KVM_CREATE_PIT2
evrim opened this issue · comments
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.