Skip to content

Commit dbdd096

Browse files
sean-jcbonzini
authored andcommitted
KVM: VMX: Intercept FS/GS_BASE MSR accesses for 32-bit KVM
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]>
1 parent 844d69c commit dbdd096

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

arch/x86/kvm/vmx/nested.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,7 @@ static inline bool nested_vmx_prepare_msr_bitmap(struct kvm_vcpu *vcpu,
614614
}
615615

616616
/* KVM unconditionally exposes the FS/GS base MSRs to L1. */
617+
#ifdef CONFIG_X86_64
617618
nested_vmx_disable_intercept_for_msr(msr_bitmap_l1, msr_bitmap_l0,
618619
MSR_FS_BASE, MSR_TYPE_RW);
619620

@@ -622,6 +623,7 @@ static inline bool nested_vmx_prepare_msr_bitmap(struct kvm_vcpu *vcpu,
622623

623624
nested_vmx_disable_intercept_for_msr(msr_bitmap_l1, msr_bitmap_l0,
624625
MSR_KERNEL_GS_BASE, MSR_TYPE_RW);
626+
#endif
625627

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

arch/x86/kvm/vmx/vmx.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,11 @@ static u32 vmx_possible_passthrough_msrs[MAX_POSSIBLE_PASSTHROUGH_MSRS] = {
157157
MSR_IA32_SPEC_CTRL,
158158
MSR_IA32_PRED_CMD,
159159
MSR_IA32_TSC,
160+
#ifdef CONFIG_X86_64
160161
MSR_FS_BASE,
161162
MSR_GS_BASE,
162163
MSR_KERNEL_GS_BASE,
164+
#endif
163165
MSR_IA32_SYSENTER_CS,
164166
MSR_IA32_SYSENTER_ESP,
165167
MSR_IA32_SYSENTER_EIP,
@@ -6956,9 +6958,11 @@ static int vmx_create_vcpu(struct kvm_vcpu *vcpu)
69566958
bitmap_fill(vmx->shadow_msr_intercept.write, MAX_POSSIBLE_PASSTHROUGH_MSRS);
69576959

69586960
vmx_disable_intercept_for_msr(vcpu, MSR_IA32_TSC, MSR_TYPE_R);
6961+
#ifdef CONFIG_X86_64
69596962
vmx_disable_intercept_for_msr(vcpu, MSR_FS_BASE, MSR_TYPE_RW);
69606963
vmx_disable_intercept_for_msr(vcpu, MSR_GS_BASE, MSR_TYPE_RW);
69616964
vmx_disable_intercept_for_msr(vcpu, MSR_KERNEL_GS_BASE, MSR_TYPE_RW);
6965+
#endif
69626966
vmx_disable_intercept_for_msr(vcpu, MSR_IA32_SYSENTER_CS, MSR_TYPE_RW);
69636967
vmx_disable_intercept_for_msr(vcpu, MSR_IA32_SYSENTER_ESP, MSR_TYPE_RW);
69646968
vmx_disable_intercept_for_msr(vcpu, MSR_IA32_SYSENTER_EIP, MSR_TYPE_RW);

0 commit comments

Comments
 (0)