Re: [PATCH v2 1/7] KVM: x86: Export kvm_pmu_is_valid_msr() for nVMX
From: Sean Christopherson
Date: Wed Dec 08 2021 - 12:55:47 EST
This is doing more than exporting a function, the export isn't even the focal
point of the patch.
On Mon, Nov 08, 2021, Like Xu wrote:
> From: Like Xu <likexu@xxxxxxxxxxx>
>
> Let's export kvm_pmu_is_valid_msr() for nVMX, instead of
Please wrap at ~75 chars.
> exporting all kvm_pmu_ops for this one case.
kvm_pmu_ops doesn't exist as of this patch, it comes later in the series.
> The reduced access scope will help to optimize the kvm_x86_ops.pmu_ops stuff
> later.
The changelog needs to explain why it's ok to add the msr_idx_to_pmc() check.
Something like:
KVM: nVMX: Use kvm_pmu_is_valid_msr() to check for PERF_GLOBAL_CTRL support
Use the generic kvm_pmu_is_valid_msr() helper when determining whether or not
PERF_GLOBAL_CTRL is exposed to the guest and thus can be loaded on nested
VM-Enter/VM-Exit. The extra (indirect!) call to msr_idx_to_pmc() that comes
with the helper is unnecessary, but harmless, as it's guaranteed to return
false for MSR_CORE_PERF_GLOBAL_CTRL and this is a already a very slow path.
Using the helper will allow future code to use static_call() for the PMU ops
without having to export any static_call definitions.
Export kvm_pmu_is_valid_msr() as necessary.
All that said, looking at this whole thing again, I think I'd prefer: