Re: [PATCH 9/9] arm64: sysreg: Reject a bit position written with a leading zero
From: Steffen Eiden
Date: Mon Nov 23 2026 - 06:22:56 EST
On Mon, Nov 23, 2026 at 07:52:19AM +0000, Fuad Tabba wrote:
> parse_bitdef() reads a field's msb and lsb as decimal and checks the
> layout with them, but the generator copies the digits into GENMASK()
> unchanged, and C reads a leading zero as octal. "Field 63:010 A" is
> accepted as bits 63 to 10, with the next field starting at bit 9, while
> its mask is GENMASK(63, 010), bits 63 to 8, which overlaps that field.
>
> Require both ends of a bit range to be decimal numbers without a leading
> zero.
>
> Signed-off-by: Fuad Tabba <fuad.tabba@xxxxxxxxx>
> ---
> arch/arm64/tools/gen-sysreg.awk | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm64/tools/gen-sysreg.awk b/arch/arm64/tools/gen-sysreg.awk
> index 057dc98082b5e..01b463e271cef 100755
> --- a/arch/arm64/tools/gen-sysreg.awk
> +++ b/arch/arm64/tools/gen-sysreg.awk
> @@ -102,7 +102,8 @@ function parse_bitdef(reg, field, bitdef, _bits)
> fatal("invalid bit-range definition '" bitdef "'")
> }
>
> -
> + if (msb !~ /^(0|[1-9][0-9]*)$/ || lsb !~ /^(0|[1-9][0-9]*)$/)
> + fatal(reg "." field " invalid bit-range '" bitdef "'")
The test is good but IMO the error message should be more precise to
what you are actually checking. sth like:
fatal(reg "." field " non-decimal bit-range '" bitdef "'")
Steffen
> if (msb != next_bit)
> fatal(reg "." field " starts at " msb " not " next_bit)
> if (63 < msb || msb < 0)
> --
> 2.47.3
>