Re: [PATCH 2/8] KVM: x86/pmu: Add PMU ops for vendor state sync

[email protected]
Newsgroups org.kernel.vger.kvm
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The newly introduced PMU ops (get_vendor_state, set_vendor_state) are never invoked by KVM nor implemented by any vendor PMU, rendering them dead code.
--

--- Patch [2]: [PATCH 2/8] KVM: x86/pmu: Add PMU ops for vendor state sync ---
commit 2b7ba0292c6d4a2eb66eaca07b256dee5f7af75a
Author: Sandipan Das <[email protected]>

KVM: x86/pmu: Add PMU ops for vendor state sync

This commit introduces new PMU operations get_vendor_state and set_vendor_state
to KVM's PMU architecture to allow synchronizing guest PMU state with a vendor
save area. It updates the capabilities initialization to nullify these operations
if the mediated PMU is not enabled.

> diff --git a/arch/x86/kvm/pmu.h b/arch/x86/kvm/pmu.h
> index f60856c48462b..2b1a8d6433734 100644
> --- a/arch/x86/kvm/pmu.h
> +++ b/arch/x86/kvm/pmu.h
> @@ -42,6 +42,8 @@ struct kvm_pmu_ops {
>  	void (*mediated_load)(struct kvm_vcpu *vcpu);
>  	void (*mediated_put)(struct kvm_vcpu *vcpu);
>  	void (*write_global_ctrl)(u64 global_ctrl);
> +	int (*get_vendor_state)(struct kvm_vcpu *vcpu, u32 msr);
> +	int (*set_vendor_state)(struct kvm_vcpu *vcpu, u32 msr);

[Severity: Low]
Are these new PMU operations actually invoked anywhere in KVM or implemented by
any vendor PMU in this patch? It appears they might be dead code, as there are
no callers or vendor implementations (e.g., for AMD or Intel) provided, despite
the commit message mentioning opportunistically synchronizing the state.

>  
>  	const u64 EVENTSEL_EVENT;
>  	const int MAX_NR_GP_COUNTERS;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.