]> git.baikalelectronics.ru Git - kernel.git/commit
kvm: x86: Sink cpuid update into vendor-specific set_cr4 functions
authorJim Mattson <jmattson@google.com>
Thu, 29 Oct 2020 17:06:48 +0000 (10:06 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Sun, 15 Nov 2020 14:49:18 +0000 (09:49 -0500)
commit9a2f174b56a04ed8eca3321a83a3ba560ceb6664
tree4eccd9a7b512efa64086921a3baae79f442e7b11
parent47d677c120aaf64cc34c2f95497e519dea230bbd
kvm: x86: Sink cpuid update into vendor-specific set_cr4 functions

On emulated VM-entry and VM-exit, update the CPUID bits that reflect
CR4.OSXSAVE and CR4.PKE.

This fixes a bug where the CPUID bits could continue to reflect L2 CR4
values after emulated VM-exit to L1. It also fixes a related bug where
the CPUID bits could continue to reflect L1 CR4 values after emulated
VM-entry to L2. The latter bug is mainly relevant to SVM, wherein
CPUID is not a required intercept. However, it could also be relevant
to VMX, because the code to conditionally update these CPUID bits
assumes that the guest CPUID and the guest CR4 are always in sync.

Fixes: 4479634cd655c0 ("KVM: nVMX: fix guest CR4 loading when emulating L2 to L1 exit")
Fixes: 9e34e753b462e7 ("KVM: VMX: Enable XSAVE/XRSTOR for guest")
Fixes: b1e422fb7ff2e9 ("KVM, pkeys: expose CPUID/CR4 to guest")
Reported-by: Abhiroop Dabral <adabral@paloaltonetworks.com>
Signed-off-by: Jim Mattson <jmattson@google.com>
Reviewed-by: Ricardo Koller <ricarkol@google.com>
Reviewed-by: Peter Shier <pshier@google.com>
Cc: Haozhong Zhang <haozhong.zhang@intel.com>
Cc: Dexuan Cui <dexuan.cui@intel.com>
Cc: Huaitong Han <huaitong.han@intel.com>
Message-Id: <20201029170648.483210-1-jmattson@google.com>
arch/x86/kvm/cpuid.c
arch/x86/kvm/svm/svm.c
arch/x86/kvm/vmx/vmx.c
arch/x86/kvm/x86.c