[PATCH 02/12] s390/percpu: Add sanity check to GEN_MVIY macro
From: Heiko Carstens
Date: Thu Sep 17 2026 - 17:18:50 EST
Emit an error if the GEN_MVIY macro fails to parse the passed register
string. This will make it more obvious if something similar which was
fixed with [1] happens again.
[1] commit 101782f8945a ("s390/percpu: Fix MVIY_PERCPU() with older binutils")
Signed-off-by: Heiko Carstens <hca@xxxxxxxxxxxxx>
---
arch/s390/include/asm/percpu.h | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/arch/s390/include/asm/percpu.h b/arch/s390/include/asm/percpu.h
index 31012abe8292..9888b38dedab 100644
--- a/arch/s390/include/asm/percpu.h
+++ b/arch/s390/include/asm/percpu.h
@@ -100,12 +100,17 @@
*/
#define MVIY_PERCPU(disp, dispalt, reg) \
- ".macro GEN_MVIY disp reg\n" \
+ ".macro GEN_MVIY disp, reg\n" \
+ ".set .Lreg,255\n" \
".irp rs,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15\n" \
" .ifc \\reg,%%r\\rs\n" \
- " mviy \\disp(%%r0),\\rs\n" \
+ " .set .Lreg,\\rs\n" \
" .endif\n" \
".endr\n" \
+ ".if .Lreg == 255\n" \
+ " .error \"Illegal register number\"\n" \
+ ".endif\n" \
+ "mviy \\disp(%%r0),.Lreg\n" \
".endm\n" \
ALTERNATIVE("GEN_MVIY " disp ", " reg "\n", \
"GEN_MVIY " dispalt ", " reg "\n", \
--
2.53.0