KVM Archive on lore.kernel.org
 help / color / Atom feed
From: David Woodhouse <dwmw2@infradead.org>
To: kvm <kvm@vger.kernel.org>
Cc: "Sironi, Filippo" <sironi@amazon.de>,
	"Raslan, KarimAllah" <karahmed@amazon.de>,
	Matt Gingell <gingell@google.com>,
	Steve Rutherford <srutherford@google.com>,
Subject: [RFC PATCH] Fix split-irqchip vs interrupt injection window request.
Date: Wed, 25 Nov 2020 15:10:13 +0000
Message-ID: <017de9019136b5d2ec34132b96b9f0273c21d6f1.camel@infradead.org> (raw)
In-Reply-To: <62918f65ec78f8990278a6a0db0567968fa23e49.camel@infradead.org>

[-- Attachment #1: Type: text/plain, Size: 1672 bytes --]

On Thu, 2020-11-12 at 13:03 +0000, David Woodhouse wrote:
> I'm using nested VMX for testing, while I add split-irqchip support to
> my VMM. I see the vCPU lock up when attempting to deliver an interrupt.

Turns out I don't need nesting or my own VMM to reproduce this; all I
need to do is boot a guest in qemu with split-irqchip and 'noapic' on
the guest command line. It locks up before getting to a login prompt,
every time.

qemu-system-x86_64 -serial mon:stdio -machine q35,accel=kvm,kernel-irqchip=split -m 2G -display none -drive file=foo.qcow2,if=virtio

Commit 782d422bc ("KVM: x86: split kvm_vcpu_ready_for_interrupt_injection
out of dm_request_for_irq_injection") made dm_request_for_irq_injection()
return true even when kvm_cpu_has_interrupt() is true.

So we enable the vmexit on interrupt window because userspace asked for
it, but then kvm_vcpu_ready_for_interrupt_injection() returns false,
causing us *not* to exit all the way to userspace but just to loop in
vcpu_run() instead.

But we *didn't* have an injectable interrupt from the kernel, so we
just go straight back into the guest, vmexit again, loop again, ad

This appears to fix it:

--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4028,7 +4028,7 @@ static int kvm_cpu_accept_dm_intr(struct kvm_vcpu *vcpu)
 static int kvm_vcpu_ready_for_interrupt_injection(struct kvm_vcpu *vcpu)
        return kvm_arch_interrupt_allowed(vcpu) &&
-               !kvm_cpu_has_interrupt(vcpu) &&
+               !kvm_cpu_has_injectable_intr(vcpu) &&
                !kvm_event_needs_reinjection(vcpu) &&

[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 5174 bytes --]

  reply index

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-12 13:03 [RFC] Further hack request_interrupt_window handling to work around kvm_cpu_has_interrupt() nesting breakage David Woodhouse
2020-11-25 15:10 ` David Woodhouse [this message]
2020-11-25 21:19   ` [RFC PATCH] Fix split-irqchip vs interrupt injection window request Sean Christopherson
2020-11-26 11:10     ` David Woodhouse
2020-11-26 12:05       ` [PATCH] kvm/x86: Fix simultaneous ExtINT and lapic interrupt handling with APICv David Woodhouse
2020-11-26 18:00         ` Paolo Bonzini
2020-11-26 19:07           ` David Woodhouse
2020-11-26 17:29       ` [RFC PATCH] Fix split-irqchip vs interrupt injection window request David Woodhouse
2020-11-26 17:59         ` Paolo Bonzini
2020-11-26 21:48           ` David Woodhouse
2020-11-27  4:37             ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=017de9019136b5d2ec34132b96b9f0273c21d6f1.camel@infradead.org \
    --to=dwmw2@infradead.org \
    --cc=gingell@google.com \
    --cc=karahmed@amazon.de \
    --cc=kvm@vger.kernel.org \
    --cc=liran@amazon.com \
    --cc=sironi@amazon.de \
    --cc=srutherford@google.com \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

KVM Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/kvm/0 kvm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 kvm kvm/ https://lore.kernel.org/kvm \
	public-inbox-index kvm

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git