[PATCH] kvm: vmx: Move check for MSR bitmap support into vmx_update_msr_bitmap

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



vmx_update_msr_bitmap should only run if the CPU supports the "use MSR
bitmaps" VM-execution control. Some callers make the check but one does
not. This change moves the check from the call sites into
vmx_update_msr_bitmap to ensure that the check is always done.

Signed-off-by: Peter Shier <pshier@xxxxxxxxxx>
Reviewed-by: Jim Mattson <jmattson@xxxxxxxxxx>
---
 arch/x86/kvm/vmx.c | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 1689f433f3a08..e9744b6324d1d 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -3088,8 +3088,7 @@ static void setup_msrs(struct vcpu_vmx *vmx)
 
 	vmx->save_nmsrs = save_nmsrs;
 
-	if (cpu_has_vmx_msr_bitmap())
-		vmx_update_msr_bitmap(&vmx->vcpu);
+	vmx_update_msr_bitmap(&vmx->vcpu);
 }
 
 static u64 vmx_read_l1_tsc_offset(struct kvm_vcpu *vcpu)
@@ -5726,10 +5725,18 @@ static void vmx_update_msr_bitmap_x2apic(unsigned long *msr_bitmap,
 
 static void vmx_update_msr_bitmap(struct kvm_vcpu *vcpu)
 {
-	struct vcpu_vmx *vmx = to_vmx(vcpu);
-	unsigned long *msr_bitmap = vmx->vmcs01.msr_bitmap;
-	u8 mode = vmx_msr_bitmap_mode(vcpu);
-	u8 changed = mode ^ vmx->msr_bitmap_mode;
+	struct vcpu_vmx *vmx;
+	unsigned long *msr_bitmap;
+	u8 mode;
+	u8 changed;
+
+	if (!cpu_has_vmx_msr_bitmap())
+		return;
+
+	vmx = to_vmx(vcpu);
+	msr_bitmap = vmx->vmcs01.msr_bitmap;
+	mode = vmx_msr_bitmap_mode(vcpu);
+	changed = mode ^ vmx->msr_bitmap_mode;
 
 	if (!changed)
 		return;
@@ -5993,8 +6000,7 @@ static void vmx_refresh_apicv_exec_ctrl(struct kvm_vcpu *vcpu)
 					SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY);
 	}
 
-	if (cpu_has_vmx_msr_bitmap())
-		vmx_update_msr_bitmap(vcpu);
+	vmx_update_msr_bitmap(vcpu);
 }
 
 static u32 vmx_exec_control(struct vcpu_vmx *vmx)
@@ -12344,8 +12350,7 @@ static void load_vmcs12_host_state(struct kvm_vcpu *vcpu,
 	kvm_set_dr(vcpu, 7, 0x400);
 	vmcs_write64(GUEST_IA32_DEBUGCTL, 0);
 
-	if (cpu_has_vmx_msr_bitmap())
-		vmx_update_msr_bitmap(vcpu);
+	vmx_update_msr_bitmap(vcpu);
 
 	if (nested_vmx_load_msr(vcpu, vmcs12->vm_exit_msr_load_addr,
 				vmcs12->vm_exit_msr_load_count))
-- 
2.18.0.233.g985f88cf7e-goog




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux