summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColton Lewis <coltonlewis@google.com>2026-09-30 21:18:34 +0000
committerMarc Zyngier <maz@kernel.org>2026-10-03 13:11:42 +0100
commit517cdec3d4b28ccf5dae2dd03dee2a0a1eef1981 (patch)
treee3a67dc0b87d6c1e97b5c3ab4691801cf3426efb
parentaa41a7c3beb59f9dac4e60c9cf1d146f6c9025c4 (diff)
KVM: arm64: Check ID_AA64DFR0_EL1.PMUVer in pmu_visibility()
pmu_visibility() currently checks kvm_vcpu_has_pmu(), which only tests whether the vCPU was initialized with KVM_ARM_VCPU_PMU_V3. If userspace initializes a vCPU with KVM_ARM_VCPU_PMU_V3 and subsequently hides FEAT_PMUv3 via ID_AA64DFR0_EL1.PMUVer, KVM continues to expose the PMU system registers instead of emulating guest accesses as UNDEF. Check ID_AA64DFR0_EL1.PMUVer directly via kvm_has_feat() in pmu_visibility() so that PMU system registers are marked REG_HIDDEN whenever FEAT_PMUv3 is not advertised in the ID registers. Suggested-by: Oliver Upton <oupton@kernel.org> Assisted-by: LLM Signed-off-by: Colton Lewis <coltonlewis@google.com> Link: https://patch.msgid.link/20260930211834.2773546-3-coltonlewis@google.com Signed-off-by: Marc Zyngier <maz@kernel.org>
-rw-r--r--arch/arm64/kvm/sys_regs.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
index 87f96c9bd2fe..8315a188676f 100644
--- a/arch/arm64/kvm/sys_regs.c
+++ b/arch/arm64/kvm/sys_regs.c
@@ -1028,7 +1028,7 @@ static unsigned int hidden_visibility(const struct kvm_vcpu *vcpu,
static unsigned int pmu_visibility(const struct kvm_vcpu *vcpu,
const struct sys_reg_desc *r)
{
- if (kvm_vcpu_has_pmu(vcpu))
+ if (kvm_has_feat(vcpu->kvm, ID_AA64DFR0_EL1, PMUVer, IMP))
return 0;
return REG_HIDDEN;