Skip to content

Commit 8fcdfa7

Browse files
sean-jcgregkh
authored andcommitted
KVM: VMX: Intercept FS/GS_BASE MSR accesses for 32-bit KVM
[ Upstream commit dbdd096 ] Disable pass-through of the FS and GS base MSRs for 32-bit KVM. Intel's SDM unequivocally states that the MSRs exist if and only if the CPU supports x86-64. FS_BASE and GS_BASE are mostly a non-issue; a clever guest could opportunistically use the MSRs without issue. KERNEL_GS_BASE is a bigger problem, as a clever guest would subtly be broken if it were migrated, as KVM disallows software access to the MSRs, and unlike the direct variants, KERNEL_GS_BASE needs to be explicitly migrated as it's not captured in the VMCS. Fixes: 25c5f22 ("KVM: VMX: Enable MSR Bitmap feature") Signed-off-by: Sean Christopherson <[email protected]> Message-Id: <[email protected]> [*NOT* for stable kernels. - Paolo] Signed-off-by: Paolo Bonzini <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 4fcaad2 commit 8fcdfa7

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

arch/x86/kvm/vmx/nested.c

+2
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,7 @@ static inline bool nested_vmx_prepare_msr_bitmap(struct kvm_vcpu *vcpu,
618618
}
619619

620620
/* KVM unconditionally exposes the FS/GS base MSRs to L1. */
621+
#ifdef CONFIG_X86_64
621622
nested_vmx_disable_intercept_for_msr(msr_bitmap_l1, msr_bitmap_l0,
622623
MSR_FS_BASE, MSR_TYPE_RW);
623624

@@ -626,6 +627,7 @@ static inline bool nested_vmx_prepare_msr_bitmap(struct kvm_vcpu *vcpu,
626627

627628
nested_vmx_disable_intercept_for_msr(msr_bitmap_l1, msr_bitmap_l0,
628629
MSR_KERNEL_GS_BASE, MSR_TYPE_RW);
630+
#endif
629631

630632
/*
631633
* Checking the L0->L1 bitmap is trying to verify two things:

arch/x86/kvm/vmx/vmx.c

+4
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,11 @@ static u32 vmx_possible_passthrough_msrs[MAX_POSSIBLE_PASSTHROUGH_MSRS] = {
156156
MSR_IA32_SPEC_CTRL,
157157
MSR_IA32_PRED_CMD,
158158
MSR_IA32_TSC,
159+
#ifdef CONFIG_X86_64
159160
MSR_FS_BASE,
160161
MSR_GS_BASE,
161162
MSR_KERNEL_GS_BASE,
163+
#endif
162164
MSR_IA32_SYSENTER_CS,
163165
MSR_IA32_SYSENTER_ESP,
164166
MSR_IA32_SYSENTER_EIP,
@@ -6904,9 +6906,11 @@ static int vmx_create_vcpu(struct kvm_vcpu *vcpu)
69046906
bitmap_fill(vmx->shadow_msr_intercept.write, MAX_POSSIBLE_PASSTHROUGH_MSRS);
69056907

69066908
vmx_disable_intercept_for_msr(vcpu, MSR_IA32_TSC, MSR_TYPE_R);
6909+
#ifdef CONFIG_X86_64
69076910
vmx_disable_intercept_for_msr(vcpu, MSR_FS_BASE, MSR_TYPE_RW);
69086911
vmx_disable_intercept_for_msr(vcpu, MSR_GS_BASE, MSR_TYPE_RW);
69096912
vmx_disable_intercept_for_msr(vcpu, MSR_KERNEL_GS_BASE, MSR_TYPE_RW);
6913+
#endif
69106914
vmx_disable_intercept_for_msr(vcpu, MSR_IA32_SYSENTER_CS, MSR_TYPE_RW);
69116915
vmx_disable_intercept_for_msr(vcpu, MSR_IA32_SYSENTER_ESP, MSR_TYPE_RW);
69126916
vmx_disable_intercept_for_msr(vcpu, MSR_IA32_SYSENTER_EIP, MSR_TYPE_RW);

0 commit comments

Comments
 (0)