KVM: x86: Use a stable condition around all VT-d PI paths
authorPaolo Bonzini <pbonzini@redhat.com>
Tue, 23 Nov 2021 00:43:11 +0000 (19:43 -0500)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 30 Nov 2021 08:53:14 +0000 (03:53 -0500)
commit53b7ca1a359389276c76fbc9e1009d8626a17e40
tree1897535502db60075d8d4d5830ea99e82620a691
parent37c4dbf337c5c2cdb24365ffae6ed70ac1e74d7a
KVM: x86: Use a stable condition around all VT-d PI paths

Currently, checks for whether VT-d PI can be used refer to the current
status of the feature in the current vCPU; or they more or less pick
vCPU 0 in case a specific vCPU is not available.

However, these checks do not attempt to synchronize with changes to
the IRTE.  In particular, there is no path that updates the IRTE when
APICv is re-activated on vCPU 0; and there is no path to wakeup a CPU
that has APICv disabled, if the wakeup occurs because of an IRTE
that points to a posted interrupt.

To fix this, always go through the VT-d PI path as long as there are
assigned devices and APICv is available on both the host and the VM side.
Since the relevant condition was copied over three times, take the hint
and factor it into a separate function.

Suggested-by: Sean Christopherson <seanjc@google.com>
Cc: stable@vger.kernel.org
Reviewed-by: Sean Christopherson <seanjc@google.com>
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
Reviewed-by: David Matlack <dmatlack@google.com>
Message-Id: <20211123004311.2954158-5-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/vmx/posted_intr.c