Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4072772imm; Mon, 14 May 2018 02:05:32 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqQYxU3j+OJm00SD1miDedMk4uf0b+rZcXgcGEL/zaGpREusTPjO9uCQeAtbwnKPTvc6sTL X-Received: by 2002:a63:90c4:: with SMTP id a187-v6mr7738829pge.189.1526288732139; Mon, 14 May 2018 02:05:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526288732; cv=none; d=google.com; s=arc-20160816; b=ZwlkBxOHIcSRCtvqj7ZEtRBs9lAlOM0ZIXd9UjzojBOxuSu6ZIzVd/mVjfq5lYJfCV R8XriiuoaaL/udhua6c8h+lB7RTOc3KGARCg6mfqQS5S3qA+Chj3T7GnOSBa+c9QZcce 4MRUI3iCzPeYWNHvG5x8Q2VljYAnaXA/3XRCditiv0dZD33NGyrOaOQHAYj0/5RBdSkY QoMIghsJBYDbgPfWfMif+/sMTEFA5d+Nhih46cmDwfQxhdUnp88JWCY2/rQJJ0vryYKr VjSHIO1zrdyAyFg2wD50oet17yhrsBYNJDBtUHQkYi/juTXp1xd7EtY8Q4AaD/5Hz6hL 21IQ== 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=R4+wRut1Xg8c8aS+O6cnIQI8PthC3Jsa62XRQAoLc20=; b=PPY1I19iWtEq6+Neu2uqH5gsulNdukIPO6r1n+Q+8MXUfp/imAVZHp+E861FUS5YlG AuepmHannFWIMKpoIwfcJ9wO4mihn1RJ5k6gM19bz6SIJHz7ejYgT0wEK0sQ/HrwxeJ7 WUGQbtx0exKkxEqMxrZY9WPjkfVsqhFIUHI88K8O34IrElGl2R9Xt24YxSeKWDPGLfIl ekMnXEtpEtJd5rJWVWOXzSKJXW3EzfZ5IDqnGOBA4thvtkB6JKmbO4PSIG7DUQn6hcNn kZUoCg3Usj9JXNiIK7Khjeq5jC3hTTlMC0o5G0tt39k8q9BCqdInl6CAl3nIG+2QRRnF fa1g== 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 a98-v6si9085879pla.239.2018.05.14.02.05.17; Mon, 14 May 2018 02:05:32 -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 S1752696AbeENJEn (ORCPT + 99 others); Mon, 14 May 2018 05:04:43 -0400 Received: from mga07.intel.com ([134.134.136.100]:60897 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752109AbeENJDt (ORCPT ); Mon, 14 May 2018 05:03:49 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 May 2018 02:03:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,399,1520924400"; d="scan'208";a="39701991" Received: from skx-d.bj.intel.com ([10.238.154.68]) by fmsmga008.fm.intel.com with ESMTP; 14 May 2018 02:03:44 -0700 From: Luwei Kang To: kvm@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, chao.p.peng@linux.intel.com, thomas.lendacky@amd.com, bp@suse.de, Kan.liang@intel.com, Janakarajan.Natarajan@amd.com, dwmw@amazon.co.uk, linux-kernel@vger.kernel.org, alexander.shishkin@linux.intel.com, peterz@infradead.org, mathieu.poirier@linaro.org, kstewart@linuxfoundation.org, gregkh@linuxfoundation.org, pbonzini@redhat.com, rkrcmar@redhat.com, david@redhat.com, bsd@redhat.com, yu.c.zhang@linux.intel.com, joro@8bytes.org, Luwei Kang Subject: [PATCH v8 12/12] KVM: x86: Disable Intel Processor Trace when VMXON in L1 guest Date: Mon, 14 May 2018 18:57:12 +0800 Message-Id: <1526295432-20640-13-git-send-email-luwei.kang@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1526295432-20640-1-git-send-email-luwei.kang@intel.com> References: <1526295432-20640-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 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 170cd48..7ace11a 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -3996,7 +3996,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)); @@ -8089,6 +8090,11 @@ 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; + pt_set_intercept_for_msr(vmx, 1); + } + nested_vmx_succeed(vcpu); return kvm_skip_emulated_instruction(vcpu); } -- 1.8.3.1