Patch "KVM/VMX: Allow direct access to MSR_IA32_SPEC_CTRL" has been added to the 4.9-stable tree
Subsystems (3)
This is a note to let you know that I've just added the patch titled
KVM/VMX: Allow direct access to MSR_IA32_SPEC_CTRL
to the 4.9-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
kvm-vmx-allow-direct-access-to-msr_ia32_spec_ctrl.patch
and it can be found in the queue-4.9 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
d28b387fb74da95d69d2615732f50cceb38e9a4dMon Sep 17 00:00:00 2001
From: KarimAllah Ahmed <[email protected]>
Date: Thu, 1 Feb 2018 22:59:45 +0100
Subject: KVM/VMX: Allow direct access to MSR_IA32_SPEC_CTRL
From: KarimAllah Ahmed <[email protected]>
commit d28b387fb74da95d69d2615732f50cceb38e9a4d upstream.
[ Based on a patch from Ashok Raj <[email protected]> ]
Add direct access to MSR_IA32_SPEC_CTRL for guests. This is needed for guests that will only mitigate Spectre V2 through IBRS+IBPB and will not be using a retpoline+IBPB based approach.
To avoid the overhead of saving and restoring the MSR_IA32_SPEC_CTRL for guests that do not actually use the MSR, only start saving and restoring when a non-zero is written to it.
No attempt is made to handle STIBP here, intentionally. Filtering STIBP may be added in a future patch, which may require trapping all writes if we don't want to pass it through directly to the guest.
[dwmw2: Clean up CPUID bits, save/restore manually, handle reset]
--- arch/x86/kvm/cpuid.c | 8 ++- arch/x86/kvm/cpuid.h | 11 +++++ arch/x86/kvm/vmx.c | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++- arch/x86/kvm/x86.c | 2 4 files changed, 118 insertions(+), 6 deletions(-)
arch/x86/kvm/cpuid.c +5 -3
@@ -357,7 +357,7 @@ static inline int __do_cpuid_ent(struct/* cpuid 0x80000008.ebx */ const u32 kvm_cpuid_8000_0008_ebx_x86_features = -F (IBPB ); +F (IBPB ) |F (IBRS );/* cpuid 0xC0000001.edx */ const u32 kvm_cpuid_C000_0001_edx_x86_features =
@@ -382,7 +382,7 @@ static inline int __do_cpuid_ent(struct/* cpuid 7.0.edx*/ const u32 kvm_cpuid_7_0_edx_x86_features = -F (ARCH_CAPABILITIES ); +F (SPEC_CTRL ) |F (ARCH_CAPABILITIES );/* all calls to cpuid_count() should be made on the same cpu */ get_cpu ();
@@ -618,9 +618,11 @@ static inline int __do_cpuid_ent(struct g_phys_as = phys_as; entry->eax = g_phys_as | (virt_as <<8 ); entry->edx =0 ; -/* IBPB isn't necessarily present in hardware cpuid */ +/* IBRS and IBPB aren't necessarily present in hardware cpuid */ if (boot_cpu_has (X86_FEATURE_IBPB )) entry->ebx |=F (IBPB ); +if (boot_cpu_has (X86_FEATURE_IBRS )) + entry->ebx |=F (IBRS ); entry->ebx &= kvm_cpuid_8000_0008_ebx_x86_features;cpuid_mask (&entry->ebx,CPUID_8000_0008_EBX );break ;
arch/x86/kvm/cpuid.h +11 -0
@@ -171,6 +171,17 @@ static inline bool guest_cpuid_has_ibpb(return best && (best->edx &bit (X86_FEATURE_SPEC_CTRL )); } +static inline bool guest_cpuid_has_ibrs (struct kvm_vcpu *vcpu) +{ +struct kvm_cpuid_entry2 *best; + + best =kvm_find_cpuid_entry (vcpu,0x80000008 ,0 ); +if (best && (best->ebx &bit (X86_FEATURE_IBRS ))) +return true; + best =kvm_find_cpuid_entry (vcpu,7 ,0 ); +return best && (best->edx &bit (X86_FEATURE_SPEC_CTRL )); +} +static inline bool guest_cpuid_has_arch_capabilities (struct kvm_vcpu *vcpu) {struct kvm_cpuid_entry2 *best;
arch/x86/kvm/vmx.c +101 -2
165 lines not on this page · raw message
arch/x86/kvm/x86.c +1 -1
@@ -975,7 +975,7 @@ static u32 msrs_to_save[] = {#endif MSR_IA32_TSC ,MSR_IA32_CR_PAT ,MSR_VM_HSAVE_PA ,MSR_IA32_FEATURE_CONTROL ,MSR_IA32_BNDCFGS ,MSR_TSC_AUX , - MSR_IA32_ARCH_CAPABILITIES + MSR_IA32_SPEC_CTRL, MSR_IA32_ARCH_CAPABILITIES };static unsigned num_msrs_to_save;
Patches currently in stable-queue which might be from [email protected] are
queue-4.9/kvm-vmx-allow-direct-access-to-msr_ia32_spec_ctrl.patch queue-4.9/kvm-x86-add-ibpb-support.patch queue-4.9/kvm-svm-allow-direct-access-to-msr_ia32_spec_ctrl.patch queue-4.9/kvm-vmx-emulate-msr_ia32_arch_capabilities.patch