Squashed 'third_party/marl/' changes from f4255c213b..13e0eb5222
13e0eb5222 Untag memory used for stack
git-subtree-dir: third_party/marl
git-subtree-split: 13e0eb5222d9ffc7f56f57b1fe8c21db260d6f9c
Change-Id: I27a723a4b9bfa528337145961c556f7b90d59380
diff --git a/src/osfiber_aarch64.c b/src/osfiber_aarch64.c
index cc61ae7..536fab9 100644
--- a/src/osfiber_aarch64.c
+++ b/src/osfiber_aarch64.c
@@ -14,6 +14,8 @@
#if defined(__aarch64__)
+#include <stddef.h>
+
#include "osfiber_asm_aarch64.h"
#include "marl/export.h"
@@ -23,12 +25,23 @@
target(arg);
}
+// This is needed for HWSAan runtimes that don't have this commit:
+// https://reviews.llvm.org/D149228.
+__attribute__((weak)) void __hwasan_tag_memory(const volatile void *p,
+ unsigned char tag, size_t size);
+__attribute((weak)) void *__hwasan_tag_pointer(const volatile void *p,
+ unsigned char tag);
+
MARL_EXPORT
void marl_fiber_set_target(struct marl_fiber_context* ctx,
void* stack,
uint32_t stack_size,
void (*target)(void*),
void* arg) {
+ if (__hwasan_tag_memory && __hwasan_tag_pointer) {
+ stack = __hwasan_tag_pointer(stack, 0);
+ __hwasan_tag_memory(stack, 0, stack_size);
+ }
uintptr_t* stack_top = (uintptr_t*)((uint8_t*)(stack) + stack_size);
ctx->LR = (uintptr_t)&marl_fiber_trampoline;
ctx->r0 = (uintptr_t)target;