|
|
Message-ID: <20251208174940.949856-7-bill.roberts@arm.com>
Date: Mon, 8 Dec 2025 11:44:49 -0600
From: Bill Roberts <bill.roberts@....com>
To: musl@...ts.openwall.com
Cc: Bill Roberts <bill.roberts@....com>
Subject: [RFC 06/14] aarch64: rewrite __unmapself in C using inline asm
Rewrite the AArch64 __unmapself routine from assembly into
C implementations using inline assembly.
This change eliminates the need for handwritten function prologues and
epilogues in __unmapself.s, which simplifies maintenance and allows the compiler
to automatically insert architecture features such as BTI landing pads and
pointer authentication (PAC) sequences where applicable.
Moving to C also enables the compiler to manage register allocation,
stack usage, and ABI compliance automatically while keeping the low-level
behavior (bitmasks and register accesses) explicit and verifiable.
No functional changes intended.
Signed-off-by: Bill Roberts <bill.roberts@....com>
---
src/thread/aarch64/__unmapself.c | 16 ++++++++++++++++
src/thread/aarch64/__unmapself.s | 7 -------
2 files changed, 16 insertions(+), 7 deletions(-)
create mode 100644 src/thread/aarch64/__unmapself.c
delete mode 100644 src/thread/aarch64/__unmapself.s
diff --git a/src/thread/aarch64/__unmapself.c b/src/thread/aarch64/__unmapself.c
new file mode 100644
index 00000000..12639609
--- /dev/null
+++ b/src/thread/aarch64/__unmapself.c
@@ -0,0 +1,16 @@
+#include <stddef.h>
+
+__attribute__((visibility("hidden"), noreturn))
+void __unmapself(void *addr, size_t len)
+{
+ __asm__ volatile(
+ "mov x8, #215\n\t" // SYS_munmap
+ "svc #0\n\t"
+ "mov x8, #93\n\t" // SYS_exit
+ "svc #0\n\t"
+ :
+ :
+ : "x8"
+ );
+ __builtin_unreachable();
+}
diff --git a/src/thread/aarch64/__unmapself.s b/src/thread/aarch64/__unmapself.s
deleted file mode 100644
index 2c5d254f..00000000
--- a/src/thread/aarch64/__unmapself.s
+++ /dev/null
@@ -1,7 +0,0 @@
-.global __unmapself
-.type __unmapself,%function
-__unmapself:
- mov x8,#215 // SYS_munmap
- svc 0
- mov x8,#93 // SYS_exit
- svc 0
--
2.51.0
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.