aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorWincy Van <fanwenyi0529@gmail.com>2015-03-04 01:31:56 -0500
committerMarcelo Tosatti <mtosatti@redhat.com>2015-03-13 08:24:51 -0400
commit670125bda1d86edfadf81dc56a87582ac7fbd47b (patch)
tree3aa81d60a6db3effc49ca1a890aa50e071af21e4 /arch
parentc1a6bff28cbff796bf6e7db5cf42ec9244911be2 (diff)
KVM: VMX: Set msr bitmap correctly if vcpu is in guest mode
In commit 3af18d9c5fe9 ("KVM: nVMX: Prepare for using hardware MSR bitmap"), we are setting MSR_BITMAP in prepare_vmcs02 if we should use hardware. This is not enough since the field will be modified by following vmx_set_efer. Fix this by setting vmx_msr_bitmap_nested in vmx_set_msr_bitmap if vcpu is in guest mode. Signed-off-by: Wincy Van <fanwenyi0529@gmail.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/kvm/vmx.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index f7b20b417a3a..10a481b7674d 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -2168,7 +2168,10 @@ static void vmx_set_msr_bitmap(struct kvm_vcpu *vcpu)
2168{ 2168{
2169 unsigned long *msr_bitmap; 2169 unsigned long *msr_bitmap;
2170 2170
2171 if (irqchip_in_kernel(vcpu->kvm) && apic_x2apic_mode(vcpu->arch.apic)) { 2171 if (is_guest_mode(vcpu))
2172 msr_bitmap = vmx_msr_bitmap_nested;
2173 else if (irqchip_in_kernel(vcpu->kvm) &&
2174 apic_x2apic_mode(vcpu->arch.apic)) {
2172 if (is_long_mode(vcpu)) 2175 if (is_long_mode(vcpu))
2173 msr_bitmap = vmx_msr_bitmap_longmode_x2apic; 2176 msr_bitmap = vmx_msr_bitmap_longmode_x2apic;
2174 else 2177 else
@@ -9218,9 +9221,9 @@ static void prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12)
9218 } 9221 }
9219 9222
9220 if (cpu_has_vmx_msr_bitmap() && 9223 if (cpu_has_vmx_msr_bitmap() &&
9221 exec_control & CPU_BASED_USE_MSR_BITMAPS && 9224 exec_control & CPU_BASED_USE_MSR_BITMAPS) {
9222 nested_vmx_merge_msr_bitmap(vcpu, vmcs12)) { 9225 nested_vmx_merge_msr_bitmap(vcpu, vmcs12);
9223 vmcs_write64(MSR_BITMAP, __pa(vmx_msr_bitmap_nested)); 9226 /* MSR_BITMAP will be set by following vmx_set_efer. */
9224 } else 9227 } else
9225 exec_control &= ~CPU_BASED_USE_MSR_BITMAPS; 9228 exec_control &= ~CPU_BASED_USE_MSR_BITMAPS;
9226 9229