Received: by 10.192.165.148 with SMTP id m20csp1656135imm; Thu, 3 May 2018 03:16:38 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpCAoFJmmspS1+t+V/Cy6DKbtNX4FtF/lspgIhxU/eacXhqq7y6J7NtwRdk2As09gYUy4Y8 X-Received: by 2002:a17:902:228:: with SMTP id 37-v6mr23090819plc.141.1525342598099; Thu, 03 May 2018 03:16:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525342598; cv=none; d=google.com; s=arc-20160816; b=Dc+wuAqatbHj88ZfqkN4o/s/cY10+3bWbt/how66W/pxKkUmE5QdPKVjVHYsPr+i6k mBhdsWlk+7/1OoPSIob3m0ql0d/CbQbGm4qlBbKHg/6s9pqN+t/7Vie/WDFZO4gIz+GK pcpwGQRBHKUyGFPCrkp/Nc7P//iWhwAkVLK3fVT8atto3P2rfiw1Sf+ch4O7R8Q3jy7c tmPB4E/VPqhJWfmsTlwGWJZS3qjzHAfNKzGGe4V+8MCW7CP7tIYbjGfPetq9Pqz3a0Ed jdlFRakmJ599lCky9mlETAVEBwim7kQKivPaylPg9cBJJZXpRKRvBbCyjdVCZjUGRsyq 03eA== 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=fbraLZLP0zVNwFUzuqHJBTXvEGPFTOuQy6f+1JP1jwE=; b=LFB9ek1+bWoHcBhVJ2GaH1POxzUEhJ4QyVZ+RvYgapPOdi11zZv0wCqhm1OoCrrJ18 O9gvNU3N2EDN8sK4d7ZIrjjelITOSL+J3A4DTwdmtT7VfgfTAi6zmxFM/sTuQpQ5M5pq n1ebOuArXb7GQxjAuT75jRts4++NepgGnjvqtPmb0ZUVBg5YsOIH50wqCGdCcZSP/Nq+ /UaljxTaoO86Y1bS+xK6NPo5OuPgPRUyRi9Cvq6QzIl3hfld8zFV1qHzRjfC5SmIDZT5 eJ5P7VcDmO6aU/OOouLr3yxikC4f7VHqrUNQpnI2xAZ/Nf2YFP2OHVrk9rgwZwOLxMzR FDjg== 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 z4-v6si11015784pgs.508.2018.05.03.03.16.23; Thu, 03 May 2018 03:16:38 -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 S1752190AbeECKPh (ORCPT + 99 others); Thu, 3 May 2018 06:15:37 -0400 Received: from mga03.intel.com ([134.134.136.65]:44408 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752161AbeECKP1 (ORCPT ); Thu, 3 May 2018 06:15:27 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 May 2018 03:15:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,358,1520924400"; d="scan'208";a="38109909" Received: from unknown (HELO skx-d.bj.intel.com) ([10.238.154.68]) by orsmga007.jf.intel.com with ESMTP; 03 May 2018 03:15:24 -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, peterz@infradead.org, chao.p.peng@linux.intel.com, Luwei Kang Subject: [PATCH v7 13/13] KVM: x86: Disable Intel Processor Trace when VMXON in L1 guest Date: Thu, 3 May 2018 20:08:43 +0800 Message-Id: <1525349323-9938-14-git-send-email-luwei.kang@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1525349323-9938-1-git-send-email-luwei.kang@intel.com> References: <1525349323-9938-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 c125fb1..1e800d0 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -3952,7 +3952,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)); @@ -8029,6 +8030,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