From: sashiko-bot@kernel.org
To: "Akihiko Odaki" <odaki@rsg.ci.i.u-tokyo.ac.jp>
Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org,
"Oliver Upton" <oupton@kernel.org>,
"Marc Zyngier" <maz@kernel.org>
Subject: Re: [PATCH v10 06/20] KVM: arm64: PMU: Preserve EL2 bitmap state during migration
Date: Mon, 14 Sep 2026 12:24:10 +0000 [thread overview]
Message-ID: <20260914122411.5A6E91F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260914-hybrid-v10-6-92788053a691@rsg.ci.i.u-tokyo.ac.jp>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Guest reads of PMU bitmap registers from EL1/EL0 fail to mask out EL2-reserved counters (HPMN), violating the architectural RAZ requirement and leaking EL2 PMU state.
--
commit 02155ef34a95aa6d00cf6402f40fbdccdad7a563
Author: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
KVM: arm64: PMU: Preserve EL2 bitmap state during migration
KVM_GET_ONE_REG and KVM_SET_ONE_REG transfer raw vCPU state for
migration. Masking PMU bitmap registers with counters accessible at the
current EL drops EL2-reserved bits when the vCPU is stopped in EL1 or
EL0.
Use the implemented counter mask for these userspace accesses so the
complete bitmap state survives migration. Guest register accesses
continue to use the accessible counter mask.
Closes: https://sashiko.dev/#/patchset/20260720-hybrid-v9-0-2b713ca1b5dc@rsg.ci.i.u-tokyo.ac.jp?part=5
> Use the implemented counter mask for these userspace accesses so the
> complete bitmap state survives migration. Guest register accesses
> continue to use the accessible counter mask.
[Severity: High]
This isn't a bug introduced by this patch, but do the guest register accesses
actually use the accessible counter mask for read paths?
When Nested Virtualization (NV) is active, an L1 hypervisor configures
MDCR_EL2.HPMN to reserve PMU counters for itself. If the L2 guest (running
at vEL1/vEL0) reads the PMU bitmap registers, it should read zero for these
reserved counters to satisfy architectural RAZ requirements.
However, looking at the read paths in arch/arm64/kvm/sys_regs.c, the raw state
is returned without applying the accessible counter mask:
arch/arm64/kvm/sys_regs.c:access_pmcnten() {
...
} else {
p->regval = __vcpu_sys_reg(vcpu, PMCNTENSET_EL0);
}
...
}
arch/arm64/kvm/sys_regs.c:access_pminten() {
...
} else {
p->regval = __vcpu_sys_reg(vcpu, PMINTENSET_EL1);
}
...
}
arch/arm64/kvm/sys_regs.c:access_pmovs() {
...
} else {
p->regval = __vcpu_sys_reg(vcpu, PMOVSSET_EL0);
}
...
}
Could this leak the L1 hypervisor's PMU configuration and overflow state
to the untrusted L2 guest?
> diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
> index 44aae52c473d7..42b6705bc21d1 100644
> --- a/arch/arm64/kvm/sys_regs.c
> +++ b/arch/arm64/kvm/sys_regs.c
> @@ -1326,7 +1326,7 @@ static bool access_pmu_evtyper(struct kvm_vcpu *vcpu, struct sys_reg_params *p,
>
> static int set_pmreg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r, u64 val)
> {
> - u64 mask = kvm_pmu_accessible_counter_mask(vcpu);
> + u64 mask = kvm_pmu_implemented_counter_mask(vcpu);
>
> __vcpu_assign_sys_reg(vcpu, r->reg, val & mask);
> kvm_make_request(KVM_REQ_RELOAD_PMU, vcpu);
> @@ -1336,7 +1336,7 @@ static int set_pmreg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r, u64 va
>
> static int get_pmreg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r, u64 *val)
> {
> - u64 mask = kvm_pmu_accessible_counter_mask(vcpu);
> + u64 mask = kvm_pmu_implemented_counter_mask(vcpu);
>
> *val = __vcpu_sys_reg(vcpu, r->reg) & mask;
> return 0;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260914-hybrid-v10-0-92788053a691@rsg.ci.i.u-tokyo.ac.jp?part=6
next prev parent reply other threads:[~2026-09-14 12:24 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-14 11:40 [PATCH v10 00/20] KVM: arm64: PMU: Use multiple host PMUs Akihiko Odaki
2026-09-14 11:40 ` [PATCH v10 01/20] KVM: arm64: Serialize repeated vCPU initialization Akihiko Odaki
2026-09-14 11:40 ` [PATCH v10 02/20] KVM: arm64: PMU: Stop updating MDCR_EL2.HPMN Akihiko Odaki
2026-09-14 11:40 ` [PATCH v10 03/20] KVM: arm64: PMU: Freeze counter count after first run Akihiko Odaki
2026-09-14 11:40 ` [PATCH v10 04/20] KVM: arm64: selftests: Test SET_NR_COUNTERS " Akihiko Odaki
2026-09-14 11:40 ` [PATCH v10 05/20] KVM: arm64: PMU: Keep implemented counter mask EL-independent Akihiko Odaki
2026-09-14 11:40 ` [PATCH v10 06/20] KVM: arm64: PMU: Preserve EL2 bitmap state during migration Akihiko Odaki
2026-09-14 12:24 ` sashiko-bot [this message]
2026-09-14 11:40 ` [PATCH v10 07/20] KVM: arm64: PMU: Recreate events after reset Akihiko Odaki
2026-09-14 12:14 ` sashiko-bot
2026-09-14 11:40 ` [PATCH v10 08/20] KVM: arm64: PMU: Recreate events after MDCR_EL2 changes Akihiko Odaki
2026-09-14 11:40 ` [PATCH v10 09/20] KVM: arm64: PMU: Recreate events after PMCR_EL0 changes Akihiko Odaki
2026-09-14 11:40 ` [PATCH v10 10/20] KVM: arm64: PMU: Recreate events after userspace event writes Akihiko Odaki
2026-09-14 11:40 ` [PATCH v10 11/20] tools headers: Use u* types for bitfield helpers Akihiko Odaki
2026-09-14 11:40 ` [PATCH v10 12/20] KVM: arm64: selftests: Cover PMU state in MDCR_EL2 Akihiko Odaki
2026-09-14 11:40 ` [PATCH v10 13/20] arm64: errata: Require Apple IMPDEF PMUv3 traps on all CPUs Akihiko Odaki
2026-09-14 11:40 ` [PATCH v10 14/20] KVM: arm64: Don't clear vcpu->cpu in kvm_arch_vcpu_put() Akihiko Odaki
2026-09-14 11:40 ` [PATCH v10 15/20] KVM: arm64: PMU: Protect the list of PMUs with RCU Akihiko Odaki
2026-09-14 11:40 ` [PATCH v10 16/20] KVM: arm64: PMU: Pass the pPMU to kvm_map_pmu_event() Akihiko Odaki
2026-09-14 11:40 ` [PATCH v10 17/20] KVM: arm64: PMU: Pass the target CPU to kvm_pmu_probe_armpmu() Akihiko Odaki
2026-09-14 11:40 ` [PATCH v10 18/20] KVM: arm64: PMU: Implement fixed-counters-only emulation Akihiko Odaki
2026-09-14 11:40 ` [PATCH v10 19/20] KVM: arm64: PMU: Introduce FIXED_COUNTERS_ONLY Akihiko Odaki
2026-09-14 11:40 ` [PATCH v10 20/20] KVM: arm64: selftests: Test PMU_V3_FIXED_COUNTERS_ONLY Akihiko Odaki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260914122411.5A6E91F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=maz@kernel.org \
--cc=odaki@rsg.ci.i.u-tokyo.ac.jp \
--cc=oupton@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.