Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4338367imu; Mon, 28 Jan 2019 23:09:06 -0800 (PST) X-Google-Smtp-Source: ALg8bN4hZqYesFy4w9js2i1EscyEQxgYBMrOAyCE+rg7es7jWb3xJ5jvDhnCHuoNpBVdDu57sgNt X-Received: by 2002:a17:902:968d:: with SMTP id n13mr25366785plp.109.1548745746083; Mon, 28 Jan 2019 23:09:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548745746; cv=none; d=google.com; s=arc-20160816; b=lDpid6CQ8uwUec3FWRGbERylUyGqQ3/5W5GR54CEIlHJLhW167V1wHNsZWpAxr7iU5 6VB/ozMnmELOAJNp+iEG7EolUWs7wZYL/hBzM/6OAjWmIo0xccVzbx89nJgop1XFsSyK 7vgRtq9tBAwSiLTzVQrazWxpkWVRKNXEY7Scdo1cq6atIPBXh2ZwN/e4FXRkHUfIdZ+1 5aqpuwIU2A0qu0Y/n0boJgicdnW0nnmB54/9/uMl8Gc5fJUdMtGhj5ErAPPrW/vV+JjQ tlF1ljoKk3GQELkEYfpyJK0Elij49P3Y95D7zkXkZ+KNu0yGiO42qxb0ZPZ/e8GYXafG tEmA== 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=qxdkDj/0RODsWTjxJO7h0+jbXoYMCs1m/uTsseT+bRzAb7K78LM/5Rsuz3FxYbo1Ag d1CHFRi14lAPcDyKw0GsPlqVV5oq77R8/mM6v/fvwJRiKaUvY19VBqu/+iZK1NVQyU+7 sY3GAdg2+YkARQsiXZP7B9k9mGBOvkD3dqamns57sjxXI7APtx3iqUW8cWq7M07hwYFk muw/wwTAelerCOagFHU1OOmOQjuePFAV3AD6x8IoV4Fv94EzGgBCKjpDo10+Gway5tmp fBj1fiFVuM7LB8KkLTlZYBH3fiigW9JhyhcGDw5OvT8Wvd6od9qCVRRapd+e0/3Ixucu OkOw== 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 e129si34181208pgc.333.2019.01.28.23.08.50; Mon, 28 Jan 2019 23:09:06 -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 S1726925AbfA2HGn (ORCPT + 99 others); Tue, 29 Jan 2019 02:06:43 -0500 Received: from mga09.intel.com ([134.134.136.24]:37998 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725764AbfA2HGm (ORCPT ); Tue, 29 Jan 2019 02:06:42 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Jan 2019 23:06:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,536,1539673200"; d="scan'208";a="129738132" Received: from vmm.bj.intel.com ([10.240.192.123]) by orsmga002.jf.intel.com with ESMTP; 28 Jan 2019 23:06:38 -0800 From: Luwei Kang To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, x86@kernel.org, songliubraving@fb.com, pbonzini@redhat.com, rkrcmar@redhat.com, peterz@infradead.org, zsm@chromium.org, alexander.shishkin@linux.intel.com, konrad.wilk@oracle.com, ak@linux.intel.com, Luwei Kang Subject: [PATCH 3/3] KVM: x86: Add support of clear Trace_ToPA_PMI status Date: Sat, 19 Jan 2019 15:04:44 -0500 Message-Id: <1547928284-2915-4-git-send-email-luwei.kang@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1547928284-2915-1-git-send-email-luwei.kang@intel.com> References: <1547928284-2915-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