Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Marc Zyngier" <maz@kernel.org>,
	kvmarm@lists.linux.dev, kvm@vger.kernel.org
Cc: "Oliver Upton" <oupton@kernel.org>
Subject: Re: [PATCH 1/3] KVM: arm64: Add enum support to idreg sanitisation
Date: Mon, 23 Nov 2026 19:34:55 +0000	[thread overview]
Message-ID: <sashiko-outbox-229945@kernel.org> (raw)
In-Reply-To: <20261123192457.8700-2-maz@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] KVM: arm64: oversized value in field_prep() in
  compute_idreg_field_deps()
--

commit db63f3732a88cac7f7573382f03761fa97deb813
Author: Marc Zyngier <maz@kernel.org>

KVM: arm64: Add enum support to idreg sanitisation

This commit extends the ID register dependency framework to evaluate nested
ordered enum feature descriptors and compute the corresponding RES0 and RES1
masks for ID register fields.

> diff --git a/arch/arm64/kvm/config.c b/arch/arm64/kvm/config.c
> index 6f668148ccc11..9763d021a5ecd 100644
> --- a/arch/arm64/kvm/config.c
> +++ b/arch/arm64/kvm/config.c

[ ... ]

> @@ -1557,6 +1571,27 @@ static const struct reg_feat_map_desc *idreg_feat_maps[] = {
>  	&id_aa64mmfr3_el1_desc,
>  };
>  
> +static struct resx compute_idreg_field_deps(struct kvm *kvm,
> +					    const struct reg_bits_to_feat_map *map)
> +{
> +	const struct reg_bits_to_feat_map *tmp;
> +	struct resx resx;
> +
> +	/*
> +	 * Assume the enum values are ordered in reverse order of
> +	 * capability (from most to least capable). A NULL callback
> +	 * value indicates the ultimate fallback (not implemented).
> +	 */
> +	for (tmp = map->idreg_field_deps; tmp->match; tmp++)
> +		if (tmp->match(kvm))
> +			break;
> +
> +	resx.res0 = field_prep(map->bits, ~(tmp->bits));
> +	resx.res1 = field_prep(map->bits, tmp->bits);
> +
> +	return resx;
> +}

[Severity: Low]
Can passing ~(tmp->bits) to field_prep() trigger a compile-time BUILD_BUG_ON
("field_prep: value too large for the field") if the compiler constant-folds
map->bits and tmp->bits?

tmp->bits is a 64-bit unsigned value holding an unshifted field value, so
~(tmp->bits) always has upper bits set outside the field width, which
violates __BF_FIELD_CHECK_MASK() in __FIELD_PREP().  Computing resx.res1
first and deriving resx.res0 as map->bits & ~resx.res1 avoids passing an
out-of-range value to field_prep().

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261123192457.8700-1-maz@kernel.org?part=1

  reply	other threads:[~2026-11-23 19:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 19:24 [PATCH 0/3] KVM: arm64: Convert GIC idreg sanitisation to the confic framework Marc Zyngier
2026-11-23 19:24 ` [PATCH 1/3] KVM: arm64: Add enum support to idreg sanitisation Marc Zyngier
2026-11-23 19:34   ` sashiko-bot [this message]
2026-11-23 19:24 ` [PATCH 2/3] KVM: arm64: Add GIC idregs sanitisation to common framework Marc Zyngier
2026-11-23 19:24 ` [PATCH 3/3] KVM: arm64: Drop open-coded GIC idreg sanitisation Marc Zyngier

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=sashiko-outbox-229945@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kvm@vger.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