Re: [PATCH v2 07/16] KVM: x86/pmu: Expose kvm_host_pmu to vendor modules

From: Mi, Dapeng

Date: Mon Aug 31 2026 - 23:13:42 EST


Reviewed-by: Dapeng Mi <dapeng1.mi@xxxxxxxxxxxxxxx>

On 8/28/2026 6:37 AM, Zide Chen wrote:
> kvm_host_pmu holds the unadulterated host PMU capabilities, which
> can be used to compare against guest capabilities to determine whether
> certain MSRs should be intercepted by KVM.
>
> Exposing it directly avoids the need to introduce per-field accessors,
> which would add boilerplate without hiding any implementation detail
> worth encapsulating.
>
> Opportunistically, fix typo "Unadultered" in the comment.
>
> Signed-off-by: Zide Chen <zide.chen@xxxxxxxxx>
> ---
> arch/x86/kvm/pmu.c | 5 +++--
> arch/x86/kvm/pmu.h | 1 +
> 2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c
> index b0fcd0a538d2..7837e2e1af98 100644
> --- a/arch/x86/kvm/pmu.c
> +++ b/arch/x86/kvm/pmu.c
> @@ -27,8 +27,9 @@
> /* This is enough to filter the vast majority of currently defined events. */
> #define KVM_PMU_EVENT_FILTER_MAX_EVENTS 300
>
> -/* Unadultered PMU capabilities of the host, i.e. of hardware. */
> -static struct x86_pmu_capability __read_mostly kvm_host_pmu;
> +/* Unadulterated PMU capabilities of the host, i.e. of hardware. */
> +struct x86_pmu_capability __read_mostly kvm_host_pmu;
> +EXPORT_SYMBOL_FOR_KVM_INTERNAL(kvm_host_pmu);
>
> /* KVM's PMU capabilities, i.e. the intersection of KVM and hardware support. */
> struct x86_pmu_capability __read_mostly kvm_pmu_cap;
> diff --git a/arch/x86/kvm/pmu.h b/arch/x86/kvm/pmu.h
> index b7a319b1eccc..9a658ae5b268 100644
> --- a/arch/x86/kvm/pmu.h
> +++ b/arch/x86/kvm/pmu.h
> @@ -252,6 +252,7 @@ static inline bool pmc_is_locally_enabled(struct kvm_pmc *pmc)
> return !kvm_pmu_call(pmc_is_disabled_in_current_mode)(pmc);
> }
>
> +extern struct x86_pmu_capability kvm_host_pmu;
> extern struct x86_pmu_capability kvm_pmu_cap;
>
> void kvm_init_pmu_capability(struct kvm_pmu_ops *pmu_ops);