Skip to contentSkip to conversation

arm64: sysreg: Fix use of XZR in write_sysreg_s

PATCH New Will Deacon 2 participants 2 messages Oct 17, 2016 arm64

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64: sysreg: Fix use of XZR in write_sysreg_s

Commit 8a71f0c656e0 ("arm64: sysreg: replace open-coded mrs_s/msr_s with {read,write}_sysreg_s") introduced a write_sysreg_s macro for writing to system registers that are not supported by binutils.

Unfortunately, this was implemented with the wrong template (%0 vs %x0), so in the case that we are writing a constant 0, we will generate invalid instruction syntax and bail with a cryptic assembler error:

| Error: constant expression required

This patch fixes the template.

---
 arch/arm64/include/asm/sysreg.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/include/asm/sysreg.h +1 -1
index e8d46e8e6079..6c80b3699cb8 100644
@@ -286,7 +286,7 @@ asm(
 
 #define write_sysreg_s(v, r) do {					\
 	u64 __val = (u64)v;						\
-	asm volatile("msr_s " __stringify(r) ", %0" : : "rZ" (__val));	\
+	asm volatile("msr_s " __stringify(r) ", %x0" : : "rZ" (__val));	\
 } while (0)
 
 static inline void config_sctlr_el1(u32 clear, u32 set)
Signature · 1 line
2.1.4
reviewer
#1 lore raw

PATCH 1/1 arm64: sysreg: Fix use of XZR in write_sysreg_s

Quoted 8 lines · Will Deacon

Commit 8a71f0c656e0 ("arm64: sysreg: replace open-coded mrs_s/msr_s with {read,write}_sysreg_s") introduced a write_sysreg_s macro for writing to system registers that are not supported by binutils.

Unfortunately, this was implemented with the wrong template (%0 vs %x0), so in the case that we are writing a constant 0, we will generate invalid instruction syntax and bail with a cryptic assembler error:

Quoted 5 lines

| Error: constant expression required

This patch fixes the template.

Whoops; I should've spotted that in review. FWIW:

Thanks,
Mark.

Quoted 26 lines
---
 arch/arm64/include/asm/sysreg.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/include/asm/sysreg.h +1 -1
index e8d46e8e6079..6c80b3699cb8 100644
@@ -286,7 +286,7 @@ asm(
 
 #define write_sysreg_s(v, r) do {					\
 	u64 __val = (u64)v;						\
-	asm volatile("msr_s " __stringify(r) ", %0" : : "rZ" (__val));	\
+	asm volatile("msr_s " __stringify(r) ", %x0" : : "rZ" (__val));	\
 } while (0)
 
 static inline void config_sctlr_el1(u32 clear, u32 set)
Signature · 7 lines
2.1.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel