Re: [PATCH v2] KVM: x86: accept userspace interrupt only if no event is injected

From: Paolo Bonzini
Date: Tue Jul 27 2021 - 17:10:05 EST


On 27/07/21 22:58, Sean Christopherson wrote:
---
arch/x86/kvm/x86.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 4116567f3d44..5e921f1e00db 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4358,8 +4358,18 @@ static int kvm_cpu_accept_dm_intr(struct kvm_vcpu *vcpu)
static int kvm_vcpu_ready_for_interrupt_injection(struct kvm_vcpu *vcpu)
{
+ /*
+ * Do not cause an interrupt window exit if an exception
+ * is pending or an event needs reinjection; userspace
+ * might want to inject the interrupt manually using KVM_SET_REGS
+ * or KVM_SET_SREGS. For that to work, we must be at an
+ * instruction boundary and with no events half-injected.
+ */
return kvm_arch_interrupt_allowed(vcpu) &&
- kvm_cpu_accept_dm_intr(vcpu);
+ kvm_cpu_accept_dm_intr(vcpu) &&

Opportunistically align this indentation?

Yep, good idea.

+ !kvm_event_needs_reinjection(vcpu)

Missing &&, apparently the mysterious cherry-pick didn't go so well :-)

Well, yeah. The only way I can excuse myself, is by not being the kind of person that yells for such stupid things...

Paolo