KVM: nVMX: Ensure vCPU honors event request if posting nested IRQ fails
authorSean Christopherson <seanjc@google.com>
Wed, 8 Dec 2021 01:52:12 +0000 (01:52 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 9 Dec 2021 14:30:46 +0000 (09:30 -0500)
commit83c98007d9fb5c827cd954fc48e9cba034ef6fdc
tree423fe4e1cf0747338e8a1e2c803bbbe6ec2fe23b
parent8e819d75cbcf541a833219521379114a76a645a6
KVM: nVMX: Ensure vCPU honors event request if posting nested IRQ fails

Add a memory barrier between writing vcpu->requests and reading
vcpu->guest_mode to ensure the read is ordered after the write when
(potentially) delivering an IRQ to L2 via nested posted interrupt.  If
the request were to be completed after reading vcpu->mode, it would be
possible for the target vCPU to enter the guest without posting the
interrupt and without handling the event request.

Note, the barrier is only for documentation since atomic operations are
serializing on x86.

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Fixes: 6b6977117f50 ("KVM: nVMX: Fix races when sending nested PI while dest enters/leaves L2")
Fixes: 705699a13994 ("KVM: nVMX: Enable nested posted interrupt processing")
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20211208015236.1616697-3-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/vmx/vmx.c