Received: by 10.192.165.148 with SMTP id m20csp1659559imm; Thu, 3 May 2018 03:20:32 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoxWL1K+BeSQBbL7+/FfQl1HqxDg4ZzxDh5NRI3o/KTVL8HlSf6+kTjndgXn3R4Ym3IAB/A X-Received: by 2002:a17:902:28ab:: with SMTP id f40-v6mr23369714plb.208.1525342832131; Thu, 03 May 2018 03:20:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525342832; cv=none; d=google.com; s=arc-20160816; b=RrtYgZB+B7lXhjb3IRcKSQwlFz83kCHD5asw6CRigYLFiw9K8ehU2lczmJSq0NF6JH yZhR1S9ngEDl747eVuUymHoK3XmWBrHExwmHN4IFowQvZAjo8XNpgJyXq5pTo/LeOR/2 4TpGWwLhUUpYdJs3qwND78Y4ytHtZ+F4UrIgmw8hi10fazUctYa0yFrvvA4lAkqnn5WB UwRspZBPMGGVoPpok5x3tsDvv9o48gZJ+xm1Iw8n0ZXbKTjNN2TOjO4JDLUEO8p3wafd Qq3nRewaP+9gODrnP+qOsk8wbLna12o72JzKhWDiWSbpHuhIUn35fi45wa3rAM37X7/A kzzw== 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=0H/7h+ErJiwGM0Ryde/yqDcHr2eZA7j2iX4Homv8GU4qLM4z1jq4TGRWBQTzYoW/cH eJFrWKK7UdHlh7+IRNuaW2oPKqCPKiZjE+p4jBb2yGdnry/g/sG3UOXCrLlk4WyTpKqf +1nCPbq/LoKMwFtGmwzbZRlHZWM1VwCskXOmT3ZrtCRQ0ntufolagbYdb6H6IRRfmib0 VMIwCuCg0atHoJ2zas1GQl/Tm/b5h+44bWmF48giX6lZ+Qlqhba1QRxo9O0bDyM6HlL6 6mCZDwjokn7varX8IdUWocE7po+gdMzZQdpwWcmGk4vBP6RxrxYIE7e8L6EnOxdhKmRg U9dw== 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 z23-v6si11698087plo.492.2018.05.03.03.20.18; Thu, 03 May 2018 03:20: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 S1752371AbeECKT7 (ORCPT + 99 others); Thu, 3 May 2018 06:19:59 -0400 Received: from mga06.intel.com ([134.134.136.31]:65515 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752339AbeECKTk (ORCPT ); Thu, 3 May 2018 06:19:40 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 May 2018 03:19:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,358,1520924400"; d="scan'208";a="36546585" Received: from unknown (HELO skx-d.bj.intel.com) ([10.238.154.68]) by fmsmga007.fm.intel.com with ESMTP; 03 May 2018 03:19:36 -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:13:28 +0800 Message-Id: <1525349608-10352-14-git-send-email-luwei.kang@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1525349608-10352-1-git-send-email-luwei.kang@intel.com> References: <1525349608-10352-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