Re: [PATCH] MIPS: Make cpu_has_mips64r6 constant on 64-bit r6 kernels
From: Tzu-Ching Yang
Date: Sun Nov 22 2026 - 22:57:48 EST
Sorry for the late reply: your mail did not reach my mailbox, and I did
not check the list archive until now.
On Fri, 30 Oct 2026, Maciej W. Rozycki wrote:
> Umm, the wrong fix. You want __isa_ge_or_flag() instead, plus obviously
> `cpu_has_64bits' is also needed (and __isa_ge_and_flag() can be discarded;
> I guess it was meant to take care of what `cpu_has_64bits' does and broke
> the whole idea by mistake).
Your form and v1 differ only on pre-r6 kernels. I built both on
mips-next (bfe97f12a0a6), and this is what cpu_has_mips64r6 folds to:
kernel mainline v1 your form
--------- ------------- ------------- -------------
64-bit r6 run-time test 1 1
32-bit r6 run-time test run-time test run-time test
pre-r6 0 0 run-time test
On r6 kernels the two give the same vmlinux, byte for byte
(64r6el_defconfig and 32r6el_defconfig, GCC 8.1 and 16.2, Clang 23).
On pre-r6 kernels your form compiles the r6 paths in behind the test,
for example the dmfc0 and dmtc0 of c0_ebase in decode_configs(), and
on 32-bit kernels every cpu_has_mips_r6 check also tests cpu_has_64bits
and MIPS_CPU_ISA_M64R6. In bloat-o-meter -t that is +264 bytes for
64r2el_defconfig and +3352 for 32r2el_defconfig with GCC 16.2, and
+168 and -2500 with Clang 23, which on 32r2el_defconfig no longer
inlines two prefetch helpers in mm/page.c.
> Your proposal precludes the use of R6 stuff
> with pre-R6 compilations -- not sure if that makes sense, but let's stay
> consistent with these macro definitions.
In mainline cpu_has_mips64r6 is already 0 on pre-r6 kernels, and I do
not think a pre-r6 kernel gets as far as cpu_probe() on an r6 CPU.
The comment above __isa_ge_and_ase() in cpu-features.h says that
"a kernel built for an older ISA cannot run on a MIPSr6 CPU", and
under QEMU -cpu I6400 (an r6 CPU) a 64-bit malta kernel built for r2
takes a Reserved Instruction exception at the first jr in head.S.
That leaves three ways, and I will send whichever you prefer as v2:
1. v1 with the unused __isa_ge_and_flag() removed, and in the same
series a patch that defines cpu_has_mips32r6 as (MIPS_ISA_REV >= 6)
to match, like cpu_has_mips_1 (MIPS_ISA_REV < 6) in that header.
cpu_has_mips_r6 is then 0 on pre-r6 kernels and the code that it
guards is dropped: in bloat-o-meter -t, -11524 bytes for
64r2el_defconfig and -11156 for 32r2el_defconfig with GCC 16.2,
-18704 and -14140 with Clang 23, with no new W=1 warnings in these
vmlinux builds. r6 kernels stay byte-identical to v1.
2. v1 with __isa_ge_and_flag() removed: pre-r6 kernels do not change.
3. Your form, with the sizes above.
I would suggest 1.
Thanks,
Tzu-Ching