From: "Mi, Dapeng" <dapeng1.mi@linux.intel.com>
To: Zide Chen <zide.chen@intel.com>,
Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Peter Zijlstra <peterz@infradead.org>
Cc: kvm@vger.kernel.org, Jim Mattson <jmattson@google.com>,
Yosry Ahmed <yosry@kernel.org>, Andi Kleen <ak@linux.intel.com>,
Stephane Eranian <eranian@google.com>,
linux-kernel@vger.kernel.org, Mingwei Zhang <mizhang@google.com>,
Das Sandipan <Sandipan.Das@amd.com>,
Shukla Manali <Manali.Shukla@amd.com>,
Xudong Hao <xudong.hao@intel.com>
Subject: Re: [PATCH v10 07/18] KVM: x86/pmu: Query perf-reported capabilities instead of RDMSR
Date: Tue, 1 Dec 2026 14:07:06 +0800 [thread overview]
Message-ID: <f600e3fe-07d1-4450-8480-cf5e91bb0e94@linux.intel.com> (raw)
In-Reply-To: <20261124213901.120572-8-zide.chen@intel.com>
Reviewed-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
On 11/25/2026 5:38 AM, Zide Chen wrote:
> KVM reads MSR_IA32_PERF_CAPABILITIES directly, which bypasses the
> errata workarounds (e.g. RPL018) and sanitizing that perf applies to
> the value.
>
> Use the capabilities reported by perf instead. This also avoids
> reading the MSR twice during VMX PMU initialization.
>
> Signed-off-by: Zide Chen <zide.chen@intel.com>
> ---
> v10:
> - Re-purposed the patch "Snapshot host IA32_PERF_CAPABILITIES"
> to simple references update.
> ---
> arch/x86/kvm/vmx/pmu_intel.c | 7 +------
> arch/x86/kvm/vmx/vmx.c | 8 ++------
> 2 files changed, 3 insertions(+), 12 deletions(-)
>
> diff --git a/arch/x86/kvm/vmx/pmu_intel.c b/arch/x86/kvm/vmx/pmu_intel.c
> index 8f72a405e737..f916048b9c54 100644
> --- a/arch/x86/kvm/vmx/pmu_intel.c
> +++ b/arch/x86/kvm/vmx/pmu_intel.c
> @@ -775,16 +775,11 @@ void intel_pmu_cross_mapped_check(struct kvm_pmu *pmu)
>
> static bool intel_pmu_is_mediated_pmu_supported(struct x86_pmu_capability *host_pmu)
> {
> - u64 host_perf_cap = 0;
> -
> - if (boot_cpu_has(X86_FEATURE_PDCM))
> - rdmsrq(MSR_IA32_PERF_CAPABILITIES, host_perf_cap);
> -
> /*
> * Require v4+ for MSR_CORE_PERF_GLOBAL_STATUS_SET, and full-width
> * writes so that KVM can precisely load guest counter values.
> */
> - if (host_pmu->version < 4 || !(host_perf_cap & PERF_CAP_FW_WRITES))
> + if (host_pmu->version < 4 || !(host_pmu->perf_capabilities & PERF_CAP_FW_WRITES))
> return false;
>
> /*
> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> index b341af4c6057..f04f2d3884d9 100644
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -7889,14 +7889,10 @@ void vmx_vcpu_after_set_cpuid(struct kvm_vcpu *vcpu)
> static __init u64 vmx_get_perf_capabilities(void)
> {
> u64 perf_cap = PERF_CAP_FW_WRITES;
> - u64 host_perf_cap = 0;
>
> if (!enable_pmu)
> return 0;
>
> - if (boot_cpu_has(X86_FEATURE_PDCM))
> - rdmsrq(MSR_IA32_PERF_CAPABILITIES, host_perf_cap);
> -
> if (!cpu_feature_enabled(X86_FEATURE_ARCH_LBR) &&
> !enable_mediated_pmu) {
> x86_perf_get_lbr(&vmx_lbr_caps);
> @@ -7909,11 +7905,11 @@ static __init u64 vmx_get_perf_capabilities(void)
> if (!vmx_lbr_caps.has_callstack)
> memset(&vmx_lbr_caps, 0, sizeof(vmx_lbr_caps));
> else if (vmx_lbr_caps.nr)
> - perf_cap |= host_perf_cap & PERF_CAP_LBR_FMT;
> + perf_cap |= kvm_pmu_cap.perf_capabilities & PERF_CAP_LBR_FMT;
> }
>
> if (vmx_pebs_supported()) {
> - perf_cap |= host_perf_cap & PERF_CAP_PEBS_MASK;
> + perf_cap |= kvm_pmu_cap.perf_capabilities & PERF_CAP_PEBS_MASK;
>
> /*
> * Disallow adaptive PEBS as it is functionally broken, can be
next prev parent reply other threads:[~2026-12-01 6:07 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 21:38 [PATCH v10 00/18] KVM: x86/pmu: Add hardware Topdown metrics support Zide Chen
2026-11-24 21:38 ` [PATCH v10 01/18] perf/x86: Add INTEL_TD_METRIC_FIELD_{BITS,MASK} constants Zide Chen
2026-12-01 5:39 ` Mi, Dapeng
2026-11-24 21:38 ` [PATCH v10 02/18] perf/x86/intel: Do not inflate capabilities for guests Zide Chen
2026-12-01 5:43 ` Mi, Dapeng
2026-11-24 21:38 ` [PATCH v10 03/18] perf/x86/intel: Track common hybrid capabilities Zide Chen
2026-12-01 6:01 ` Mi, Dapeng
2026-11-24 21:38 ` [PATCH v10 04/18] perf/x86: Expose perf_capabilities to KVM Zide Chen
2026-12-01 6:03 ` Mi, Dapeng
2026-11-24 21:38 ` [PATCH v10 05/18] perf/x86: Expose number of Topdown metric events " Zide Chen
2026-11-24 21:38 ` [PATCH v10 06/18] KVM: x86/pmu: Do not map fixed counters >= 3 to generic perf events Zide Chen
2026-11-24 21:38 ` [PATCH v10 07/18] KVM: x86/pmu: Query perf-reported capabilities instead of RDMSR Zide Chen
2026-12-01 6:07 ` Mi, Dapeng [this message]
2026-11-24 21:38 ` [PATCH v10 08/18] KVM: x86/pmu: Rename and move vcpu_get_perf_capabilities() to pmu.h Zide Chen
2026-11-24 21:38 ` [PATCH v10 09/18] KVM: x86/pmu: Mask only OS/USR bits when filtering fixed counters Zide Chen
2026-12-01 6:15 ` Mi, Dapeng
2026-11-24 21:38 ` [PATCH v10 10/18] KVM: x86/pmu: Block PMU passthrough if guest lacks PERF_METRICS Zide Chen
2026-11-24 21:38 ` [PATCH v10 11/18] KVM: x86/pmu: Support Intel fixed counter 3 on mediated vPMU Zide Chen
2026-11-24 21:38 ` [PATCH v10 12/18] KVM: x86/pmu: Move RDPMC emulation into per-vendor callbacks Zide Chen
2026-11-24 21:38 ` [PATCH v10 13/18] KVM: x86/pmu: Emulate RDPMC on performance metrics Zide Chen
2026-11-24 21:38 ` [PATCH v10 14/18] KVM: x86/pmu: Support PERF_METRICS MSR in mediated vPMU Zide Chen
2026-11-24 21:38 ` [PATCH v10 15/18] KVM: x86/pmu: Support RDPMC Metrics Clear Mode Zide Chen
2026-11-24 21:38 ` [PATCH v10 16/18] KVM: selftests: Rework PMU guest measurement asm operands Zide Chen
2026-11-24 21:39 ` [PATCH v10 17/18] KVM: selftests: Move and generalize PMU guest measurement helpers Zide Chen
2026-11-24 21:39 ` [PATCH v10 18/18] KVM: selftests: Add Topdown PERF_METRICS test Zide Chen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f600e3fe-07d1-4450-8480-cf5e91bb0e94@linux.intel.com \
--to=dapeng1.mi@linux.intel.com \
--cc=Manali.Shukla@amd.com \
--cc=Sandipan.Das@amd.com \
--cc=ak@linux.intel.com \
--cc=eranian@google.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mizhang@google.com \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=seanjc@google.com \
--cc=xudong.hao@intel.com \
--cc=yosry@kernel.org \
--cc=zide.chen@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox