Message ID | 20230808063111.1870070-14-dapeng1.mi@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2325142vqr; Tue, 8 Aug 2023 11:48:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE2FkSBB+gPXOt66bQGXYXqmx/swOXTPx/XKHh354k5519WQ14NYggljJPmQ7MiPID4h7XW X-Received: by 2002:a17:903:22c8:b0:1bc:15ea:ced8 with SMTP id y8-20020a17090322c800b001bc15eaced8mr580381plg.54.1691520480831; Tue, 08 Aug 2023 11:48:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691520480; cv=none; d=google.com; s=arc-20160816; b=ynWQ4mnFjiagNeUBpLlvoUBvhVLPggiaotdJYSmL2+PXXM/n1WsBxfNm+nuNER6O+T clevl08wrxmtE43FOQR0F+7S3pRhmI3EzXvzDTFFDupXHdYQGWrcJJQpyGBeRAwoXa8V RR3Edb/Rg6oZ5Ag3J4I+cVghG/XzO6WYDYokCtNBR86tSGLNKKf99XdOMOviwvS5Y1MS /0wN7cavkhCA7d1V+e+fpU2BsXiqNKnpe5biKF8XZ8u3516XsFAMaQtpkexqFI1eJb+D aM3rsnJK9Yw0BfhJzXFDFIckOugDuDkSVyjA3sLI9/S8t3tB6uh0QpKcKyqP+XTKSHLK BOCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UM3j+o8rNx2WdWgfvAUDOeQUR0XIoADBGZr/FaHqejg=; fh=UPwqiesAqvJCK7JcrgEpVEdaX86ysnZ9K1cUIusTBBs=; b=KBM7KQxicPiDvy0/jVYJNee2v9pOyYVk/LFcCg4pGfwL9rSPbmyAPc9yDOAaaHvQvh wqKpmqZzbqwUZ2Dukk5Nytuvc2uw8ujGOTKnVr7YYT/cWpYzZH2iZl2QEMIBF+IR5wrd QtFkWXjzEOFKmEkR4sN9pKQaZDWZRwlX99kSt2KaS9nv6sT2WCm/xicdiRCtdNODokHD xrn640FV0bU6IlZ6cO4N/wUarMdTIYEh8bkUmYqjHFHfRILnSYpxF/H7GynSQ0b6q0wl 7FBIs+gZkmaJa7F5vEv6EazRATuCBXzUl/YwR3Orj1ELpj8h5kEba47rUfu/2e8dz7MU E6/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hmczZNzO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e12-20020a6558cc000000b0055adfd70273si5476496pgu.538.2023.08.08.11.47.48; Tue, 08 Aug 2023 11:48:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hmczZNzO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235612AbjHHSVq (ORCPT <rfc822;aaronkmseo@gmail.com> + 99 others); Tue, 8 Aug 2023 14:21:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235641AbjHHSVS (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 8 Aug 2023 14:21:18 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93AD53AB5; Tue, 8 Aug 2023 10:31:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691515904; x=1723051904; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HN6umFzIzizJH0eHFuu9gWTiK+dcpuqVvLuFCdBvuNY=; b=hmczZNzOJrZIr1qoAE7flUiWwLYM9c3r+oPDonAOFt+60N0t5YWPOUxD gRMztg3sWj8RherjblshK/kDD2leb2sBcYf805Tk6LX3oLf+6l0APHago uydtZrsJWrMYoY2z5ggv5h8AUDGtE1yB0e0wWAfFPvsxAFfdIYQrT7fVB aV1cbegVnEXgywMf+KegqepMJP0W5kO4rHqpzdvPi2yOUUb4Id6C09e3+ WtbbWqRAwDeQ4Neww1kizwMvhgN2qFKELFWj/XS9X8MEJoznV8HcW4Bqt wAhLKBLWiwHvFgd1TAdusoSV1+zC+Hkj6t7MUSRKSkEe/MTTmLiIIM+r5 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10795"; a="434582224" X-IronPort-AV: E=Sophos;i="6.01,263,1684825200"; d="scan'208";a="434582224" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2023 23:27:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10795"; a="734377961" X-IronPort-AV: E=Sophos;i="6.01,263,1684825200"; d="scan'208";a="734377961" Received: from dmi-pnp-i7.sh.intel.com ([10.239.159.155]) by fmsmga007.fm.intel.com with ESMTP; 07 Aug 2023 23:27:53 -0700 From: Dapeng Mi <dapeng1.mi@linux.intel.com> To: Sean Christopherson <seanjc@google.com>, Paolo Bonzini <pbonzini@redhat.com>, Peter Zijlstra <peterz@infradead.org>, Arnaldo Carvalho de Melo <acme@kernel.org>, Kan Liang <kan.liang@linux.intel.com>, Like Xu <likexu@tencent.com>, Mark Rutland <mark.rutland@arm.com>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>, Ian Rogers <irogers@google.com>, Adrian Hunter <adrian.hunter@intel.com> Cc: kvm@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Zhenyu Wang <zhenyuw@linux.intel.com>, Zhang Xiong <xiong.y.zhang@intel.com>, Lv Zhiyuan <zhiyuan.lv@intel.com>, Yang Weijiang <weijiang.yang@intel.com>, Dapeng Mi <dapeng1.mi@intel.com>, Dapeng Mi <dapeng1.mi@linux.intel.com> Subject: [PATCH RFV v2 13/13] KVM: x86/pmu: Expose Topdown in MSR_IA32_PERF_CAPABILITIES Date: Tue, 8 Aug 2023 14:31:11 +0800 Message-Id: <20230808063111.1870070-14-dapeng1.mi@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230808063111.1870070-1-dapeng1.mi@linux.intel.com> References: <20230808063111.1870070-1-dapeng1.mi@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773687779799046539 X-GMAIL-MSGID: 1773687779799046539 |
Series |
Enable fixed counter 3 and topdown perf metrics for vPMU
|
|
Commit Message
Mi, Dapeng
Aug. 8, 2023, 6:31 a.m. UTC
Topdown support is enumerated via IA32_PERF_CAPABILITIES[bit 15]. Enable this bit for guest when the feature is available on host. Co-developed-by: Yang Weijiang <weijiang.yang@intel.com> Signed-off-by: Yang Weijiang <weijiang.yang@intel.com> Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com> --- arch/x86/kvm/vmx/pmu_intel.c | 3 +++ arch/x86/kvm/vmx/vmx.c | 2 ++ 2 files changed, 5 insertions(+)
diff --git a/arch/x86/kvm/vmx/pmu_intel.c b/arch/x86/kvm/vmx/pmu_intel.c index d4870e92c9d3..39afc79b0981 100644 --- a/arch/x86/kvm/vmx/pmu_intel.c +++ b/arch/x86/kvm/vmx/pmu_intel.c @@ -614,6 +614,9 @@ static void intel_pmu_refresh(struct kvm_vcpu *vcpu) (((1ull << pmu->nr_arch_fixed_counters) - 1) << INTEL_PMC_IDX_FIXED)); pmu->global_ctrl_mask = counter_mask; + if (intel_pmu_metrics_is_enabled(vcpu)) + pmu->global_ctrl_mask &= ~(1ULL << GLOBAL_CTRL_EN_PERF_METRICS); + /* * GLOBAL_STATUS and GLOBAL_OVF_CONTROL (a.k.a. GLOBAL_STATUS_RESET) * share reserved bit definitions. The kernel just happens to use diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 8cf1c00d9352..f9a8509f4ca8 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -7831,6 +7831,8 @@ static u64 vmx_get_perf_capabilities(void) perf_cap &= ~PERF_CAP_PEBS_BASELINE; } + perf_cap |= host_perf_cap & PMU_CAP_PERF_METRICS; + return perf_cap; }