Skip to content

Commit 9e05d9b

Browse files
moehanabibonzini
authored andcommitted
KVM: x86: Check irqchip mode before create PIT
As the kvm api(https://docs.kernel.org/virt/kvm/api.html) reads, KVM_CREATE_PIT2 call is only valid after enabling in-kernel irqchip support via KVM_CREATE_IRQCHIP. Without this check, I can create PIT first and enable irqchip-split then, which may cause the PIT invalid because of lacking of in-kernel PIC to inject the interrupt. Signed-off-by: Tengfei Yu <moehanabichan@gmail.com> Message-Id: <20240125050823.4893-1-moehanabichan@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 11f5633 commit 9e05d9b

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

arch/x86/kvm/x86.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7016,6 +7016,9 @@ int kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg)
70167016
r = -EEXIST;
70177017
if (kvm->arch.vpit)
70187018
goto create_pit_unlock;
7019+
r = -ENOENT;
7020+
if (!pic_in_kernel(kvm))
7021+
goto create_pit_unlock;
70197022
r = -ENOMEM;
70207023
kvm->arch.vpit = kvm_create_pit(kvm, u.pit_config.flags);
70217024
if (kvm->arch.vpit)

0 commit comments

Comments
 (0)