summaryrefslogtreecommitdiffstats
path: root/arch/arm/cpu
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2019-07-16 14:32:34 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2019-08-07 09:41:28 +0200
commit0e284efa85a85e148d6c506763603398d68ba937 (patch)
tree47fa8cc72473008635b19da58ee613bbf22746e0 /arch/arm/cpu
parent3ce644784995c3e5778cca075208e4f72b77cfd5 (diff)
downloadbarebox-0e284efa85a85e148d6c506763603398d68ba937.tar.gz
barebox-0e284efa85a85e148d6c506763603398d68ba937.tar.xz
ARM: access __boot_cpu_mode with a function
__boot_cpu_mode is accessed from barebox_multi_pbl_start() and barebox_single_pbl_start(). These functions may be called at an address different from the address they are linked at. Calculating the address of global variables can yield wrong results when it is done before setup_c() is called. We can't make sure when the address is calculated, OSELAS.Toolchain-2018.12.0 indeed calculates the address after setup_c() is called, but Debian arm-linux-gnueabihf-gcc 8.3.0 does it before setup_c() is called and thus doesn't work. This is solved by accessing __boot_cpu_mode with a wrapper function which we call explicitly after setup_c() is done. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/cpu')
-rw-r--r--arch/arm/cpu/common.c8
-rw-r--r--arch/arm/cpu/sm.c4
-rw-r--r--arch/arm/cpu/start-pbl.c2
-rw-r--r--arch/arm/cpu/uncompress.c2
4 files changed, 12 insertions, 4 deletions
diff --git a/arch/arm/cpu/common.c b/arch/arm/cpu/common.c
index 4a2b6734db..4d957da1dc 100644
--- a/arch/arm/cpu/common.c
+++ b/arch/arm/cpu/common.c
@@ -23,6 +23,7 @@
#include <asm/barebox-arm.h>
#include <asm/barebox-arm-head.h>
#include <asm-generic/memory_layout.h>
+#include <asm/secure.h>
#include <asm/sections.h>
#include <asm/cache.h>
#include <debug_ll.h>
@@ -147,3 +148,10 @@ int __pure cpu_architecture(void)
return __cpu_architecture;
}
#endif
+
+extern int __boot_cpu_mode;
+
+int boot_cpu_mode(void)
+{
+ return __boot_cpu_mode;
+}
diff --git a/arch/arm/cpu/sm.c b/arch/arm/cpu/sm.c
index b7a9eae89b..1f2c236d5a 100644
--- a/arch/arm/cpu/sm.c
+++ b/arch/arm/cpu/sm.c
@@ -157,7 +157,7 @@ int armv7_secure_monitor_install(void)
return -EINVAL;
}
- if (__boot_cpu_mode == HYP_MODE)
+ if (boot_cpu_mode() == HYP_MODE)
return 0;
mmuon = get_cr() & CR_M;
@@ -235,7 +235,7 @@ static int sm_init(void)
bootm_secure_state_names,
ARRAY_SIZE(bootm_secure_state_names));
- if (__boot_cpu_mode == HYP_MODE)
+ if (boot_cpu_mode() == HYP_MODE)
bootm_secure_state = ARM_STATE_HYP;
return 0;
diff --git a/arch/arm/cpu/start-pbl.c b/arch/arm/cpu/start-pbl.c
index f5c7cfec19..796239d902 100644
--- a/arch/arm/cpu/start-pbl.c
+++ b/arch/arm/cpu/start-pbl.c
@@ -102,7 +102,7 @@ __noreturn void barebox_single_pbl_start(unsigned long membase,
else
barebox = (void *)barebox_base;
- if (IS_ENABLED(CONFIG_CPU_V7) && __boot_cpu_mode == HYP_MODE)
+ if (IS_ENABLED(CONFIG_CPU_V7) && boot_cpu_mode() == HYP_MODE)
armv7_switch_to_hyp();
barebox(membase, memsize, boarddata);
diff --git a/arch/arm/cpu/uncompress.c b/arch/arm/cpu/uncompress.c
index c7851c5c75..4f16af22f8 100644
--- a/arch/arm/cpu/uncompress.c
+++ b/arch/arm/cpu/uncompress.c
@@ -103,7 +103,7 @@ void __noreturn barebox_multi_pbl_start(unsigned long membase,
pr_debug("jumping to uncompressed image at 0x%p\n", barebox);
- if (IS_ENABLED(CONFIG_CPU_V7) && __boot_cpu_mode == HYP_MODE)
+ if (IS_ENABLED(CONFIG_CPU_V7) && boot_cpu_mode() == HYP_MODE)
armv7_switch_to_hyp();
barebox(membase, memsize, boarddata);