diff mbox

kvm: Clear stale posted interrupts when restoring apic state.

Message ID 20180717002428.39055-1-pshier@google.com (mailing list archive)
State New, archived
Headers show

Commit Message

Peter Shier July 17, 2018, 12:24 a.m. UTC
From: Andrew Honig <ahonig@google.com>

Prior to this change if userspace set the local apic state while there
was a posted interrupt waiting, then the posted interrupt would not be
cleared.

To fix this issue we clear all the not-yet-delivered posted interrupts
and put them in the apic, so that when userspace overwrites the apic,
registers, it also clears any posted interrupts.

Signed-off-by: Andrew Honig <ahonig@google.com>
Signed-off-by: Peter Shier <pshier@google.com>
---
 arch/x86/kvm/x86.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Radim Krčmář July 18, 2018, 1:55 p.m. UTC | #1
2018-07-16 17:24-0700, Peter Shier:
> From: Andrew Honig <ahonig@google.com>
> 
> Prior to this change if userspace set the local apic state while there
> was a posted interrupt waiting, then the posted interrupt would not be
> cleared.
> 
> To fix this issue we clear all the not-yet-delivered posted interrupts
> and put them in the apic, so that when userspace overwrites the apic,
> registers, it also clears any posted interrupts.
> 
> Signed-off-by: Andrew Honig <ahonig@google.com>
> Signed-off-by: Peter Shier <pshier@google.com>
> ---

Isn't this already covered by 967235d32032 ("KVM: vmx: clear pending
interrupts on KVM_SET_LAPIC")?

Thanks.
diff mbox

Patch

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 0046aa70205aa..cbb097946d32f 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3163,6 +3163,9 @@  static int kvm_vcpu_ioctl_set_lapic(struct kvm_vcpu *vcpu,
 {
 	int r;
 
+	if (vcpu->arch.apicv_active)
+		kvm_x86_ops->sync_pir_to_irr(vcpu);
+
 	r = kvm_apic_set_state(vcpu, s);
 	if (r)
 		return r;