diff mbox series

[4/4] arm: use correct argument size of special registers

Message ID 20200527180424.39395-5-xypron.glpk@gmx.de
State Accepted
Commit 22a4e006be52fbd5249f46c36c4d8016c15b9fa7
Delegated to: Tom Rini
Headers show
Series arm: fix clang build errors | expand

Commit Message

Heinrich Schuchardt May 27, 2020, 6:04 p.m. UTC
Compiling with clang on ARMv8 shows errors like:

./arch/arm/include/asm/system.h:162:32: note: use constraint modifier "w"
                asm volatile("msr sctlr_el1, %0" : : "r" (val) : "cc");
                                             ^~
                                             %w0

These errors are due to using an incorrect size for the variables used
for writing to and reading from special registers which have 64 bits on
ARMv8.

Mask off reserved bits when reading the exception level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 arch/arm/include/asm/system.h | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

--
2.26.2

Comments

Tom Rini July 8, 2020, 3:03 a.m. UTC | #1
On Wed, May 27, 2020 at 08:04:24PM +0200, Heinrich Schuchardt wrote:

> Compiling with clang on ARMv8 shows errors like:
> 
> ./arch/arm/include/asm/system.h:162:32: note: use constraint modifier "w"
>                 asm volatile("msr sctlr_el1, %0" : : "r" (val) : "cc");
>                                              ^~
>                                              %w0
> 
> These errors are due to using an incorrect size for the variables used
> for writing to and reading from special registers which have 64 bits on
> ARMv8.
> 
> Mask off reserved bits when reading the exception level.
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h
index 1e3f574403..952057d8ca 100644
--- a/arch/arm/include/asm/system.h
+++ b/arch/arm/include/asm/system.h
@@ -133,14 +133,16 @@  enum dcache_option {

 static inline unsigned int current_el(void)
 {
-	unsigned int el;
+	unsigned long el;
+
 	asm volatile("mrs %0, CurrentEL" : "=r" (el) : : "cc");
-	return el >> 2;
+	return 3 & (el >> 2);
 }

 static inline unsigned int get_sctlr(void)
 {
-	unsigned int el, val;
+	unsigned int el;
+	unsigned long val;

 	el = current_el();
 	if (el == 1)
@@ -153,7 +155,7 @@  static inline unsigned int get_sctlr(void)
 	return val;
 }

-static inline void set_sctlr(unsigned int val)
+static inline void set_sctlr(unsigned long val)
 {
 	unsigned int el;