KVM: x86: Disable Intel PT when VMXON in L1 guest
authorLuwei Kang <luwei.kang@intel.com>
Wed, 24 Oct 2018 08:05:16 +0000 (16:05 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 21 Dec 2018 10:28:38 +0000 (11:28 +0100)
Currently, Intel Processor Trace do not support tracing in L1 guest
VMX operation(IA32_VMX_MISC[bit 14] is 0). As mentioned in SDM,
on these type of processors, execution of the VMXON instruction will
clears IA32_RTIT_CTL.TraceEn and any attempt to write IA32_RTIT_CTL
causes a general-protection exception (#GP).

Signed-off-by: Luwei Kang <luwei.kang@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/vmx/nested.c
arch/x86/kvm/vmx/vmx.c

index adc8493132ee4a0f7b29a1f3f86e843c25fe21d2..d839864aa8b0cb7274f730fcf38e49e95b218853 100644 (file)
@@ -4167,6 +4167,12 @@ static int enter_vmx_operation(struct kvm_vcpu *vcpu)
 
        vmx->nested.vmcs02_initialized = false;
        vmx->nested.vmxon = true;
+
+       if (pt_mode == PT_MODE_HOST_GUEST) {
+               vmx->pt_desc.guest.ctl = 0;
+               pt_update_intercept_for_msr(vmx);
+       }
+
        return 0;
 
 out_shadow_vmcs:
index 338c650912415489d82c112b05fef4d429d73649..3ef444de0c5ead31115d56a0cd12b5a8efc67753 100644 (file)
@@ -1926,7 +1926,8 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
                break;
        case MSR_IA32_RTIT_CTL:
                if ((pt_mode != PT_MODE_HOST_GUEST) ||
-                       vmx_rtit_ctl_check(vcpu, data))
+                       vmx_rtit_ctl_check(vcpu, data) ||
+                       vmx->nested.vmxon)
                        return 1;
                vmcs_write64(GUEST_IA32_RTIT_CTL, data);
                vmx->pt_desc.guest.ctl = data;