kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] KVM: SVM: Track physical cpu and asid_generation via the vmcb
@ 2021-01-12 16:43 Cathy Avery
  2021-01-12 16:43 ` [PATCH 1/2] KVM: nSVM: Track the physical cpu of the vmcb vmrun through " Cathy Avery
  2021-01-12 16:43 ` [PATCH 2/2] KVM: nSVM: Track the ASID generation " Cathy Avery
  0 siblings, 2 replies; 4+ messages in thread
From: Cathy Avery @ 2021-01-12 16:43 UTC (permalink / raw)
  To: linux-kernel, kvm, pbonzini; +Cc: vkuznets, wei.huang2, sean.j.christopherson

In the cases where vmcbs change processors from one vmrun to another updated
information in the vmcb from a prior run can potentially be lost. By tracking
the physical cpu and asid_generation per vmcb instead of svm->vcpu the following
scenario illustrated by Paolo can be avoided.

     ---------------------          ---------------------
     pCPU 1                         pCPU 2
     ---------------------          ---------------------
     run VMCB02
                                    run VMCB02 (*)
                                    run VMCB01
     run VMCB01 (**)
     run VMCB02 (***)
     ---------------------          ---------------------

     After the point marked (*), while L2 runs, some fields change in VMCB02.
     When the processor vmexits back to L0, VMCB02 is marked clean.

     At the point marked (**), svm->vcpu.cpu becomes 1 again.

     Therefore, at the point marked (***) you will get svm->vcpu.cpu == cpu
     and the VMCB02 will not be marked dirty.  The processor can then incorrectly
     use some data that is cached from before point (*).

Theses patches are intended for the kvm nested-svm branch.

The patches have been tested on nested fedora VMs, kvm self tests, and kvm-unit-tests.
They have not been tested on SEV.

Cathy Avery (2):
  KVM: nSVM: Track the physical cpu of the vmcb vmrun through the vmcb
  KVM: nSVM: Track the ASID generation of the vmcb vmrun through the
    vmcb

 arch/x86/kvm/svm/svm.c | 45 +++++++++++++++++++++++-------------------
 arch/x86/kvm/svm/svm.h |  3 ++-
 2 files changed, 27 insertions(+), 21 deletions(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-01-13 12:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-12 16:43 [PATCH 0/2] KVM: SVM: Track physical cpu and asid_generation via the vmcb Cathy Avery
2021-01-12 16:43 ` [PATCH 1/2] KVM: nSVM: Track the physical cpu of the vmcb vmrun through " Cathy Avery
2021-01-13 12:09   ` Paolo Bonzini
2021-01-12 16:43 ` [PATCH 2/2] KVM: nSVM: Track the ASID generation " Cathy Avery

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).