Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1222667

[PATCH 2/2] ARM: domains: add memory dependencies to get_domain/set_domain

From Russell King <rmk+kernel@arm.linux.org.uk>
Newsgroups linux.kernel
Subject [PATCH 2/2] ARM: domains: add memory dependencies to get_domain/set_domain
Date 2015-09-11 12:00 +0200
Message-ID <q7thD-6pR-11@gated-at.bofh.it> (permalink)
References <q7thD-6pR-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 arch/arm/include/asm/domain.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h
index e878129f2fee..fc8ba1663601 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
 
 /*
@@ -89,7 +90,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;
 }
@@ -98,7 +100,7 @@ static inline void set_domain(unsigned val)
 {
 	asm volatile(
 	"mcr	p15, 0, %0, c3, c0	@ set domain"
-	  : : "r" (val));
+	  : : "r" (val) : "memory");
 	isb();
 }
 
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH] ARM: fix alignement of __bug_table section entries Robert Jarzmik <robert.jarzmik@free.fr> - 2015-09-08 19:10 +0200
  Re: [PATCH] ARM: fix alignement of __bug_table section entries Russell King - ARM Linux <linux@arm.linux.org.uk> - 2015-09-08 22:10 +0200
    Re: [PATCH] ARM: fix alignement of __bug_table section entries Robert Jarzmik <robert.jarzmik@free.fr> - 2015-09-08 23:00 +0200
    Re: [PATCH] ARM: fix alignement of __bug_table section entries Robert Jarzmik <robert.jarzmik@free.fr> - 2015-09-10 01:20 +0200
      Re: [PATCH] ARM: fix alignement of __bug_table section entries Robert Jarzmik <robert.jarzmik@free.fr> - 2015-09-10 21:10 +0200
        Re: [PATCH] ARM: fix alignement of __bug_table section entries Russell King - ARM Linux <linux@arm.linux.org.uk> - 2015-09-10 21:20 +0200
          Re: [PATCH] ARM: fix alignement of __bug_table section entries Robert Jarzmik <robert.jarzmik@free.fr> - 2015-09-10 23:00 +0200
            Re: [PATCH] ARM: fix alignement of __bug_table section entries Russell King - ARM Linux <linux@arm.linux.org.uk> - 2015-09-11 12:00 +0200
              [PATCH 2/2] ARM: domains: add memory dependencies to  get_domain/set_domain Russell King <rmk+kernel@arm.linux.org.uk> - 2015-09-11 12:00 +0200
                Re: [PATCH 2/2] ARM: domains: add memory dependencies to get_domain/set_domain Robert Jarzmik <robert.jarzmik@free.fr> - 2015-09-11 17:10 +0200
                Re: [PATCH 2/2] ARM: domains: add memory dependencies to  get_domain/set_domain Russell King - ARM Linux <linux@arm.linux.org.uk> - 2015-09-11 17:20 +0200
                Re: [PATCH 2/2] ARM: domains: add memory dependencies to get_domain/set_domain Robert Jarzmik <robert.jarzmik@free.fr> - 2015-09-11 17:50 +0200
              [PATCH 1/2] ARM: domains: thread_info.h no longer needs asm/domains.h Russell King <rmk+kernel@arm.linux.org.uk> - 2015-09-11 12:00 +0200

csiph-web