linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: x86: Check irqchip mode before create PIT
@ 2024-01-24 16:02 Brilliant Hanabi
  2024-01-24 16:32 ` Sean Christopherson
  0 siblings, 1 reply; 9+ messages in thread
From: Brilliant Hanabi @ 2024-01-24 16:02 UTC (permalink / raw)
  To: Sean Christopherson, Paolo Bonzini, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Dave Hansen, x86, H. Peter Anvin
  Cc: Brilliant Hanabi, kvm, linux-kernel

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: Brilliant Hanabi <moehanabichan@gmail.com>
---
 arch/x86/kvm/x86.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 27e23714e960..3edc8478310f 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -7016,6 +7016,8 @@ int kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg)
 		r = -EEXIST;
 		if (kvm->arch.vpit)
 			goto create_pit_unlock;
+		if (!pic_in_kernel(kvm))
+			goto create_pit_unlock;
 		r = -ENOMEM;
 		kvm->arch.vpit = kvm_create_pit(kvm, u.pit_config.flags);
 		if (kvm->arch.vpit)
-- 
2.39.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-01-26 18:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-24 16:02 [PATCH] KVM: x86: Check irqchip mode before create PIT Brilliant Hanabi
2024-01-24 16:32 ` Sean Christopherson
2024-01-24 17:02   ` moehanabi
2024-01-24 17:43     ` Sean Christopherson
2024-01-24 19:01       ` Brilliant Hanabi
2024-01-24 23:59         ` Sean Christopherson
2024-01-25  5:08           ` [PATCH v2] " Tengfei Yu
2024-01-26 18:12             ` Paolo Bonzini
2024-01-26 18:11           ` Re: Re: [PATCH] " Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).