From 43fdbab20fc47df3ecb6443fa24f933a6108b6a9 Mon Sep 17 00:00:00 2001 From: Ayrton Munoz Date: Tue, 12 Nov 2024 10:31:23 -0500 Subject: [PATCH] libia2: WIP stack alignment --- runtime/libia2/threads.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/runtime/libia2/threads.c b/runtime/libia2/threads.c index 0e6327b06..cd595df7b 100644 --- a/runtime/libia2/threads.c +++ b/runtime/libia2/threads.c @@ -62,7 +62,6 @@ void *ia2_thread_begin(void *arg) { : [fn] "r"(fn), [data] "r"(data), [new_sp_addr] "r"(new_sp_addr) : "rdi"); #elif defined(__aarch64__) -#warning "ia2_thread_begin does not align the stack correctly" __asm__ volatile( // Copy stack pointer to x10 "mov x10, sp\n" @@ -71,6 +70,12 @@ void *ia2_thread_begin(void *arg) { "mov sp, x0\n" // Push the old stack pointer "str x10, [sp, #-8]!\n" + // Align the stack + //"movn x10, #0x000f\n" + //"and sp, sp, x10, #0\n" + // Prologue (necessary?) + //"str x29, [sp, #-8]!\n" + //"mov x29, sp\n" // Load argument "ldr x0, [%[data]]\n" // Call fn(data) @@ -84,6 +89,8 @@ void *ia2_thread_begin(void *arg) { : [result] "=r"(result) : [fn] "r"(fn), [data] "r"(&data), [new_sp_addr] "r"(new_sp_addr) : "x0", "x10"); +#else +#error "unknown architecture" #endif /* clang-format on */