From: sashiko-bot@kernel.org
To: "Mark Brown" <broonie@kernel.org>
Cc: kvmarm@lists.linux.dev, "Oliver Upton" <oupton@kernel.org>,
"Marc Zyngier" <maz@kernel.org>
Subject: Re: [PATCH v3 1/3] KVM: arm64: Finalize guest-wide sysregs prior to per-vCPU sysregs
Date: Tue, 01 Sep 2026 18:43:08 +0000 [thread overview]
Message-ID: <20260901184309.74C9C1F00ACA@smtp.kernel.org> (raw)
In-Reply-To: <20260901-kvm-arm64-idreg-final-v3-1-a0ffa06fa872@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Iterating over `enum vcpu_sysreg` using a numeric range (`< NR_SYS_REGS`) treats the enum as a dense array, touching unintended unallocated gaps because VNCR-mapped entries have sparse numbering based on their byte offsets.
--
commit 54e02ec9a7efd1b5c5a028a29a9441e4c02c5f90
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 guest-wide phase and a
per-vCPU phase. It runs the guest-wide setup earlier to prevent mismatches
between ID registers updated by vGIC finalization and the per-vCPU NV
register sanitization.
> diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
> --- a/arch/arm64/kvm/sys_regs.c
> +++ b/arch/arm64/kvm/sys_regs.c
[ ... ]
> +/*
> + * Because this can be called once per CPU, changes must be idempotent.
> + */
> +int kvm_vcpu_finalize_sys_regs(struct kvm_vcpu *vcpu)
> +{
> + struct kvm *kvm = vcpu->kvm;
> + int ret;
> +
> + guard(mutex)(&kvm->arch.config_lock);
> +
> + ret = kvm_vm_finalize_sys_regs(kvm);
> + if (ret)
> + return ret;
> +
> + if (vcpu_has_nv(vcpu)) {
> + ret = kvm_init_nv_sysregs(vcpu);
[Severity: High]
This isn't a bug introduced by this patch, but this is a pre-existing
issue in the kvm_init_nv_sysregs() function called here.
Does this loop in arch/arm64/kvm/nested.c:kvm_init_nv_sysregs() drop
guest state?
for (enum vcpu_sysreg sr = __SANITISED_REG_START__; sr < NR_SYS_REGS; sr++)
__vcpu_rmw_sys_reg(vcpu, sr, |=, 0);
The enum vcpu_sysreg maps VNCR entries using sparse byte offsets rather
than sequential integers. Iterating over it with a numeric range
comparison (< NR_SYS_REGS) covers unallocated gaps, which can silently
drop guest state and desynchronize the host's GET/SET_ONE_REG view when
a VM is configured with nested virtualization.
Could this loop be replaced with an explicit per-register allowlist?
> + if (ret)
> + return ret;
> + }
> +
> + return 0;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260901-kvm-arm64-idreg-final-v3-0-a0ffa06fa872@kernel.org?part=1
next prev parent reply other threads:[~2026-09-01 18:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 18:18 [PATCH v3 0/3] KVM: arm64: ID register finalisation fixes Mark Brown
2026-09-01 18:18 ` [PATCH v3 1/3] KVM: arm64: Finalize guest-wide sysregs prior to per-vCPU sysregs Mark Brown
2026-09-01 18:43 ` sashiko-bot [this message]
2026-09-01 18:18 ` [PATCH v3 2/3] KVM: arm64: Block ID register changes after we rely on the values Mark Brown
2026-09-01 18:18 ` [PATCH v3 3/3] KVM: arm64: selftests: Check ID regs are immutable after a failed run Mark Brown
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=20260901184309.74C9C1F00ACA@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).