Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp298257ima; Wed, 24 Oct 2018 01:10:42 -0700 (PDT) X-Google-Smtp-Source: AJdET5fxjEtUIVfCfTFpHHCnNlEJ/2AhZlwG0Ve1AQwr3nMHmoJgB0lzRVnUJTIQKiu2M3Z8FRGk X-Received: by 2002:a62:444f:: with SMTP id r76-v6mr1720857pfa.111.1540368642595; Wed, 24 Oct 2018 01:10:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540368642; cv=none; d=google.com; s=arc-20160816; b=ElhxqSWuunYVovA8V5ndobJmIVuIY0uZmVBV0e0WWMQFF78V2pdmAsTDX6V8eX+x9H lvzhcM2a52W7BJu45I5Tg5IHcCag+zD0Aw74ZAeifignxODWz/wBHyo8kYp96ZT/wPlg vCIG3t3pwOmoaHP+TU1DYgkINIjDCVtA4toBcboCrVo2r8IFUqr6VlZYxBwqp/2ilmsS KOToq1zMW6JlCc+VsUCTGlmcdwKZteRavj5Zo+VsODk8oZFC0oK3CNl06WM6vd1Eqob2 gWcPEPHLhyEFqXRSAIM0a2qgyv+jTwMVam28//wtS/iCv0+jCZUB6LEW3QCg0adl6mB5 nPZg== 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; bh=boviBc07/0uPVHr5T4UfSrmd/Q6KlPrIQGfUafU2JaA=; b=JJfhpAo3y2dVVJHRXeP9AQqYLEZ93Dkeqs9FSmdHZwoQUis49Xgtn1zg8hBF+xDTtu kuQiKkFgUzfjUAJw4WjxtzUBAQrCu902FlqmJZo6aMRU7lPhTMUZNIyN7D75oP1IX0DU weB9u7dNX2vd3ipPMnkqOe7xixGvwuZEkGI/4nJu2dt2ll1Ewcs8+yYwWq8siwQ9rMiS zWPF8UCHxiQLXrqyUlkaU4um34OwwPSA6a+SBz1eJOUqx3lUci9/EQrQWqrWC+kxzNFa pQeQeH7tpzrmwCaQZYBpOHgRhNk47kRY5514TkFnuI/S1NaI2KkJZR2zXa/HptNTfdJs KVxg== 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 61-v6si4020868plr.72.2018.10.24.01.10.27; Wed, 24 Oct 2018 01:10:42 -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 S1729698AbeJXQfS (ORCPT + 99 others); Wed, 24 Oct 2018 12:35:18 -0400 Received: from mga06.intel.com ([134.134.136.31]:43358 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729637AbeJXQfR (ORCPT ); Wed, 24 Oct 2018 12:35:17 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Oct 2018 01:08:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,419,1534834800"; d="scan'208";a="273987528" Received: from skx-d.bj.intel.com ([10.238.135.53]) by fmsmga005.fm.intel.com with ESMTP; 24 Oct 2018 01:08:09 -0700 From: Luwei Kang To: kvm@vger.kernel.org, x86@kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, pbonzini@redhat.com, rkrcmar@redhat.com, joro@8bytes.org, songliubraving@fb.com, peterz@infradead.org, alexander.shishkin@linux.intel.com, kstewart@linuxfoundation.org, gregkh@linuxfoundation.org, thomas.lendacky@amd.com, konrad.wilk@oracle.com, mattst88@gmail.com, Janakarajan.Natarajan@amd.com, dwmw@amazon.co.uk, jpoimboe@redhat.com, marcorr@google.com, ubizjak@gmail.com, sean.j.christopherson@intel.com, jmattson@google.com, linux-kernel@vger.kernel.org, Luwei Kang Subject: [PATCH v13 12/12] KVM: x86: Disable Intel PT when VMXON in L1 guest Date: Wed, 24 Oct 2018 16:05:16 +0800 Message-Id: <1540368316-12998-13-git-send-email-luwei.kang@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1540368316-12998-1-git-send-email-luwei.kang@intel.com> References: <1540368316-12998-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 ed247dd..5001049 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -4556,7 +4556,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)); @@ -8760,6 +8761,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); + } + return nested_vmx_succeed(vcpu); } -- 1.8.3.1