Re: [PATCH v5 3/5] arm64/hwcap: Describe 2024 dpISA extensions to userspace

Mark Rutland
2025-02-07T18:37:35Z

On Tue, Jan 07, 2025 at 10:59:43PM +0000, Mark Brown wrote:
> The 2024 dpISA introduces a number of architecture features all of which
> only add new instructions so only require the addition of hwcaps and ID
> register visibility.

While working on SME fixes atop v6.14-rc1, I found this patch breaks the
build spectacularly with CONFIG_ARM64_SME is enabled (splat at the end
of this mail), due to some missing definitions.

From a quick scan, there are some other missing bits too. For example
these two caps are defined in terms of ID_AA64FPFR0_EL1 fields:

> +HWCAP_F8MM8
> + Functionality implied by ID_AA64FPFR0_EL1.F8MM8 == 0b0001.
> +
> +HWCAP_F8MM4
> + Functionality implied by ID_AA64FPFR0_EL1.F8MM4 == 0b0001.

> +#define KERNEL_HWCAP_F8MM8 __khwcap_feature(F8MM8)
> +#define KERNEL_HWCAP_F8MM4 __khwcap_feature(F8MM4)

> +#define HWCAP_F8MM8 (1UL << 35)
> +#define HWCAP_F8MM4 (1UL << 36)

... and we expose the ID register bits to userspace:

> @@ -381,6 +396,8 @@ static const struct arm64_ftr_bits ftr_id_aa64fpfr0[] = {
> ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_EXACT, ID_AA64FPFR0_EL1_F8FMA_SHIFT, 1, 0),
> ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_EXACT, ID_AA64FPFR0_EL1_F8DP4_SHIFT, 1, 0),
> ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_EXACT, ID_AA64FPFR0_EL1_F8DP2_SHIFT, 1, 0),
> + ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_EXACT, ID_AA64FPFR0_EL1_F8MM8_SHIFT, 1, 0),
> + ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_EXACT, ID_AA64FPFR0_EL1_F8MM4_SHIFT, 1, 0),
> ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_EXACT, ID_AA64FPFR0_EL1_F8E4M3_SHIFT, 1, 0),
> ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_EXACT, ID_AA64FPFR0_EL1_F8E5M2_SHIFT, 1, 0),

... but there's no corresponding arm64_elf_hwcaps additions to actually
expose the hwcaps.

There are *SME* variants in arm64_elf_hwcaps:

> @@ -3163,6 +3187,13 @@ static const struct arm64_cpu_capabilities arm64_elf_hwcaps[] = {
> HWCAP_CAP(ID_AA64SMFR0_EL1, SF8FMA, IMP, CAP_HWCAP, KERNEL_HWCAP_SME_SF8FMA),
> HWCAP_CAP(ID_AA64SMFR0_EL1, SF8DP4, IMP, CAP_HWCAP, KERNEL_HWCAP_SME_SF8DP4),
> HWCAP_CAP(ID_AA64SMFR0_EL1, SF8DP2, IMP, CAP_HWCAP, KERNEL_HWCAP_SME_SF8DP2),
> + HWCAP_CAP(ID_AA64SMFR0_EL1, SF8MM8, IMP, CAP_HWCAP, KERNEL_HWCAP_SME_SF8MM8),
> + HWCAP_CAP(ID_AA64SMFR0_EL1, SF8MM4, IMP, CAP_HWCAP, KERNEL_HWCAP_SME_SF8MM4),

... but those KERNEL_HWCAP_SME_* values are never defined, and neither
are the UAPI equivalents.

We need to fix that quick, in case we need to shuffle values.

> diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c
> index d79e88fccdfce427507e7a34c5959ce6309cbd12..b08ea3dd5e210626102b83edc3be4efcc9225fc6 100644
> --- a/arch/arm64/kernel/cpuinfo.c
> +++ b/arch/arm64/kernel/cpuinfo.c
> @@ -145,6 +145,21 @@ static const char *const hwcap_str[] = {
> [KERNEL_HWCAP_SME_SF8DP4] = "smesf8dp4",
> [KERNEL_HWCAP_SME_SF8DP2] = "smesf8dp2",
> [KERNEL_HWCAP_POE] = "poe",
> + [KERNEL_HWCAP_CMPBR] = "cmpbr",
> + [KERNEL_HWCAP_FPRCVT] = "fprcvt",
> + [KERNEL_HWCAP_F8MM8] = "f8mm8",
> + [KERNEL_HWCAP_F8MM4] = "f8mm4",
> + [KERNEL_HWCAP_SVE_F16MM] = "svef16mm",
> + [KERNEL_HWCAP_SVE_ELTPERM] = "sveeltperm",
> + [KERNEL_HWCAP_SVE_AES2] = "sveaes2",
> + [KERNEL_HWCAP_SVE_BFSCALE] = "svebfscale",
> + [KERNEL_HWCAP_SVE2P2] = "sve2p2",
> + [KERNEL_HWCAP_SME2P2] = "sme2p2",
> + [KERNEL_HWCAP_SME_SBITPERM] = "smesbitperm",
> + [KERNEL_HWCAP_SME_AES] = "smeaes",
> + [KERNEL_HWCAP_SME_SFEXPA] = "smesfexpa",
> + [KERNEL_HWCAP_SME_STMOP] = "smestmop",
> + [KERNEL_HWCAP_SME_SMOP4] = "smesmop4",
> };

Likewise they're missing from the strings table here.

The full splat I got was:

| [mark@lakrids:~/src/linux]% usekorg 14.2.0 make ARCH=arm64 CROSS_COMPILE=aarch64-linux- arch/arm64/
| CALL scripts/checksyscalls.sh
| CC arch/arm64/kernel/cpufeature.o
| arch/arm64/kernel/cpufeature.c:3183:61: error: 'KERNEL_HWCAP_SME_SF8MM8' undeclared here (not in a function); did you mean 'KERNEL_HWCAP_SME_SF8FMA'?
| 3183 | HWCAP_CAP(ID_AA64SMFR0_EL1, SF8MM8, IMP, CAP_HWCAP, KERNEL_HWCAP_SME_SF8MM8),
| | ^~~~~~~~~~~~~~~~~~~~~~~
| arch/arm64/kernel/cpufeature.c:3013:26: note: in definition of macro '__HWCAP_CAP'
| 3013 | .hwcap = cap, \
| | ^~~
| arch/arm64/kernel/cpufeature.c:3183:9: note: in expansion of macro 'HWCAP_CAP'
| 3183 | HWCAP_CAP(ID_AA64SMFR0_EL1, SF8MM8, IMP, CAP_HWCAP, KERNEL_HWCAP_SME_SF8MM8),
| | ^~~~~~~~~
| arch/arm64/kernel/cpufeature.c:3183:19: error: 'ID_AA64SMFR0_EL1_SF8MM8_SHIFT' undeclared here (not in a function); did you mean 'ID_AA64SMFR0_EL1_SF8FMA_SHIFT'?
| 3183 | HWCAP_CAP(ID_AA64SMFR0_EL1, SF8MM8, IMP, CAP_HWCAP, KERNEL_HWCAP_SME_SF8MM8),
| | ^~~~~~~~~~~~~~~~
| arch/arm64/kernel/cpufeature.c:154:30: note: in definition of macro '__ARM64_CPUID_FIELDS'
| 154 | .field_pos = reg##_##field##_SHIFT, \
| | ^~~
| arch/arm64/kernel/cpufeature.c:3007:17: note: in expansion of macro 'ARM64_CPUID_FIELDS'
| 3007 | ARM64_CPUID_FIELDS(reg, field, min_value)
| | ^~~~~~~~~~~~~~~~~~
| arch/arm64/kernel/cpufeature.c:3018:17: note: in expansion of macro 'HWCAP_CPUID_MATCH'
| 3018 | HWCAP_CPUID_MATCH(reg, field, min_value) \
| | ^~~~~~~~~~~~~~~~~
| arch/arm64/kernel/cpufeature.c:3183:9: note: in expansion of macro 'HWCAP_CAP'
| 3183 | HWCAP_CAP(ID_AA64SMFR0_EL1, SF8MM8, IMP, CAP_HWCAP, KERNEL_HWCAP_SME_SF8MM8),
| | ^~~~~~~~~
| arch/arm64/kernel/cpufeature.c:3183:19: error: 'ID_AA64SMFR0_EL1_SF8MM8_WIDTH' undeclared here (not in a function); did you mean 'ID_AA64SMFR0_EL1_SF8FMA_WIDTH'?
| 3183 | HWCAP_CAP(ID_AA64SMFR0_EL1, SF8MM8, IMP, CAP_HWCAP, KERNEL_HWCAP_SME_SF8MM8),
| | ^~~~~~~~~~~~~~~~
| arch/arm64/kernel/cpufeature.c:155:32: note: in definition of macro '__ARM64_CPUID_FIELDS'
| 155 | .field_width = reg##_##field##_WIDTH, \
| | ^~~
| arch/arm64/kernel/cpufeature.c:3007:17: note: in expansion of macro 'ARM64_CPUID_FIELDS'
| 3007 | ARM64_CPUID_FIELDS(reg, field, min_value)
| | ^~~~~~~~~~~~~~~~~~
| arch/arm64/kernel/cpufeature.c:3018:17: note: in expansion of macro 'HWCAP_CPUID_MATCH'
| 3018 | HWCAP_CPUID_MATCH(reg, field, min_value) \
| | ^~~~~~~~~~~~~~~~~
| arch/arm64/kernel/cpufeature.c:3183:9: note: in expansion of macro 'HWCAP_CAP'
| 3183 | HWCAP_CAP(ID_AA64SMFR0_EL1, SF8MM8, IMP, CAP_HWCAP, KERNEL_HWCAP_SME_SF8MM8),
| | ^~~~~~~~~
| arch/arm64/kernel/cpufeature.c:3183:19: error: 'ID_AA64SMFR0_EL1_SF8MM8_SIGNED' undeclared here (not in a function); did you mean 'ID_AA64SMFR0_EL1_SF8FMA_SIGNED'?
| 3183 | HWCAP_CAP(ID_AA64SMFR0_EL1, SF8MM8, IMP, CAP_HWCAP, KERNEL_HWCAP_SME_SF8MM8),
| | ^~~~~~~~~~~~~~~~
| arch/arm64/kernel/cpufeature.c:156:25: note: in definition of macro '__ARM64_CPUID_FIELDS'
| 156 | .sign = reg##_##field##_SIGNED, \
| | ^~~
| arch/arm64/kernel/cpufeature.c:3007:17: note: in expansion of macro 'ARM64_CPUID_FIELDS'
| 3007 | ARM64_CPUID_FIELDS(reg, field, min_value)
| | ^~~~~~~~~~~~~~~~~~
| arch/arm64/kernel/cpufeature.c:3018:17: note: in expansion of macro 'HWCAP_CPUID_MATCH'
| 3018 | HWCAP_CPUID_MATCH(reg, field, min_value) \
| | ^~~~~~~~~~~~~~~~~
| arch/arm64/kernel/cpufeature.c:3183:9: note: in expansion of macro 'HWCAP_CAP'
| 3183 | HWCAP_CAP(ID_AA64SMFR0_EL1, SF8MM8, IMP, CAP_HWCAP, KERNEL_HWCAP_SME_SF8MM8),
| | ^~~~~~~~~
| arch/arm64/kernel/cpufeature.c:3183:19: error: 'ID_AA64SMFR0_EL1_SF8MM8_IMP' undeclared here (not in a function); did you mean 'ID_AA64SMFR0_EL1_SF8FMA_IMP'?
| 3183 | HWCAP_CAP(ID_AA64SMFR0_EL1, SF8MM8, IMP, CAP_HWCAP, KERNEL_HWCAP_SME_SF8MM8),
| | ^~~~~~~~~~~~~~~~
| arch/arm64/kernel/cpufeature.c:157:36: note: in definition of macro '__ARM64_CPUID_FIELDS'
| 157 | .min_field_value = min_value, \
| | ^~~~~~~~~
| arch/arm64/kernel/cpufeature.c:169:30: note: in expansion of macro 'SYS_FIELD_VALUE'
| 169 | SYS_FIELD_VALUE(reg, field, min_value), \
| | ^~~~~~~~~~~~~~~
| arch/arm64/kernel/cpufeature.c:3007:17: note: in expansion of macro 'ARM64_CPUID_FIELDS'
| 3007 | ARM64_CPUID_FIELDS(reg, field, min_value)
| | ^~~~~~~~~~~~~~~~~~
| arch/arm64/kernel/cpufeature.c:3018:17: note: in expansion of macro 'HWCAP_CPUID_MATCH'
| 3018 | HWCAP_CPUID_MATCH(reg, field, min_value) \
| | ^~~~~~~~~~~~~~~~~
| arch/arm64/kernel/cpufeature.c:3183:9: note: in expansion of macro 'HWCAP_CAP'
| 3183 | HWCAP_CAP(ID_AA64SMFR0_EL1, SF8MM8, IMP, CAP_HWCAP, KERNEL_HWCAP_SME_SF8MM8),
| | ^~~~~~~~~
| arch/arm64/kernel/cpufeature.c:3184:61: error: 'KERNEL_HWCAP_SME_SF8MM4' undeclared here (not in a function); did you mean 'KERNEL_HWCAP_SME_SF8DP4'?
| 3184 | HWCAP_CAP(ID_AA64SMFR0_EL1, SF8MM4, IMP, CAP_HWCAP, KERNEL_HWCAP_SME_SF8MM4),
| | ^~~~~~~~~~~~~~~~~~~~~~~
| arch/arm64/kernel/cpufeature.c:3013:26: note: in definition of macro '__HWCAP_CAP'
| 3013 | .hwcap = cap, \
| | ^~~
| arch/arm64/kernel/cpufeature.c:3184:9: note: in expansion of macro 'HWCAP_CAP'
| 3184 | HWCAP_CAP(ID_AA64SMFR0_EL1, SF8MM4, IMP, CAP_HWCAP, KERNEL_HWCAP_SME_SF8MM4),
| | ^~~~~~~~~
| arch/arm64/kernel/cpufeature.c:3184:19: error: 'ID_AA64SMFR0_EL1_SF8MM4_SHIFT' undeclared here (not in a function); did you mean 'ID_AA64SMFR0_EL1_SF8FMA_SHIFT'?
| 3184 | HWCAP_CAP(ID_AA64SMFR0_EL1, SF8MM4, IMP, CAP_HWCAP, KERNEL_HWCAP_SME_SF8MM4),
| | ^~~~~~~~~~~~~~~~
| arch/arm64/kernel/cpufeature.c:154:30: note: in definition of macro '__ARM64_CPUID_FIELDS'
| 154 | .field_pos = reg##_##field##_SHIFT, \
| | ^~~
| arch/arm64/kernel/cpufeature.c:3007:17: note: in expansion of macro 'ARM64_CPUID_FIELDS'
| 3007 | ARM64_CPUID_FIELDS(reg, field, min_value)
| | ^~~~~~~~~~~~~~~~~~
| arch/arm64/kernel/cpufeature.c:3018:17: note: in expansion of macro 'HWCAP_CPUID_MATCH'
| 3018 | HWCAP_CPUID_MATCH(reg, field, min_value) \
| | ^~~~~~~~~~~~~~~~~
| arch/arm64/kernel/cpufeature.c:3184:9: note: in expansion of macro 'HWCAP_CAP'
| 3184 | HWCAP_CAP(ID_AA64SMFR0_EL1, SF8MM4, IMP, CAP_HWCAP, KERNEL_HWCAP_SME_SF8MM4),
| | ^~~~~~~~~
| arch/arm64/kernel/cpufeature.c:3184:19: error: 'ID_AA64SMFR0_EL1_SF8MM4_WIDTH' undeclared here (not in a function); did you mean 'ID_AA64SMFR0_EL1_SF8FMA_WIDTH'?
| 3184 | HWCAP_CAP(ID_AA64SMFR0_EL1, SF8MM4, IMP, CAP_HWCAP, KERNEL_HWCAP_SME_SF8MM4),
| | ^~~~~~~~~~~~~~~~
| arch/arm64/kernel/cpufeature.c:155:32: note: in definition of macro '__ARM64_CPUID_FIELDS'
| 155 | .field_width = reg##_##field##_WIDTH, \
| | ^~~
| arch/arm64/kernel/cpufeature.c:3007:17: note: in expansion of macro 'ARM64_CPUID_FIELDS'
| 3007 | ARM64_CPUID_FIELDS(reg, field, min_value)
| | ^~~~~~~~~~~~~~~~~~
| arch/arm64/kernel/cpufeature.c:3018:17: note: in expansion of macro 'HWCAP_CPUID_MATCH'
| 3018 | HWCAP_CPUID_MATCH(reg, field, min_value) \
| | ^~~~~~~~~~~~~~~~~
| arch/arm64/kernel/cpufeature.c:3184:9: note: in expansion of macro 'HWCAP_CAP'
| 3184 | HWCAP_CAP(ID_AA64SMFR0_EL1, SF8MM4, IMP, CAP_HWCAP, KERNEL_HWCAP_SME_SF8MM4),
| | ^~~~~~~~~
| arch/arm64/kernel/cpufeature.c:3184:19: error: 'ID_AA64SMFR0_EL1_SF8MM4_SIGNED' undeclared here (not in a function); did you mean 'ID_AA64SMFR0_EL1_SF8DP4_SIGNED'?
| 3184 | HWCAP_CAP(ID_AA64SMFR0_EL1, SF8MM4, IMP, CAP_HWCAP, KERNEL_HWCAP_SME_SF8MM4),
| | ^~~~~~~~~~~~~~~~
| arch/arm64/kernel/cpufeature.c:156:25: note: in definition of macro '__ARM64_CPUID_FIELDS'
| 156 | .sign = reg##_##field##_SIGNED, \
| | ^~~
| arch/arm64/kernel/cpufeature.c:3007:17: note: in expansion of macro 'ARM64_CPUID_FIELDS'
| 3007 | ARM64_CPUID_FIELDS(reg, field, min_value)
| | ^~~~~~~~~~~~~~~~~~
| arch/arm64/kernel/cpufeature.c:3018:17: note: in expansion of macro 'HWCAP_CPUID_MATCH'
| 3018 | HWCAP_CPUID_MATCH(reg, field, min_value) \
| | ^~~~~~~~~~~~~~~~~
| arch/arm64/kernel/cpufeature.c:3184:9: note: in expansion of macro 'HWCAP_CAP'
| 3184 | HWCAP_CAP(ID_AA64SMFR0_EL1, SF8MM4, IMP, CAP_HWCAP, KERNEL_HWCAP_SME_SF8MM4),
| | ^~~~~~~~~
| arch/arm64/kernel/cpufeature.c:3184:19: error: 'ID_AA64SMFR0_EL1_SF8MM4_IMP' undeclared here (not in a function); did you mean 'ID_AA64SMFR0_EL1_SF8DP4_IMP'?
| 3184 | HWCAP_CAP(ID_AA64SMFR0_EL1, SF8MM4, IMP, CAP_HWCAP, KERNEL_HWCAP_SME_SF8MM4),
| | ^~~~~~~~~~~~~~~~
| arch/arm64/kernel/cpufeature.c:157:36: note: in definition of macro '__ARM64_CPUID_FIELDS'
| 157 | .min_field_value = min_value, \
| | ^~~~~~~~~
| arch/arm64/kernel/cpufeature.c:169:30: note: in expansion of macro 'SYS_FIELD_VALUE'
| 169 | SYS_FIELD_VALUE(reg, field, min_value), \
| | ^~~~~~~~~~~~~~~
| arch/arm64/kernel/cpufeature.c:3007:17: note: in expansion of macro 'ARM64_CPUID_FIELDS'
| 3007 | ARM64_CPUID_FIELDS(reg, field, min_value)
| | ^~~~~~~~~~~~~~~~~~
| arch/arm64/kernel/cpufeature.c:3018:17: note: in expansion of macro 'HWCAP_CPUID_MATCH'
| 3018 | HWCAP_CPUID_MATCH(reg, field, min_value) \
| | ^~~~~~~~~~~~~~~~~
| arch/arm64/kernel/cpufeature.c:3184:9: note: in expansion of macro 'HWCAP_CAP'
| 3184 | HWCAP_CAP(ID_AA64SMFR0_EL1, SF8MM4, IMP, CAP_HWCAP, KERNEL_HWCAP_SME_SF8MM4),
| | ^~~~~~~~~
| make[4]: *** [scripts/Makefile.build:207: arch/arm64/kernel/cpufeature.o] Error 1
| make[3]: *** [scripts/Makefile.build:465: arch/arm64/kernel] Error 2
| make[2]: *** [scripts/Makefile.build:465: arch/arm64] Error 2
| make[1]: *** [/home/mark/src/linux/Makefile:1994: .] Error 2
| make: *** [Makefile:251: __sub-make] Error 2

Mark.