]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: SVM: Ensure target pCPU is read once when signalling AVIC doorbell
authorSean Christopherson <seanjc@google.com>
Sat, 9 Oct 2021 02:11:55 +0000 (19:11 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 8 Dec 2021 09:24:45 +0000 (04:24 -0500)
commit5ccc3026db1bf273964b7fb5a0e0cd4153730303
tree89250072fc71715415021a23fab3e8a2f0e918fa
parentc16417b3448ea0e8241969cc54f3f7580633baef
KVM: SVM: Ensure target pCPU is read once when signalling AVIC doorbell

Ensure vcpu->cpu is read once when signalling the AVIC doorbell.  If the
compiler rereads the field and the vCPU is migrated between the check and
writing the doorbell, KVM would signal the wrong physical CPU.

Functionally, signalling the wrong CPU in this case is not an issue as
task migration means the vCPU has exited and will pick up any pending
interrupts on the next VMRUN.  Add the READ_ONCE() purely to clean up the
code.

Opportunistically add a comment explaining the task migration behavior,
and rename cpuid=>cpu to avoid conflating the CPU number with KVM's more
common usage of CPUID.

Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20211009021236.4122790-3-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/svm/avic.c