[PATCH v2 2/4] KVM: arm64: Print register encoding if there's no accessor

Marc Zyngier maz at kernel.org
Mon Dec 15 05:58:40 PST 2025


On Mon, 15 Dec 2025 11:44:07 +0000,
Alexandru Elisei <alexandru.elisei at arm.com> wrote:
> 
> Configuring a register trap without specifying an accessor function is
> abviously a bug. Instead of calling die() when that happens, let's be a bit
> more helpful and print the register encoding and kill the virtual machine
> instead.
> 
> Signed-off-by: Alexandru Elisei <alexandru.elisei at arm.com>
> ---
>  arch/arm64/kvm/sys_regs.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
> index c8fd7c6a12a1..d669f6fef177 100644
> --- a/arch/arm64/kvm/sys_regs.c
> +++ b/arch/arm64/kvm/sys_regs.c
> @@ -4668,7 +4668,13 @@ static void perform_access(struct kvm_vcpu *vcpu,
>  	 * that we don't know how to handle. This certainly qualifies
>  	 * as a gross bug that should be fixed right away.
>  	 */
> -	BUG_ON(!r->access);
> +	if (!r->access) {
> +		KVM_BUG(1, vcpu->kvm,
> +			"Unexpected access to register: { Op0(%2u), Op1(%2u), CRn(%2u), CRm(%2u), Op2(%2u) } (%s)",
> +			params->Op0, params->Op1, params->CRn, params->CRm, params->Op2,
> +			str_write_read(params->is_write));
> +		return;
> +	}

Why not writing

	if (KVM_BUG(!r>access, ...))
		return;

instead? And you could reuse the format that's already defined in
print_sys_reg_msg().

You could instead consider injecting an UNDEF in the guest, which I
find more palatable than this "vm_bugged" stuff. It would at least be
consistent with the "register does not exist in the sysreg table"
approach that we already have.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.



More information about the linux-arm-kernel mailing list