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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
2.23.0.866.gb869b98d4c-goog




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux