All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heinrich Schuchardt <xypron.glpk@gmx.de>
To: u-boot@lists.denx.de
Subject: [PATCH 4/4] arm: use correct argument size of special registers
Date: Wed, 27 May 2020 20:04:24 +0200	[thread overview]
Message-ID: <20200527180424.39395-5-xypron.glpk@gmx.de> (raw)
In-Reply-To: <20200527180424.39395-1-xypron.glpk@gmx.de>

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(-)

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;

--
2.26.2

  parent reply	other threads:[~2020-05-27 18:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-27 18:04 [PATCH 0/4] arm: fix clang build errors Heinrich Schuchardt
2020-05-27 18:04 ` [PATCH 1/4] efi_loader: allow compiling with clang Heinrich Schuchardt
2020-05-31 14:08   ` Simon Glass
2020-05-27 18:04 ` [PATCH 2/4] trace: clang compatible handling of gd register Heinrich Schuchardt
2020-05-31 14:08   ` Simon Glass
2020-07-08  3:03   ` Tom Rini
2020-05-27 18:04 ` [PATCH 3/4] arm: remove outdated comment concerning -ffixed-x18 Heinrich Schuchardt
2020-05-31 14:08   ` Simon Glass
2020-07-08  3:03   ` Tom Rini
2020-05-27 18:04 ` Heinrich Schuchardt [this message]
2020-07-08  3:03   ` [PATCH 4/4] arm: use correct argument size of special registers Tom Rini
2020-06-14 15:51 ` [PATCH 0/4] arm: fix clang build errors Heinrich Schuchardt
2020-06-14 15:59   ` Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200527180424.39395-5-xypron.glpk@gmx.de \
    --to=xypron.glpk@gmx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.