[PATCH v7 08/20] KVM: arm64: Add Partitioned PMU register trap handlers
Colton Lewis
coltonlewis at google.com
Thu May 14 11:18:03 PDT 2026
Oliver Upton <oupton at kernel.org> writes:
> On Mon, May 04, 2026 at 09:18:01PM +0000, Colton Lewis wrote:
>> We may want a partitioned PMU but not have FEAT_FGT to untrap the
>> specific registers that would normally be untrapped. Add handling for
>> those trapped register accesses that does the right thing if the PMU
>> is partitioned.
>> For registers that shouldn't be written to hardware because they
>> require special handling (PMEVTYPER and PMOVS), write to the virtual
>> register. A later patch will ensure these are handled correctly at
>> vcpu_load time.
>> Signed-off-by: Colton Lewis <coltonlewis at google.com>
> I'd prefer an approach that provides a single accessor helper that takes
> a vcpu_sysreg enum as an argument and internally handles the dispatch
> between partitioned and emulated PMUs. That goes for all of the PMU
> sysregs.
That seems ugly to me. It'll need a giant switch or two to re-dispatch
to the correct sysreg handling when we were already dispatched courtesy
of the function we are in.
Are you thinking:
single_accessor(vcpu_sysreg)
{
if (is_partitioned) {
switch (vcpu_sysreg) {
...
}
return;
}
switch (vcpu_sysreg) {
...
}
}
or I could do the switch on the outside and duplicate the is_partitioned
check but that's the same as what happens now with extra steps.
> This will help you reuse some of the PMU emuation code that you'll still
> need for things like nested...
I'm not seeing what you mean. Could you explain further please?
> Thanks,
> Oliver
More information about the linux-arm-kernel
mailing list