All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/3] KVM: x86: request interrupt window when IRQ chip is split
@ 2015-11-12 19:08 Matt Gingell
  2015-11-13  8:56 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: Matt Gingell @ 2015-11-12 19:08 UTC (permalink / raw)
  To: kvm; +Cc: Steve Rutherford

Before this patch we incorrectly enter the guest without requesting an
interrupt window if the IRQ chip is split between user space and the
kernel.

Because lapic_in_kernel no longer implies the PIC is in the kernel, this
patch tests pic_in_kernel to determining whether an interrupt window
should be requested when entering the guest.

If the APIC is in the kernel and we request an interrupt window the
guest will return immediately. If the APIC is masked the guest will not
not make forward progress and unmask it, leading to a loop when KVM
reenters and requests again. This patch adds a check to ensure the APIC
is ready to accept an interrupt before requesting a window.

Reviewed-by: Andy Honig <ahonig@google.com>
Signed-off-by: Matt Gingell <gingell@google.com>
---
 arch/x86/kvm/x86.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 456973b..fd64dee 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -6258,10 +6258,14 @@ void kvm_arch_mmu_notifier_invalidate_page(struct kvm *kvm,
 static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
 {
 	int r;
-	bool req_int_win = !lapic_in_kernel(vcpu) &&
+	bool req_int_win = !pic_in_kernel(vcpu->kvm) &&
 		vcpu->run->request_interrupt_window;
+
 	bool req_immediate_exit = false;
 
+	if (irqchip_split(vcpu->kvm))
+		req_int_win = req_int_win && kvm_apic_accept_pic_intr(vcpu);
+
 	if (vcpu->requests) {
 		if (kvm_check_request(KVM_REQ_MMU_RELOAD, vcpu))
 			kvm_mmu_unload(vcpu);
-- 
2.6.0.rc2.230.g3dd15c0



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

* Re: [PATCH 2/3] KVM: x86: request interrupt window when IRQ chip is split
  2015-11-12 19:08 [PATCH 2/3] KVM: x86: request interrupt window when IRQ chip is split Matt Gingell
@ 2015-11-13  8:56 ` Paolo Bonzini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2015-11-13  8:56 UTC (permalink / raw)
  To: Matt Gingell, kvm; +Cc: Steve Rutherford



On 12/11/2015 20:08, Matt Gingell wrote:
> +	bool req_int_win = !pic_in_kernel(vcpu->kvm) &&
>  		vcpu->run->request_interrupt_window;

Hey, this is the new form of dm_request_for_irq_injection I have
just written about, in the review to patch 3.

So it's probably best to swap these two.

>  	bool req_immediate_exit = false;
>  
> +	if (irqchip_split(vcpu->kvm))
> +		req_int_win = req_int_win && kvm_apic_accept_pic_intr(vcpu);

Overall this is

	bool req_int_win =
		vcpu->run->request_interrupt_window &&
		!pic_in_kernel(vcpu->kvm) &&
		(!lapic_in_kernel(vcpu) || kvm_apic_accept_pic_intr(vcpu))

writing it in this form is nice, because it's again very similar to
the tests you're using in patch 3.

Paolo

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

end of thread, other threads:[~2015-11-13  8:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-12 19:08 [PATCH 2/3] KVM: x86: request interrupt window when IRQ chip is split Matt Gingell
2015-11-13  8:56 ` Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.