summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2021-10-05 13:36:13 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2021-10-05 13:51:51 +0200
commitd53f454e588899cd7331b3bc8d272c6aa2ad916d (patch)
treec112997427cd2ad3f660a5a7a702278a1c58718e /commands
parente7bc380ca1e6620488184c45f07bd9eb40fd1bc5 (diff)
downloadbarebox-d53f454e588899cd7331b3bc8d272c6aa2ad916d.tar.gz
barebox-d53f454e588899cd7331b3bc8d272c6aa2ad916d.tar.xz
commands: smc: disable -c (start cpu) test option for ARMv8
This option is meant for debugging and was only tested on an ARMv7 CPU. On ARMv8, the handshake times out and the code executing on the second CPU invokes undefined behavior by modifying the stack base from a non- naked function. This led so far to a warning, which went unnoticed, but a follow-up commit will make it an error to use arm_setup_stack on ARM64. Prepare for this by disabling -c usage on ARM64. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211005113613.3609-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands')
-rw-r--r--commands/smc.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/commands/smc.c b/commands/smc.c
index 2a53e1b647..3143065582 100644
--- a/commands/smc.c
+++ b/commands/smc.c
@@ -9,14 +9,15 @@
#include <asm/psci.h>
#include <asm/secure.h>
+#include <asm/barebox-arm.h>
#include <linux/arm-smccc.h>
-#define STACK_SIZE 100
+#define HANDSHAKE_STACK_SIZE 100
#define HANDSHAKE_MAGIC 0xBA12EB0C
#define ERROR_MAGIC 0xDEADBEEF
struct cpu_context {
- unsigned long stack[STACK_SIZE];
+ unsigned long stack[HANDSHAKE_STACK_SIZE];
long handshake;
};
@@ -35,12 +36,12 @@ static void noinline cpu_handshake(long *handshake)
;
}
-static void __naked second_entry(unsigned long arg0)
+static void NAKED second_entry(unsigned long arg0)
{
struct cpu_context *context = (void*)arg0;
arm_cpu_lowlevel_init();
- arm_setup_stack((unsigned long)&context->stack[STACK_SIZE]);
+ arm_setup_stack((unsigned long)&context->stack[HANDSHAKE_STACK_SIZE]);
barrier();
cpu_handshake(&context->handshake);
@@ -110,6 +111,11 @@ static int do_smc(int argc, char *argv[])
printf("found psci version %ld.%ld\n", res.a0 >> 16, res.a0 & 0xffff);
break;
case 'c':
+ if (IS_ENABLED(CONFIG_CPU_64)) {
+ printf("CPU bootstrap test not supported for ARMv8\n");
+ return COMMAND_ERROR;
+ }
+
if (!context)
context = dma_alloc_coherent(sizeof(*context),
DMA_ADDRESS_BROKEN);