8000 KVM_CREATE_PIT2 · Issue #1 · kvmtool/kvmtool · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

KVM_CREATE_PIT2 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
evrim opened this issue Aug 27, 2017 · 3 comments
Open

KVM_CREATE_PIT2 #1

evrim opened this issue Aug 27, 2017 · 3 comments

Comments

@evrim
Copy link
evrim commented Aug 27, 2017

Hello,

kvm.c<x86> reads:

 133 │ void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size)                                         
 134 │ {                                                                                                                      
 135 │     struct kvm_pit_config pit_config = { .flags = 0, };                                                                
 136 │     int ret;                                                                                                           
 137 │                                                                                                                        
 138 │     ret = ioctl(kvm->vm_fd, KVM_SET_TSS_ADDR, 0xfffbd000);                                                             
 139 │     if (ret < 0)                                                                                                       
 140 │         die_perror("KVM_SET_TSS_ADDR ioctl");                                                                          
 141 │                                                                                                                        
 142 │     ret = ioctl(kvm->vm_fd, KVM_CREATE_PIT2, &pit_config);                                                             
 143 │     if (ret < 0)                                                                                                       
 144 │         die_perror("KVM_CREATE_PIT2 ioctl");                                                                           
 145 │                                                                                                                        
 146 │     if (ram_size < KVM_32BIT_GAP_START) {                                                                              
 147 │         kvm->ram_size = ram_size;                                                                                      
 148 │         kvm->ram_start = mmap_anon_or_hugetlbfs(kvm, hugetlbfs_path, ram_size);                                        
 149 │     } else {                                                                                                           
 150 │         kvm->ram_start = mmap_anon_or_hugetlbfs(kvm, hugetlbfs_path, ram_size + KVM_32BIT_GAP_SIZE);                   
 151 │         kvm->ram_size = ram_size + KVM_32BIT_GAP_SIZE;                                                                 
 152 │         if (kvm->ram_start != MAP_FAILED)                                                                              
 153 │             /*                                                                                                         
 154 │              * We mprotect the gap (see kvm__init_ram() for details) PROT_NONE so that                                 
 155 │              * if we accidently write to it, we will know.                                                             
 156 │              */                                                                                                        
 157 │             mprotect(kvm->ram_start + KVM_32BIT_GAP_START, KVM_32BIT_GAP_SIZE, PROT_NONE);                             
 158 │     }                                                                                                                  
 159 │     if (kvm->ram_start == MAP_FAILED)                                                                                  
 160 │         die("out of memory");                                                                                          
 161 │                                                                                                                        
 162 │     madvise(kvm->ram_start, kvm->ram_size, MADV_MERGEABLE);                                                            
 163 │                                                                                                                        
 164 │     ret = ioctl(kvm->vm_fd, KVM_CREATE_IRQCHIP);                                                                       
 165 │     if (ret < 0)                                                                                                       
 166 │         die_perror("KVM_CREATE_IRQCHIP ioctl");                                                                        
 167 │ }

Interestingly, kernel Documentation/virtual/kvm/api.txt reads:

Capability: KVM_CAP_PIT2
Architectures: x86
Type: vm ioctl
Parameters: struct kvm_pit_config (in)
Returns: 0 on success, -1 on error

Creates an in-kernel device model for the i8254 PIT. This call is only valid
after enabling in-kernel irqchip support via KVM_CREATE_IRQCHIP. The following
parameters have to be passed:

Question: should CREATE_PIT2 be executed after CREATE_IRQCHIP in line 164?

best,
evrim.

asias pushed a commit that referenced this issue Apr 9, 2022
Linux, besides CPIO, supports 7 different compressed formats for the initrd
(gzip, bzip2, LZMA, XZ, LZO, LZ4, ZSTD), but kvmtool only recognizes one of
them.

Remove the initrd magic check because:

1. It doesn't bring much to the end user, as the Linux kernel still
   complains if the initrd is in an unknown format.

2. --kernel can be used to load something that is not a Linux kernel (like
   a kvm-unit-tests test), in which case a format which is not supported by
   a Linux kernel can still be perfectly valid. For example, kvm-unit-tests
   load the test environment as an initrd in plain ASCII format.

3. It cuts down on the maintenance effort when new formats are added to
   the Linux kernel. Not a big deal, since that doesn't happen very often,
   but it's still an effort with very little gain (see point #1 above).

Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
Link: https://lore.kernel.org/r/20220214165830.69207-2-alexandru.elisei@arm.com
Signed-off-by: Will Deacon <will@kernel.org>
@bjackman
Copy link

Looks like since this commit the CREATE_PIT2 command fails in practice.

If I just reorder the ioctls in kvm__arch_init it seems to work

@bjackman
Copy link

@bjackman
Copy link

This is now fixed by e73a6b2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0