Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARM: Align stack pointer to support SCTLR_EL1.SA0 #495

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions runtime/libia2/include/ia2_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,12 @@ asm(".macro movz_shifted_tag_x18 tag\n"
"mov x9, sp\n" \
/* switch to newly allocated stack */ \
"mov sp, %0\n" \
/* push old stack pointer to new stack */ \
"str x9, [sp], #-8\n" \
/* push the stack pointer in x9 and a dummy reg to new stack */ \
"stp x9, x10, [sp, #-16]!\n" \
/* initialize TLS */ \
"bl init_tls_" #i "\n" \
/* pop old stack pointer from new stack */ \
"ldr x9, [sp, #8]!\n" \
"ldp x9, x10, [sp], #16\n" \
/* save pointer to new stack */ \
"mov x10, sp\n" \
/* switch to old stack */ \
Expand Down
7 changes: 5 additions & 2 deletions runtime/libia2/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@ char *allocate_stack(int i) {
exit(-1);
}
}
#ifdef __aarch64__
#if defined(__aarch64__)
/* Tag the allocated stack pointer so it is accessed with the right pkey */
stack = (char *)((uint64_t)stack | (uint64_t)i << 56);
#endif
// TODO: can we do this on x86 too?
return stack + STACK_SIZE - 16;
#else
/* Each stack frame start + 8 is initially 16-byte aligned. */
return stack + STACK_SIZE - 8;
#endif
}

void allocate_stack_0() {
Expand Down
Loading