Skip to content

Add support for XSAVES to AMD and unify it with Intel

Aaron Lewis kvm 3 versions – Applied

Status from this message: Queued, thanks.

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest9 patches 2 repliesApplied
  2. v25 patches 5 repliesSuperseded
  3. v16 patches 19 repliesSuperseded

Changes in v3 from the cover letter

- Remove guest_xcr0_loaded from kvm_vcpu.
- Add vcpu->arch.xsaves_enabled.
- Add staged rollout to load the hardware IA32_XSS MSR with guest/host values on VM-entry and VM-exit:
1) Introduce vcpu->arch->xsaves_enabled.
2) Add svm implementation for switching between guest and host IA32_XSS.
3) Add vmx implementation for switching between guest and host IA32_XSS.
4) Remove svm and vmx implementation and add it to common code.

Patches in v3 Applied

#Subject and filesSizeRepliesApplied
1/9KVM: x86: Introduce vcpu->arch.xsaves_enabledarch/x86/include/asm/kvm_host.h arch/x86/kvm/svm.c arch/x86/kvm/vmx/vmx.c+9 -00 replies
2/9KVM: VMX: Fix conditions for guest IA32_XSS supportarch/x86/kvm/vmx/vmx.c+11 -131 reply
3/9KVM: x86: Remove unneeded kvm_vcpu variable, guest_xcr0_loadedarch/x86/kvm/x86.c include/linux/kvm_host.h+5 -120 replies
4/9KVM: SVM: Use wrmsr for switching between guest and host IA32_XSS on AMDarch/x86/kvm/svm.c+23 -00 replies
5/9KVM: VMX: Use wrmsr for switching between guest and host IA32_XSS on Intelarch/x86/kvm/vmx/vmx.c+18 -70 replies
6/9KVM: x86: Move IA32_XSS-swapping on VM-entry/VM-exit to common x86 codearch/x86/kvm/svm.c arch/x86/kvm/vmx/vmx.c arch/x86/kvm/x86.c +1 more+34 -620 replies
7/9kvm: x86: Move IA32_XSS to kvm_{get,set}_msr_commonarch/x86/kvm/vmx/vmx.c arch/x86/kvm/x86.c+20 -180 replies
8/9kvm: svm: Update svm_xsaves_supportedarch/x86/kvm/svm.c+1 -10 replies
9/9kvm: tests: Add test to verify MSR_IA32_XSStools/testing/selftests/kvm/.gitignore tools/testing/selftests/kvm/Makefile tools/testing/selftests/kvm/include/x86_64/processor.h +2 more+147 -100 replies

Reviews trailers per patch

All 9 patches have a Reviewed-by or Acked-by.

PatchJim Mattson
1/9R-b
2/9R-b
3/9R-b
4/9R-b
5/9R-b
6/9R-b
7/9R-b
8/9R-b
9/9R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/9] Add support for XSAVES to AMD and unify it with Intel

Unify AMD's and Intel's approach for supporting XSAVES. To do this change Intel's approach from using the MSR-load areas to writing the guest/host values to IA32_XSS on a VM-enter/VM-exit. Switching to this strategy allows for a common approach between both AMD and Intel. Additionally, define svm_xsaves_supported() based on AMD's feedback, and add vcpu->arch.xsaves_enabled to track whether XSAVES is enabled in the guest.

This change sets up IA32_XSS to be a non-zero value in the future, which may happen sooner than later with support for guest CET feature being added.

v2 -> v3:
- Remove guest_xcr0_loaded from kvm_vcpu.
- Add vcpu->arch.xsaves_enabled.
- Add staged rollout to load the hardware IA32_XSS MSR with guest/host values on VM-entry and VM-exit:
1) Introduce vcpu->arch->xsaves_enabled.
2) Add svm implementation for switching between guest and host IA32_XSS.
3) Add vmx implementation for switching between guest and host IA32_XSS.
4) Remove svm and vmx implementation and add it to common code.

v1 -> v2:
- Add the flag xsaves_enabled to kvm_vcpu_arch to track when XSAVES is enabled in the guest, whether or not XSAVES is enumerated in the guest CPUID.
- Remove code that sets the X86_FEATURE_XSAVES bit in the guest CPUID which was added in patch "Enumerate XSAVES in guest CPUID when it is available to the guest". As a result we no longer need that patch.
- Added a comment to kvm_set_msr_common to describe how to save/restore PT MSRS without using XSAVES/XRSTORS.
- Added more comments to the "Add support for XSAVES on AMD" patch.
- Replaced vcpu_set_msr_expect_result() with _vcpu_set_msr() in the test library.

Aaron Lewis (9):
KVM: x86: Introduce vcpu->arch.xsaves_enabled
KVM: VMX: Fix conditions for guest IA32_XSS support
KVM: x86: Remove unneeded kvm_vcpu variable, guest_xcr0_loaded
KVM: SVM: Use wrmsr for switching between guest and host IA32_XSS on AMD
KVM: VMX: Use wrmsr for switching between guest and host IA32_XSS on Intel
KVM: x86: Move IA32_XSS-swapping on VM-entry/VM-exit to common x86 code
kvm: x86: Move IA32_XSS to kvm_{get,set}_msr_common
kvm: svm: Update svm_xsaves_supported
kvm: tests: Add test to verify MSR_IA32_XSS

 arch/x86/include/asm/kvm_host.h               |  1 +
 arch/x86/kvm/svm.c                            |  9 ++-
 arch/x86/kvm/vmx/vmx.c                        | 41 ++--------
 arch/x86/kvm/x86.c                            | 52 ++++++++++---
 arch/x86/kvm/x86.h                            |  4 +-
 include/linux/kvm_host.h                      |  1 -
 tools/testing/selftests/kvm/.gitignore        |  1 +
 tools/testing/selftests/kvm/Makefile          |  1 +
 .../selftests/kvm/include/x86_64/processor.h  |  7 +-
 .../selftests/kvm/lib/x86_64/processor.c      | 72 +++++++++++++++---
 .../selftests/kvm/x86_64/xss_msr_test.c       | 76 +++++++++++++++++++
 11 files changed, 205 insertions(+), 60 deletions(-)
 create mode 100644 tools/testing/selftests/kvm/x86_64/xss_msr_test.c
Signature · 1 line
2.23.0.866.gb869b98d4c-goog