diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2015-09-11 08:34:52 +0100 |
---|---|---|
committer | Jeff Vander Stoep <jeffv@google.com> | 2016-01-25 09:27:56 -0800 |
commit | bad6c993d9ebd088c16f3249e4c8bc2af1d1fc7e (patch) | |
tree | a364b79573853e97c43cf39abb4432066f4c79af | |
parent | 4fe92225a5024052f095e9e24dce9242a5ad3007 (diff) | |
download | hikey-linaro-bad6c993d9ebd088c16f3249e4c8bc2af1d1fc7e.tar.gz |
UPSTREAM: ARM: domains: add memory dependencies to get_domain/set_domain
We need to have memory dependencies on get_domain/set_domain to avoid
the compiler over-optimising these inline assembly instructions.
Loads/stores must not be reordered across a set_domain(), so introduce
a compiler barrier for that assembly.
The value of get_domain() must not be cached across a set_domain(), but
we still want to allow the compiler to optimise it away. Introduce a
dependency on current_thread_info()->cpu_domain to avoid this; the new
memory clobber in set_domain() should therefore cause the compiler to
re-load this. The other advantage of using this is we should have its
address in the register set already, or very soon after at most call
sites.
Tested-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Bug: 25672827
Patchset: PAN emulation
(cherry picked from commit 6e8f580d1fcc18e290713984c379cb97131c015a)
Signed-off-by: Kees Cook <keescook@google.com>
Change-Id: I44021c2e0af72a2f20bab4d5af7d67d20ca0a211
-rw-r--r-- | arch/arm/include/asm/domain.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h index 2be929549938..bc42d4cb17fe 100644 --- a/arch/arm/include/asm/domain.h +++ b/arch/arm/include/asm/domain.h @@ -12,6 +12,7 @@ #ifndef __ASSEMBLY__ #include <asm/barrier.h> +#include <asm/thread_info.h> #endif /* @@ -71,7 +72,8 @@ static inline unsigned int get_domain(void) asm( "mrc p15, 0, %0, c3, c0 @ get domain" - : "=r" (domain)); + : "=r" (domain) + : "m" (current_thread_info()->cpu_domain)); return domain; } @@ -81,7 +83,7 @@ static inline void set_domain(unsigned val) { asm volatile( "mcr p15, 0, %0, c3, c0 @ set domain" - : : "r" (val)); + : : "r" (val) : "memory"); isb(); } |