Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2298337imj; Mon, 18 Feb 2019 03:39:23 -0800 (PST) X-Google-Smtp-Source: AHgI3IY8owdBeBS+VjH56D902X7iax2pXRrW+q648kgW3V0ZaTUgE8Klhq4fkrv41OJsL5/5FThf X-Received: by 2002:a17:902:b082:: with SMTP id p2mr21719197plr.299.1550489963600; Mon, 18 Feb 2019 03:39:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550489963; cv=none; d=google.com; s=arc-20160816; b=K19yjaMPC8jEorKInL+LnL7cCKb51CQ2eKRYMuiDdCEX4R5YROUe5Mjyh7VjZog+l8 XObCwkpAytdtz3ECFrMmTHIr9RUzn+XmlReLgy7aQAkPZKOKTSx4DmMOBkXaVhxo5MGR FliJ1TauswTL/3AdHKF3u1M7gEjLrbMCJ6aRVVmo7WQaF8Gz7VBhI1fbNAyXXrGThSiV UTuYPhJ1I/zpfKwUQKV6jrBcGjtlQOKt4b3T19ZVJShQ96FReIyHrFTL7PEbNn0QXlar BXn3acBIqiVmjwmCLTpcFnDQmn79qx717VZyPoabTP6VQQUG0EvT4d4JWZrvzaEAYSzH WHPg== 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=XuytEDQhRkFjIgW4N2ZVUVD5yv0SgReyPomPe4XdA3E=; b=F0LXkhj3uE3Q5waZLArJ/t/72ARYOI/zENahGu06mfS+HuFNfWGfAJP9KyT/soVUqV toua/Jwms1nEupaTSbWpV6F2BQtjOASwrDoJmL3MgvECvgGUUmPvrlsrQEKnclzdEpj0 WtcKo/lHlanwh0S3/VcGhk4qVFqM70OCQi1lq6DXsVN8YHf9P99X9LxWoPOA79j1U5g/ CT4EL0q8GwG0bn2btfQFoJCflJc6kUqCQoFk4nwkxaLDuG1ap9mKMhiBw7cAGQFgFPNC 4rHxloiugitgrnFZnbi2smOPaeKS+NhHDNhOIPgjH9y0Pi4gH/fwDpTpAKYUIDsnD9pe TW3A== 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 i2si13216852pgl.153.2019.02.18.03.39.08; Mon, 18 Feb 2019 03:39:23 -0800 (PST) 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 S1730707AbfBRL1D (ORCPT + 99 others); Mon, 18 Feb 2019 06:27:03 -0500 Received: from mga09.intel.com ([134.134.136.24]:4212 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728905AbfBRL1A (ORCPT ); Mon, 18 Feb 2019 06:27:00 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Feb 2019 03:27:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,384,1544515200"; d="scan'208";a="275885445" Received: from vmm.bj.intel.com ([10.240.192.123]) by orsmga004.jf.intel.com with ESMTP; 18 Feb 2019 03:26:55 -0800 From: Luwei Kang To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, x86@kernel.org, pbonzini@redhat.com, rkrcmar@redhat.com, peterz@infradead.org, acme@kernel.org, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org, kan.liang@linux.intel.com, ak@linux.intel.com, konrad.wilk@oracle.com, Janakarajan.Natarajan@amd.com, mattst88@gmail.com, tim.c.chen@linux.intel.com, Luwei Kang Subject: [PATCH v2 2/2] KVM: x86: Add support of clear Trace_ToPA_PMI status Date: Mon, 18 Feb 2019 19:26:08 -0500 Message-Id: <1550535968-7652-3-git-send-email-luwei.kang@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1550535968-7652-1-git-send-email-luwei.kang@intel.com> References: <1550535968-7652-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 Add support of clear Intel PT ToPA PMI status for KVM guest. Signed-off-by: Luwei Kang --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/include/asm/msr-index.h | 4 ++++ arch/x86/kvm/vmx/pmu_intel.c | 8 +++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 4660ce9..de95704 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -468,6 +468,7 @@ struct kvm_pmu { u64 global_ovf_ctrl; u64 counter_bitmask[2]; u64 global_ctrl_mask; + u64 global_ovf_ctrl_mask; u64 reserved_bits; u8 version; struct kvm_pmc gp_counters[INTEL_PMC_MAX_GENERIC]; diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h index ae01fb0..c0ea4aa 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -778,6 +778,10 @@ /* PERF_GLOBAL_OVF_CTL bits */ #define MSR_CORE_PERF_GLOBAL_OVF_CTRL_TRACE_TOPA_PMI_BIT 55 #define MSR_CORE_PERF_GLOBAL_OVF_CTRL_TRACE_TOPA_PMI (1ULL << MSR_CORE_PERF_GLOBAL_OVF_CTRL_TRACE_TOPA_PMI_BIT) +#define MSR_CORE_PERF_GLOBAL_OVF_CTRL_OVF_BUF_BIT 62 +#define MSR_CORE_PERF_GLOBAL_OVF_CTRL_OVF_BUF (1ULL << MSR_CORE_PERF_GLOBAL_OVF_CTRL_OVF_BUF_BIT) +#define MSR_CORE_PERF_GLOBAL_OVF_CTRL_COND_CHGD_BIT 63 +#define MSR_CORE_PERF_GLOBAL_OVF_CTRL_COND_CHGD (1ULL << MSR_CORE_PERF_GLOBAL_OVF_CTRL_COND_CHGD_BIT) /* Geode defined MSRs */ #define MSR_GEODE_BUSCONT_CONF0 0x00001900 diff --git a/arch/x86/kvm/vmx/pmu_intel.c b/arch/x86/kvm/vmx/pmu_intel.c index 5ab4a36..6dee7cf 100644 --- a/arch/x86/kvm/vmx/pmu_intel.c +++ b/arch/x86/kvm/vmx/pmu_intel.c @@ -227,7 +227,7 @@ static int intel_pmu_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) } break; case MSR_CORE_PERF_GLOBAL_OVF_CTRL: - if (!(data & (pmu->global_ctrl_mask & ~(3ull<<62)))) { + if (!(data & pmu->global_ovf_ctrl_mask)) { if (!msr_info->host_initiated) pmu->global_status &= ~data; pmu->global_ovf_ctrl = data; @@ -297,6 +297,12 @@ static void intel_pmu_refresh(struct kvm_vcpu *vcpu) pmu->global_ctrl = ((1ull << pmu->nr_arch_gp_counters) - 1) | (((1ull << pmu->nr_arch_fixed_counters) - 1) << INTEL_PMC_IDX_FIXED); pmu->global_ctrl_mask = ~pmu->global_ctrl; + pmu->global_ovf_ctrl_mask = ~(pmu->global_ctrl | + MSR_CORE_PERF_GLOBAL_OVF_CTRL_OVF_BUF | + MSR_CORE_PERF_GLOBAL_OVF_CTRL_COND_CHGD); + if (kvm_x86_ops->pt_supported()) + pmu->global_ovf_ctrl_mask &= + ~MSR_CORE_PERF_GLOBAL_OVF_CTRL_TRACE_TOPA_PMI; entry = kvm_find_cpuid_entry(vcpu, 7, 0); if (entry && -- 1.8.3.1