]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
s390/xor: Improve inline assembly constraints
authorHeiko Carstens <hca@linux.ibm.com>
Mon, 2 Mar 2026 13:34:59 +0000 (14:34 +0100)
committerVasily Gorbik <gor@linux.ibm.com>
Tue, 3 Mar 2026 15:42:14 +0000 (16:42 +0100)
The inline assembly constraint for the "bytes" operand is "d" for all xor()
inline assemblies. "d" means that any register from 0 to 15 can be used. If
the compiler would use register 0 then the exrl instruction would not or
the value of "bytes" into the executed instruction - resulting in an
incorrect result.

However all the xor() inline assemblies make hard-coded use of register 0,
and it is correctly listed in the clobber list, so that this cannot happen.

Given that this is quite subtle use the better "a" constraint, which
excludes register 0 from register allocation in any case.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Link: https://lore.kernel.org/r/20260302133500.1560531-3-hca@linux.ibm.com
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
arch/s390/lib/xor.c

index 81c0235c04666ef98567036f8ddbf9047333833a..5363e4c2462d1c2a925bc5369f69ca66472f5f8d 100644 (file)
@@ -28,7 +28,7 @@ static void xor_xc_2(unsigned long bytes, unsigned long * __restrict p1,
                "       j       3f\n"
                "2:     xc      0(1,%1),0(%2)\n"
                "3:"
-               : "+d" (bytes), "+a" (p1), "+a" (p2)
+               : "+a" (bytes), "+a" (p1), "+a" (p2)
                : : "0", "cc", "memory");
 }
 
@@ -54,7 +54,7 @@ static void xor_xc_3(unsigned long bytes, unsigned long * __restrict p1,
                "2:     xc      0(1,%1),0(%2)\n"
                "3:     xc      0(1,%1),0(%3)\n"
                "4:"
-               : "+d" (bytes), "+a" (p1), "+a" (p2), "+a" (p3)
+               : "+a" (bytes), "+a" (p1), "+a" (p2), "+a" (p3)
                : : "0", "cc", "memory");
 }
 
@@ -85,7 +85,7 @@ static void xor_xc_4(unsigned long bytes, unsigned long * __restrict p1,
                "3:     xc      0(1,%1),0(%3)\n"
                "4:     xc      0(1,%1),0(%4)\n"
                "5:"
-               : "+d" (bytes), "+a" (p1), "+a" (p2), "+a" (p3), "+a" (p4)
+               : "+a" (bytes), "+a" (p1), "+a" (p2), "+a" (p3), "+a" (p4)
                : : "0", "cc", "memory");
 }
 
@@ -121,7 +121,7 @@ static void xor_xc_5(unsigned long bytes, unsigned long * __restrict p1,
                "4:     xc      0(1,%1),0(%4)\n"
                "5:     xc      0(1,%1),0(%5)\n"
                "6:"
-               : "+d" (bytes), "+a" (p1), "+a" (p2), "+a" (p3), "+a" (p4),
+               : "+a" (bytes), "+a" (p1), "+a" (p2), "+a" (p3), "+a" (p4),
                  "+a" (p5)
                : : "0", "cc", "memory");
 }