Received: by 10.213.65.68 with SMTP id h4csp865039imn; Tue, 20 Mar 2018 18:13:15 -0700 (PDT) X-Google-Smtp-Source: AG47ELumGtWx+CSLDbC8n38egD6/pW+IFt10KHvse5gxcfswRRnX4o6KVvkyu7JBZtwpp901d37f X-Received: by 2002:a17:902:b101:: with SMTP id q1-v6mr18696049plr.287.1521594795164; Tue, 20 Mar 2018 18:13:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521594795; cv=none; d=google.com; s=arc-20160816; b=sNVWq8tXVAgzQQPp3HU/7YQdOj4qqgSxoAHDFlrvMkNetBcKE79+7VJ8f1zF7QpwCK ll8dK7K9xC1/8dnh2fSEZxJdW6Wi73+EMsI5JCCm9yad0xzlL2rqmO5OANqWD/IJ7iTS +E9pFZscirc+awEkMv/0GAQCDgrbkGV0gDEF2mDg3J8ytsyuerXIaAvMaVz8AjJXB4jF OD0qzJXf8FpYkE2qIpjvEZ38QrfaBx/5/1eG/zMiFWyy8L4zZt6wigYNXmef8+lKApfh hbHjajz5Fa7/wujK5n1OCIADJFlMIj8x5PrIGyWVFMJx/dnXHvOp2RNVg/PV4wfPUXyd 1Rcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=WzOGm7J0dEwNfHMsGoOzZkTZZnsuYWKX5SsfUTlkf8Y=; b=SMsN8SF+VAFoXOhSIgcDTzK6nxbqaGQ6Af/PTRATZ6zMX2FIHdPtNWnmbtSGDDHTQj VV5qj2jxLiabpUShjUOIdECgQRYyLoxxtG99Fo7aYWNEZsHDwDu9vGRTDE0IyDAahGc7 /54FacQB83oaSjW+KSxIzmUrvk0cRN9N5tRlSreLzifEu5VIlgCgEWwzWv22Jjozondf mFV4wGHU2cIlL9dVfUxTmIM0gPMkb5SfXGibJorwE4FyMCVFRizj9XY+JU8QjqEckPaQ j2DLATKUyjIDlVi8Zl3P2pNuZ7EiylH12kq25mvVVJIqFXwDwBJodAqBi6oJEtOga+ti dd6Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u22-v6si2797555plk.608.2018.03.20.18.13.01; Tue, 20 Mar 2018 18:13:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752046AbeCUBLt (ORCPT + 99 others); Tue, 20 Mar 2018 21:11:49 -0400 Received: from mga09.intel.com ([134.134.136.24]:19664 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751996AbeCUBLg (ORCPT ); Tue, 20 Mar 2018 21:11:36 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Mar 2018 18:11:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,338,1517904000"; d="scan'208";a="39779443" Received: from vmm.bj.intel.com ([10.238.135.172]) by fmsmga001.fm.intel.com with ESMTP; 20 Mar 2018 18:11:33 -0700 From: Luwei Kang To: kvm@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, pbonzini@redhat.com, rkrcmar@redhat.com, linux-kernel@vger.kernel.org, joro@8bytes.org, Luwei Kang Subject: [PATCH v6 11/11] KVM: x86: Disable Intel Processor Trace when VMXON in L1 guest Date: Tue, 20 Mar 2018 19:21:58 +0800 Message-Id: <1521544918-31084-12-git-send-email-luwei.kang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521544918-31084-1-git-send-email-luwei.kang@intel.com> References: <1521544918-31084-1-git-send-email-luwei.kang@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- arch/x86/kvm/vmx.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 27185da..77a28f3 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -3763,7 +3763,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); pt_set_intercept_for_msr(vmx, !(data & RTIT_CTL_TRACEEN)); @@ -7869,6 +7870,12 @@ static int handle_vmon(struct kvm_vcpu *vcpu) if (ret) return ret; + if (pt_mode == PT_MODE_HOST_GUEST) { + vmx->pt_desc.guest.ctl = 0; + vmcs_write64(GUEST_IA32_RTIT_CTL, 0); + pt_set_intercept_for_msr(vmx, 1); + } + nested_vmx_succeed(vcpu); return kvm_skip_emulated_instruction(vcpu); } -- 1.8.3.1