Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1036158imm; Mon, 21 May 2018 20:00:06 -0700 (PDT) X-Google-Smtp-Source: AB8JxZphqbk9GtHf6HNDFqE8Ma8Ik4FeVsrCUDciwjeaKRZgdlHWwA75UEoRmCwtRGHf3XljjasZ X-Received: by 2002:a17:902:b184:: with SMTP id s4-v6mr22372007plr.359.1526958006086; Mon, 21 May 2018 20:00:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526958006; cv=none; d=google.com; s=arc-20160816; b=MmoeSYyXgzDdLHzTlZbMbJMOIgypxcd5m1f5jnLnFsMKnq3FGRf5dzr6rzPx6ZoR2m Jn7Fk+gkdwRreuX6T1yQI6U20F9d+QJ8l4dWYVme5tDTOt1RcQ+1bFCZpuuuPFd/cNlB BC5nq4A9CbxpM4N3sBPf+v6Hya6YKHNZj99v8PsMOg7chl9VMmiJ1gPXYeyuZqy45ggI oYdPPvjrYaSCpa/E84d0FkfUf0kH0J7ibjqCkxUCXo/LsHvXOBfe1nwHJ/gF2WZJiIAF r7cX0QztWc24ojJ2Fts899iT/09y0H6edCaDa2DzLoJy1M16T9slK4Zo7hs5Paw18Ed2 XxQQ== 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=y6+i6hFmRUqgyqqvY4H8T9wqFc2lR0fn+Qr+478c33Q=; b=ncywRDRRw0VUK5WbrOcuXghmJLsVm3OoTJKXr+OJwZBFaa1629aBmix93knv/LQdzM exl0wgPnNziTtjhwmI6BBFHTnbfaERvku37kB8zxPZJSoqM6ABtGrwb2RxvmYhn5Jojn 5eS/iQUz24ya8ISYQ+fnrtB+f1aaU2xZD7/owSXSs38T10Q+0IMFEV1MgVqYAlvzXzuZ VjrVyk2ZzamhVyAhL2n20ZwNtuiHyS7tLVNDD2cu1wOXHtRz9dKB56e5CMudbXqe3KVr j9OfYXvAdU4v523XHPzQcNF0NacZMgNT1lAo9DifjTzgYx2oUIZz8cc8Z1cHyAsHaNbZ 7pUw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 205-v6si8796361pgf.604.2018.05.21.19.59.51; Mon, 21 May 2018 20:00:06 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752850AbeEVC7I (ORCPT + 99 others); Mon, 21 May 2018 22:59:08 -0400 Received: from mga02.intel.com ([134.134.136.20]:36591 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752791AbeEVC7B (ORCPT ); Mon, 21 May 2018 22:59:01 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 May 2018 19:59:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,428,1520924400"; d="scan'208";a="201336075" Received: from skx-d.bj.intel.com ([10.238.154.68]) by orsmga004.jf.intel.com with ESMTP; 21 May 2018 19:58:56 -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 v9 12/12] KVM: x86: Disable Intel Processor Trace when VMXON in L1 guest Date: Tue, 22 May 2018 12:52:15 +0800 Message-Id: <1526964735-16566-13-git-send-email-luwei.kang@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1526964735-16566-1-git-send-email-luwei.kang@intel.com> References: <1526964735-16566-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 a09157c..093c1f7 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -3997,7 +3997,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)); @@ -8090,6 +8091,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