]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: VMX: Consider PID.PIR to determine if vCPU has pending interrupts
authorJoao Martins <joao.m.martins@oracle.com>
Mon, 11 Nov 2019 17:20:10 +0000 (17:20 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 12 Nov 2019 09:17:40 +0000 (10:17 +0100)
commitbdfe3d23f555e47604d2f8f8414455f8e8551d71
treed9b42638af4072a7b4fdcd478f26e0aec628b53e
parentcff42d9deddee5b2c031d0f88b4936f66f968108
KVM: VMX: Consider PID.PIR to determine if vCPU has pending interrupts

Commit 463d15d0e2b7 ("KVM: Fix leak vCPU's VMCS value into other pCPU")
introduced vmx_dy_apicv_has_pending_interrupt() in order to determine
if a vCPU have a pending posted interrupt. This routine is used by
kvm_vcpu_on_spin() when searching for a a new runnable vCPU to schedule
on pCPU instead of a vCPU doing busy loop.

vmx_dy_apicv_has_pending_interrupt() determines if a
vCPU has a pending posted interrupt solely based on PID.ON. However,
when a vCPU is preempted, vmx_vcpu_pi_put() sets PID.SN which cause
raised posted interrupts to only set bit in PID.PIR without setting
PID.ON (and without sending notification vector), as depicted in VT-d
manual section 5.2.3 "Interrupt-Posting Hardware Operation".

Therefore, checking PID.ON is insufficient to determine if a vCPU has
pending posted interrupts and instead we should also check if there is
some bit set on PID.PIR if PID.SN=1.

Fixes: 463d15d0e2b7 ("KVM: Fix leak vCPU's VMCS value into other pCPU")
Reviewed-by: Jagannathan Raman <jag.raman@oracle.com>
Co-developed-by: Liran Alon <liran.alon@oracle.com>
Signed-off-by: Liran Alon <liran.alon@oracle.com>
Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/vmx/vmx.c