[PATCH v2] KVM: arm64: Preserve GPRs for AArch32 CP64 reads generating an UNDEF
Marc Zyngier
maz at kernel.org
Sun Aug 2 23:32:29 PDT 2026
On Sun, 02 Aug 2026 19:22:22 +0100,
Karl Mehltretter <kmehltretter at gmail.com> wrote:
>
> kvm_handle_cp_64() only seeds params.regval for writes. If a CP64 read is
> decoded but UNDEFs, emulate_cp() still returns handled and the caller
> writes params.regval back to Rt/Rt2.
>
> This can happen for PMU counter read accesses generating an UNDEF. KVM
> injects the exception into the guest, so the MRRC GPRs must remain
> unchanged.
>
> Instead, the uninitialised regval is copied into the guest GPRs. With stack
> auto-initialisation this is a deterministic zero or pattern value. With
> CONFIG_INIT_STACK_NONE it may be stale host stack data.
>
> Match kvm_handle_cp_32() and kvm_handle_sys_reg() by seeding regval from
> the GPRs before emulation.
>
> Fixes: 62a89c44954f0 ("arm64: KVM: 32bit handling of coprocessor traps")
> Assisted-by: Claude:claude-opus-5
> Signed-off-by: Karl Mehltretter <kmehltretter at gmail.com>
Reviewed-by: Marc Zyngier <maz at kernel.org>
M.
--
Without deviation from the norm, progress is not possible.
More information about the linux-arm-kernel
mailing list