* [PATCH 1/9] arm64: sysreg: Map MPAM1_EL12 to MPAM1_EL1
[not found] <20261123075219.369042-1-fuad.tabba@linux.dev>
@ 2026-11-23 7:52 ` Fuad Tabba
2026-11-23 7:52 ` [PATCH 2/9] arm64: sysreg: Remove the dead range check from parse_bitdef() Fuad Tabba
` (4 subsequent siblings)
5 siblings, 0 replies; 6+ messages in thread
From: Fuad Tabba @ 2026-11-23 7:52 UTC (permalink / raw)
To: Catalin Marinas, Will Deacon
Cc: Mark Rutland, Marc Zyngier, Oliver Upton, Mark Brown,
Sascha Bischoff, Steffen Eiden, linux-arm-kernel, linux-kernel,
Fuad Tabba
MPAM1_EL12 is the EL12 alias of MPAM1_EL1, but its entry in the sysreg
file is "Fields MPAM1_ELx", and the file doesn't have an MPAM1_ELx
block. Since commit 6ae7fab7d9d33 ("arm64: sysreg: Emit RESx/UNKN values
for Mapping/Fields definitions"), the generator's MPAM1_EL12_RES0, _RES1
and _UNKN expand to MPAM1_ELx_RES0 and the like, which aren't defined.
They aren't used yet, but the first user would fail to build.
Describe the register as a mapping of MPAM1_EL1.
Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev>
---
arch/arm64/tools/sysreg | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm64/tools/sysreg b/arch/arm64/tools/sysreg
index 997c62ab72e68..ebe5c5bd6fef6 100644
--- a/arch/arm64/tools/sysreg
+++ b/arch/arm64/tools/sysreg
@@ -5501,7 +5501,7 @@ Field 63:0 ADDR
EndSysreg
Sysreg MPAM1_EL12 3 5 10 5 0
-Fields MPAM1_ELx
+Mapping MPAM1_EL1
EndSysreg
Sysreg CONTEXTIDR_EL12 3 5 13 0 1
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/9] arm64: sysreg: Remove the dead range check from parse_bitdef()
[not found] <20261123075219.369042-1-fuad.tabba@linux.dev>
2026-11-23 7:52 ` [PATCH 1/9] arm64: sysreg: Map MPAM1_EL12 to MPAM1_EL1 Fuad Tabba
@ 2026-11-23 7:52 ` Fuad Tabba
2026-11-23 7:52 ` [PATCH 3/9] arm64: sysreg: Reject a Sysreg and a SysregFields with the same name Fuad Tabba
` (3 subsequent siblings)
5 siblings, 0 replies; 6+ messages in thread
From: Fuad Tabba @ 2026-11-23 7:52 UTC (permalink / raw)
To: Catalin Marinas, Will Deacon
Cc: Mark Rutland, Marc Zyngier, Oliver Upton, Mark Brown,
Sascha Bischoff, Steffen Eiden, linux-arm-kernel, linux-kernel,
Fuad Tabba
parse_bitdef() ends by testing "low > high", but the script doesn't
assign either variable, so the test compares two empty values and never
fires. The "msb < lsb" test just above it already rejects an inverted
range.
Remove the dead test.
No functional change intended.
Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev>
---
arch/arm64/tools/gen-sysreg.awk | 2 --
1 file changed, 2 deletions(-)
diff --git a/arch/arm64/tools/gen-sysreg.awk b/arch/arm64/tools/gen-sysreg.awk
index 53844f5c5e525..b299342463631 100755
--- a/arch/arm64/tools/gen-sysreg.awk
+++ b/arch/arm64/tools/gen-sysreg.awk
@@ -100,8 +100,6 @@ function parse_bitdef(reg, field, bitdef, _bits)
fatal(reg "." field " invalid low bit in '" bitdef "'")
if (msb < lsb)
fatal(reg "." field " invalid bit-range '" bitdef "'")
- if (low > high)
- fatal(reg "." field " has invalid range " high "-" low)
next_bit = lsb - 1
}
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/9] arm64: sysreg: Reject a Sysreg and a SysregFields with the same name
[not found] <20261123075219.369042-1-fuad.tabba@linux.dev>
2026-11-23 7:52 ` [PATCH 1/9] arm64: sysreg: Map MPAM1_EL12 to MPAM1_EL1 Fuad Tabba
2026-11-23 7:52 ` [PATCH 2/9] arm64: sysreg: Remove the dead range check from parse_bitdef() Fuad Tabba
@ 2026-11-23 7:52 ` Fuad Tabba
2026-11-23 7:52 ` [PATCH 6/9] arm64: sysreg: Reject an enum value not written at its field's width Fuad Tabba
` (2 subsequent siblings)
5 siblings, 0 replies; 6+ messages in thread
From: Fuad Tabba @ 2026-11-23 7:52 UTC (permalink / raw)
To: Catalin Marinas, Will Deacon
Cc: Mark Rutland, Marc Zyngier, Oliver Upton, Mark Brown,
Sascha Bischoff, Steffen Eiden, linux-arm-kernel, linux-kernel,
Fuad Tabba
The generator rejects two Sysreg blocks, or two SysregFields blocks,
with the same name, but tracks the two kinds separately. Both kinds name
their macros for the block, so a Sysreg FOO and a SysregFields FOO that
each have a field A both define FOO_A, as well as FOO_RES0 and the other
masks, and the compiler warns only where the definitions differ.
Track both kinds of name in defined_regs, so that a block is rejected
when either kind already has its name, and leave the kind out of the
error.
Suggested-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev>
---
arch/arm64/tools/gen-sysreg.awk | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/arm64/tools/gen-sysreg.awk b/arch/arm64/tools/gen-sysreg.awk
index b299342463631..8ce4981273dd3 100755
--- a/arch/arm64/tools/gen-sysreg.awk
+++ b/arch/arm64/tools/gen-sysreg.awk
@@ -137,9 +137,9 @@ $1 == "SysregFields" && block_current() == "Root" {
res1 = "UL(0)"
unkn = "UL(0)"
- if (reg in defined_fields)
- fatal("Duplicate SysregFields definition for " reg)
- defined_fields[reg] = 1
+ if (reg in defined_regs)
+ fatal("Duplicate definition for " reg)
+ defined_regs[reg] = 1
next_bit = 63
@@ -181,7 +181,7 @@ $1 == "Sysreg" && block_current() == "Root" {
unkn = "UL(0)"
if (reg in defined_regs)
- fatal("Duplicate Sysreg definition for " reg)
+ fatal("Duplicate definition for " reg)
defined_regs[reg] = 1
define_reg("REG_" reg, "S" op0 "_" op1 "_C" crn "_C" crm "_" op2)
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 6/9] arm64: sysreg: Reject an enum value not written at its field's width
[not found] <20261123075219.369042-1-fuad.tabba@linux.dev>
` (2 preceding siblings ...)
2026-11-23 7:52 ` [PATCH 3/9] arm64: sysreg: Reject a Sysreg and a SysregFields with the same name Fuad Tabba
@ 2026-11-23 7:52 ` Fuad Tabba
2026-11-23 7:52 ` [PATCH 7/9] arm64: sysreg: Reject a macro name defined twice Fuad Tabba
2026-11-23 7:52 ` [PATCH 9/9] arm64: sysreg: Reject a bit position written with a leading zero Fuad Tabba
5 siblings, 0 replies; 6+ messages in thread
From: Fuad Tabba @ 2026-11-23 7:52 UTC (permalink / raw)
To: Catalin Marinas, Will Deacon
Cc: Mark Rutland, Marc Zyngier, Oliver Upton, Mark Brown,
Sascha Bischoff, Steffen Eiden, linux-arm-kernel, linux-kernel,
Fuad Tabba
The generator emits each enum value as written and doesn't check it
against the width of its field, so a value wider than the field defines
a constant the field can't hold. The duplicate value check compares the
strings as written, so 0b01 and 0b001 in the same field pass as distinct
values, and the rule's pattern, an unanchored /0b[01]+/, accepts 0b12
too.
Require each value to be 0b followed by exactly as many binary digits as
its field has bits. The one enum written otherwise is TS, a two-bit
field of TRFCR_EL1 and TRFCR_EL2 whose values have four digits. Write
them with two digits, which leaves the numbers unchanged.
Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev>
---
arch/arm64/tools/gen-sysreg.awk | 3 +++
arch/arm64/tools/sysreg | 14 +++++++-------
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/arch/arm64/tools/gen-sysreg.awk b/arch/arm64/tools/gen-sysreg.awk
index 1843d283192d2..cde526896ed96 100755
--- a/arch/arm64/tools/gen-sysreg.awk
+++ b/arch/arm64/tools/gen-sysreg.awk
@@ -367,6 +367,9 @@ $1 == "EndEnum" && block_current() == "Enum" {
val = $1
name = $2
+ if (val !~ /^0b[01]+$/ || length(val) - 2 != msb - lsb + 1)
+ fatal("Enum value " val " for " name " is not " (msb - lsb + 1) " binary digits")
+
if (val in seen_enum_vals)
fatal("Duplicate Enum value " val " for " name)
seen_enum_vals[val] = 1
diff --git a/arch/arm64/tools/sysreg b/arch/arm64/tools/sysreg
index ebe5c5bd6fef6..5b587a7544e40 100644
--- a/arch/arm64/tools/sysreg
+++ b/arch/arm64/tools/sysreg
@@ -2919,9 +2919,9 @@ EndSysreg
Sysreg TRFCR_EL1 3 0 1 2 1
Res0 63:7
UnsignedEnum 6:5 TS
- 0b0001 VIRTUAL
- 0b0010 GUEST_PHYSICAL
- 0b0011 PHYSICAL
+ 0b01 VIRTUAL
+ 0b10 GUEST_PHYSICAL
+ 0b11 PHYSICAL
EndEnum
Res0 4:2
Field 1 ExTRE
@@ -4300,10 +4300,10 @@ EndSysreg
Sysreg TRFCR_EL2 3 4 1 2 1
Res0 63:7
UnsignedEnum 6:5 TS
- 0b0000 USE_TRFCR_EL1_TS
- 0b0001 VIRTUAL
- 0b0010 GUEST_PHYSICAL
- 0b0011 PHYSICAL
+ 0b00 USE_TRFCR_EL1_TS
+ 0b01 VIRTUAL
+ 0b10 GUEST_PHYSICAL
+ 0b11 PHYSICAL
EndEnum
Res0 4
Field 3 CX
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 7/9] arm64: sysreg: Reject a macro name defined twice
[not found] <20261123075219.369042-1-fuad.tabba@linux.dev>
` (3 preceding siblings ...)
2026-11-23 7:52 ` [PATCH 6/9] arm64: sysreg: Reject an enum value not written at its field's width Fuad Tabba
@ 2026-11-23 7:52 ` Fuad Tabba
2026-11-23 7:52 ` [PATCH 9/9] arm64: sysreg: Reject a bit position written with a leading zero Fuad Tabba
5 siblings, 0 replies; 6+ messages in thread
From: Fuad Tabba @ 2026-11-23 7:52 UTC (permalink / raw)
To: Catalin Marinas, Will Deacon
Cc: Mark Rutland, Marc Zyngier, Oliver Upton, Mark Brown,
Sascha Bischoff, Steffen Eiden, linux-arm-kernel, linux-kernel,
Fuad Tabba
The generator rejects a duplicate register, SysregFields block, prefix
or enum value, but not two definitions of the same macro. Two fields
called F in REG make it emit REG_F twice with different masks, which the
compiler reports only as a redefinition warning against the generated
header, in every file that includes it. Two values of one enum sharing a
name do the same, and so do names that collide only once the generator
joins them: a field A_B beside value B of field A, a field F_MASK beside
F, or a field B_C in FOO beside a field C in FOO_B.
Record every macro name the generator defines, and fail on the second
definition. This covers a duplicate block or prefix too, but their own
checks stay, since they report the duplicate at the block's own line, by
block name.
Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev>
---
arch/arm64/tools/gen-sysreg.awk | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/arm64/tools/gen-sysreg.awk b/arch/arm64/tools/gen-sysreg.awk
index cde526896ed96..0bd6aab8aae0f 100755
--- a/arch/arm64/tools/gen-sysreg.awk
+++ b/arch/arm64/tools/gen-sysreg.awk
@@ -46,6 +46,10 @@ function expect_fields(nf) {
# Print a CPP macro definition, padded with spaces so that the macro bodies
# line up in a column
function define(prefix, name, val) {
+ if ((prefix name) in defined_macros)
+ fatal("Duplicate macro " prefix name)
+ defined_macros[prefix name] = 1
+
printf "%-56s%s\n", "#define " prefix name, val
}
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 9/9] arm64: sysreg: Reject a bit position written with a leading zero
[not found] <20261123075219.369042-1-fuad.tabba@linux.dev>
` (4 preceding siblings ...)
2026-11-23 7:52 ` [PATCH 7/9] arm64: sysreg: Reject a macro name defined twice Fuad Tabba
@ 2026-11-23 7:52 ` Fuad Tabba
5 siblings, 0 replies; 6+ messages in thread
From: Fuad Tabba @ 2026-11-23 7:52 UTC (permalink / raw)
To: Catalin Marinas, Will Deacon
Cc: Mark Rutland, Marc Zyngier, Oliver Upton, Mark Brown,
Sascha Bischoff, Steffen Eiden, linux-arm-kernel, linux-kernel,
Fuad Tabba
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@linux.dev>
---
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 "'")
if (msb != next_bit)
fatal(reg "." field " starts at " msb " not " next_bit)
if (63 < msb || msb < 0)
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-11-23 8:02 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20261123075219.369042-1-fuad.tabba@linux.dev>
2026-11-23 7:52 ` [PATCH 1/9] arm64: sysreg: Map MPAM1_EL12 to MPAM1_EL1 Fuad Tabba
2026-11-23 7:52 ` [PATCH 2/9] arm64: sysreg: Remove the dead range check from parse_bitdef() Fuad Tabba
2026-11-23 7:52 ` [PATCH 3/9] arm64: sysreg: Reject a Sysreg and a SysregFields with the same name Fuad Tabba
2026-11-23 7:52 ` [PATCH 6/9] arm64: sysreg: Reject an enum value not written at its field's width Fuad Tabba
2026-11-23 7:52 ` [PATCH 7/9] arm64: sysreg: Reject a macro name defined twice Fuad Tabba
2026-11-23 7:52 ` [PATCH 9/9] arm64: sysreg: Reject a bit position written with a leading zero Fuad Tabba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox