aboutsummaryrefslogtreecommitdiff
path: root/include/arch
diff options
context:
space:
mode:
authorAndre Przywara <andre.przywara@arm.com>2020-10-16 18:19:03 +0100
committerAndre Przywara <andre.przywara@arm.com>2020-10-27 16:15:00 +0000
commit2be491b1dc8deae73befd10d137d485c1a41d7f1 (patch)
treec0a630ce20e4caf74fe59362d1c8936e0ecb06d5 /include/arch
parent00ad74c7afe67b2ffaf08300710f18d3dafebb45 (diff)
downloadtrusted-firmware-a-2be491b1dc8deae73befd10d137d485c1a41d7f1.tar.gz
aarch64/arm: Add compiler barrier to barrier instructions
When issuing barrier instructions like DSB or DMB, we must make sure that the compiler does not undermine out efforts to fence off instructions. Currently the compiler is free to move the barrier instruction around, in respect to former or later memory access statements, which is not what we want. Add a compiler barrier to the inline assembly statement in our DEFINE_SYSOP_TYPE_FUNC macro, to make sure memory accesses are not reordered by the compiler. This is in line with Linux' definition: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/include/asm/barrier.h Since those instructions share a definition, apart from DSB and DMB this now also covers some TLBI instructions. Having a compiler barrier there also is useful, although we probably have stronger barriers in place already. Change-Id: If6fe97b13a562643a643efc507cb4aad29daa5b6 Reported-by: Alexandru Elisei <alexandru.elisei@arm.com> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Diffstat (limited to 'include/arch')
-rw-r--r--include/arch/aarch32/arch_helpers.h2
-rw-r--r--include/arch/aarch64/arch_helpers.h2
2 files changed, 2 insertions, 2 deletions
diff --git a/include/arch/aarch32/arch_helpers.h b/include/arch/aarch32/arch_helpers.h
index 94cf7ea9dc..82efb188a4 100644
--- a/include/arch/aarch32/arch_helpers.h
+++ b/include/arch/aarch32/arch_helpers.h
@@ -166,7 +166,7 @@ static inline void _op(void) \
#define DEFINE_SYSOP_TYPE_FUNC(_op, _type) \
static inline void _op ## _type(void) \
{ \
- __asm__ (#_op " " #_type); \
+ __asm__ (#_op " " #_type : : : "memory"); \
}
/* Define function for system instruction with register parameter */
diff --git a/include/arch/aarch64/arch_helpers.h b/include/arch/aarch64/arch_helpers.h
index 1f2f4a9233..5d1bc948c8 100644
--- a/include/arch/aarch64/arch_helpers.h
+++ b/include/arch/aarch64/arch_helpers.h
@@ -80,7 +80,7 @@ static inline void _op(uint64_t v) \
#define DEFINE_SYSOP_TYPE_FUNC(_op, _type) \
static inline void _op ## _type(void) \
{ \
- __asm__ (#_op " " #_type); \
+ __asm__ (#_op " " #_type : : : "memory"); \
}
/* Define function for system instruction with register parameter */