From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B13E23009CB for ; Mon, 15 Dec 2025 13:58:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765807122; cv=none; b=oGWelFJTD42KsdNenjt825pOp3Mftxp+GfzX39rgNCNgHlH48LRgcMwOZZavu60CEE1yT4U53Wf1yE3nd0/R37kmhvwYlhkWC6zmJHeiB2tzxMXH+uuLPw6Cg4DFgTNrr47lhUodNXqIrLCjTW/VO8V7EIMl8vr0OCRs8g9j4kA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765807122; c=relaxed/simple; bh=Vf7zzfbdgRtZPUqHyBBRLu76rSNg6wAlAZK53fZzzFg=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=rvRKwegXrLFZ/wA0Hkxe3nw4r4/fa2MTAGfyPQp0XpAF8L6whwmEUzf/KviYs7qKQFob3G1L6i3pZoxsTTZ+mJQWwpzeDK1w5s6npkA3AJ4aEJG2eZNn1Olv8RopQvjNsadu+yBTjfiIWNmr6XahdAS+PuKClfWEQXRIqqKJeto= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cnbLA2cw; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cnbLA2cw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89DE6C19422; Mon, 15 Dec 2025 13:58:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1765807122; bh=Vf7zzfbdgRtZPUqHyBBRLu76rSNg6wAlAZK53fZzzFg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=cnbLA2cwn8H3e2IBVbpalCppTh31oS4ZiC8fAiVQTPlsu9X4xkBuHNZVQXZADAq4Y geMSuM4BtA6v3ooxtHahHPamDBOe/sdvw+GRwF6Tizy6rVwR+EQ0s+LXlZs2u+SjfO OyEnoPSby3qTEe1DJlkx7zvnGml0u8j4tlejuLzOh1ERUHPFNMAcK/wfMbm/G4Cvrt QMlp9PY1kUpCeIuwh8hOsR0ylxavOgJT7nZEpTgRFtQ5mWIE4Y6oT3kw3XjU5sz85H q7E4fd4AXfuNqZaQZsPjKfUkoE2zFQHuvKTsZ5FAAerJ1FUzajU5PsY1DzKfGyHsQx PIPEzB24Ar9cQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vV960-0000000CmOD-2TH6; Mon, 15 Dec 2025 13:58:40 +0000 Date: Mon, 15 Dec 2025 13:58:40 +0000 Message-ID: <86ike7onhr.wl-maz@kernel.org> From: Marc Zyngier To: Alexandru Elisei Cc: oupton@kernel.org, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, qperret@google.com, will@kernel.org, tabba@google.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev Subject: Re: [PATCH v2 2/4] KVM: arm64: Print register encoding if there's no accessor In-Reply-To: <20251215114409.212512-3-alexandru.elisei@arm.com> References: <20251215114409.212512-1-alexandru.elisei@arm.com> <20251215114409.212512-3-alexandru.elisei@arm.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: alexandru.elisei@arm.com, oupton@kernel.org, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, qperret@google.com, will@kernel.org, tabba@google.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Mon, 15 Dec 2025 11:44:07 +0000, Alexandru Elisei 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 > --- > 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.