Skip to content

KVM: x86/SVM: Fixes for AMD ERAPS virtualization

Jim Mattson kvm 2 versions – NAK

Status from this message: NAK, the whole point of KVM_REQ_TLB_FLUSH_GUEST is emulate TLB invalidations in

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest3 patches 5 repliesNAK
  2. v13 patches 0 repliesSuperseded

Changes in v2 from the cover letter

* Restored the ALLOW_LARGER_RAP configuration in init_vmcb() [Sashiko]

Patches in v2

#Subject and filesSizeRepliesApplied
1/3KVM: SVM: Configure ALLOW_LARGER_RAP in svm_vcpu_after_set_cpuid()arch/x86/kvm/svm/svm.c+5 -02 replies
2/3KVM: SVM: Dirty ERAPS register on all ASID TLB flushesarch/x86/kvm/svm/svm.c+3 -82 replies
3/3KVM: x86: Flush guest TLB on MTRR MSR writesarch/x86/kvm/mtrr.c+1 -01 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/3] KVM: x86/SVM: Fixes for AMD ERAPS virtualization

This series fixes three issues in KVM's virtualization of Enhanced Return Address Predictor Security (ERAPS):

Patch 1 adds ALLOW_LARGER_RAP configuration to svm_vcpu_after_set_cpuid() so that the BSP will be properly configured. The ALLOW_LARGER_RAP configuration in init_vmcb() is retained to restore the bit after the VMCB is cleared on the VCPU triple fault path.

Patch 2 moves ERAPS dirty tracking into svm_flush_tlb_asid(). AMD ERAPS architecturally requires clearing the Return Address Predictor (RAP/RSB) on all implicit TLB invalidations. Centralizing dirty tracking in svm_flush_tlb_asid() ensures that local/current ASID flushes (e.g. same-value CR3 reloads under shadow paging, CR4.PAE/SMEP toggles, single-context INVPCID) correctly mark ERAPS dirty and clear the RAP on the next VMRUN.

Patch 3 adds a KVM_REQ_TLB_FLUSH_GUEST request to kvm_mtrr_set_msr() when MTRR MSRs are written via WRMSR. Per AMD APM and Intel SDM, MTRR writes are implicit TLB invalidations. Requesting a guest TLB flush restores x86 architectural compliance and ensures ERAPS RAP clearing on MTRR writes.

v1 -> v2:

* Restored the ALLOW_LARGER_RAP configuration in init_vmcb() [Sashiko]

v1: https://lore.kernel.org/kvm/[email protected]/

Jim Mattson (3):
KVM: SVM: Configure ALLOW_LARGER_RAP in svm_vcpu_after_set_cpuid()
KVM: SVM: Dirty ERAPS register on all ASID TLB flushes
KVM: x86: Flush guest TLB on MTRR MSR writes

 arch/x86/kvm/mtrr.c    |  1 +
 arch/x86/kvm/svm/svm.c | 16 ++++++++--------
 2 files changed, 9 insertions(+), 8 deletions(-)

base-commit: 58717b2a1365d06c8c64b72aa948541b53fe31eb

Signature · 1 line
2.55.0.229.g6434b31f56-goog