From: sashiko-bot@kernel.org
To: "Mark Brown" <broonie@kernel.org>
Cc: kvmarm@lists.linux.dev, "Marc Zyngier" <maz@kernel.org>,
"Oliver Upton" <oupton@kernel.org>
Subject: Re: [PATCH v2 1/2] KVM: arm64: Finalize guest-wide sysregs prior to per-vCPU sysregs
Date: Mon, 03 Aug 2026 23:12:00 +0000 [thread overview]
Message-ID: <20260803231200.D62F81F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260803-kvm-arm64-idreg-final-v2-1-d7d7e4efc640@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Numeric range comparison over sparse `enum vcpu_sysreg` covers unintended registers.
--
--- Patch [1]: [PATCH v2 1/2] KVM: arm64: Finalize guest-wide sysregs prior to per-vCPU sysregs ---
commit d51df44c26211dddcc71c5fe7798bb6cbbc7e67e
Author: Mark Brown <broonie@kernel.org>
KVM: arm64: Finalize guest-wide sysregs prior to per-vCPU sysregs
This commit splits the sysreg initialization into a per-VM and a per-vCPU
function to ensure that guest-wide settings are finalized before per-vCPU
NV initialization runs.
> diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
> index 5d5c579d45790..958d7ef78785f 100644
> --- a/arch/arm64/kvm/sys_regs.c
> +++ b/arch/arm64/kvm/sys_regs.c
[ ... ]
> @@ -5825,6 +5814,29 @@ int kvm_finalize_sys_regs(struct kvm_vcpu *vcpu)
[ ... ]
> +int kvm_vcpu_finalize_sys_regs(struct kvm_vcpu *vcpu)
> +{
[ ... ]
> + if (vcpu_has_nv(vcpu)) {
> + ret = kvm_init_nv_sysregs(vcpu);
[Severity: High]
This isn't a bug introduced by this patch, but does the initialization in
kvm_init_nv_sysregs() touch unintended registers by iterating over the
sparse vcpu_sysreg enumeration?
Looking at the loop at the end of kvm_init_nv_sysregs() in
arch/arm64/kvm/nested.c:
for (enum vcpu_sysreg sr = __SANITISED_REG_START__; sr < NR_SYS_REGS; sr++)
__vcpu_rmw_sys_reg(vcpu, sr, |=, 0);
Because VNCR-mapped entries are numbered by their VNCR-page byte offset
rather than declaration order, iterating using a numeric range comparison
over the enum covers unassigned gaps and other registers that happen to fall
in that byte span.
Could this loop inadvertently corrupt or desync guest state by treating
offsets as sequential enum entries?
> + if (ret)
> + return ret;
> + }
> +
> + return 0;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260803-kvm-arm64-idreg-final-v2-0-d7d7e4efc640@kernel.org?part=1
next prev parent reply other threads:[~2026-08-03 23:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-03 22:53 [PATCH v2 0/2] KVM: arm64: ID register finalisation fixes Mark Brown
2026-08-03 22:53 ` [PATCH v2 1/2] KVM: arm64: Finalize guest-wide sysregs prior to per-vCPU sysregs Mark Brown
2026-08-03 23:12 ` sashiko-bot [this message]
2026-08-04 8:01 ` Fuad Tabba
2026-08-03 22:53 ` [PATCH v2 2/2] KVM: arm64: Block ID register changes after we rely on the values Mark Brown
2026-08-04 9:30 ` [PATCH v2 0/2] KVM: arm64: ID register finalisation fixes Fuad Tabba
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=20260803231200.D62F81F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=broonie@kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=maz@kernel.org \
--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.