Received: by 10.223.185.116 with SMTP id b49csp2081317wrg; Sun, 4 Mar 2018 17:59:14 -0800 (PST) X-Google-Smtp-Source: AG47ELvArXJ4NwNi6D2aBHWp9jVNmUlnkdP93fVaMVRH3v3lHr+SeoRtiDqqh43UGK7CsG7nnVsC X-Received: by 10.98.17.86 with SMTP id z83mr13643154pfi.207.1520215154532; Sun, 04 Mar 2018 17:59:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520215154; cv=none; d=google.com; s=arc-20160816; b=yAtEi++Tl8ff0xu5SgqRuT7CNv3WiVoemS0RbJuIr6KQ+Cc/aMOOzo3PUV7jNCsngp +LXLcCQDLEOYy3WjbPaNvwUcsx031uQGl7EA4gKcC8yiAgkj5YaByZB+/JTk/1brgEco KjLWRDCp2FYJhbOrAazB8kLZnQrKuGNppVntXBk5w+ttXHvxSboRBqg0isnwgO1f1vWW LUBQ41xKVNRW1GOlMvpfTxL/QqVSWdmjlV4wIx+tDLnsy2XgcFkvADArXYsgs+1sPij/ ejB0fYLmrLqo4lgm09m5ZepJ2bWYcfMASO4Al8MLJLvVwVmsLOP1vYyiL2IMKRQzv1V8 SZOQ== 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=k6VAarf0h0fgIZzi+ktp3Tese7G2F3aqHWsHzwmuGa4=; b=r+tDq1wZ1XAfj3/Qa4jzWHiN9+GNJqrGJ2G0yriCh6aZkKeoqwgeFFeEgpXy0wCnQP pgSowP12KkiL6Pv4KvqFC+gEvHqVNwfO2eJdj6FphzQ6j52ZMNor/8Dlss/PIAfDbL3k EIn4V9bJ7Q4wpK6NaFwhF7TeP9OTySrYWGQXE6udKGXdtRy09wO4CkRh1MsW37YyB797 Ms+SzgxZlxqm3kDOMSeCiEB4ZxhDHE6cPBYEkDAkunTvHZqCXMM5Pmk1iDbioXCNNwck dVVZKZkA8Ph0VyVQLxf06ZMpcMZfiP0k4JtsFCB/Fp7il7JNc0WnadVVp8urAzlENr0S zZ6Q== 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 h190si7722878pgc.178.2018.03.04.17.59.00; Sun, 04 Mar 2018 17:59:14 -0800 (PST) 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 S1752396AbeCEB54 (ORCPT + 99 others); Sun, 4 Mar 2018 20:57:56 -0500 Received: from mga14.intel.com ([192.55.52.115]:39574 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932653AbeCEB5W (ORCPT ); Sun, 4 Mar 2018 20:57:22 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Mar 2018 17:57:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,425,1515484800"; d="scan'208";a="21986126" Received: from vmm.bj.intel.com ([10.238.135.172]) by fmsmga008.fm.intel.com with ESMTP; 04 Mar 2018 17:57:19 -0800 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 v5 11/11] KVM: x86: Disable Intel Processor Trace when VMXON in L1 guest Date: Sun, 4 Mar 2018 20:07:21 +0800 Message-Id: <1520165241-15819-12-git-send-email-luwei.kang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520165241-15819-1-git-send-email-luwei.kang@intel.com> References: <1520165241-15819-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 0a55772..a1ec71d 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -3710,7 +3710,8 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) clear_atomic_switch_msr(vmx, MSR_IA32_XSS); break; case MSR_IA32_RTIT_CTL: - if (!vmx_pt_supported() || vmx_rtit_ctl_check(vcpu, data)) + if (!vmx_pt_supported() || vmx_rtit_ctl_check(vcpu, data) || + vmx->nested.vmxon) return 1; vmcs_write64(GUEST_IA32_RTIT_CTL, data); vmx->pt_desc.guest.ctl = data; @@ -7783,6 +7784,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