[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 12/14] bsd-user: Define TARGET_SIGSTACK_ALIGN and use it to round
From: |
Warner Losh |
Subject: |
[PULL 12/14] bsd-user: Define TARGET_SIGSTACK_ALIGN and use it to round stack |
Date: |
Tue, 23 Jul 2024 12:07:23 -0600 |
Most (all?) targets require stacks to be properly aligned. Rather than a
series of ifdefs in bsd-user/signal.h, instead use a manditory #define
for all architectures.
Signed-off-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
bsd-user/aarch64/target_arch_signal.h | 2 ++
bsd-user/arm/target_arch_signal.h | 2 ++
bsd-user/i386/target_arch_signal.h | 2 ++
bsd-user/signal.c | 9 +--------
bsd-user/x86_64/target_arch_signal.h | 2 ++
5 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/bsd-user/aarch64/target_arch_signal.h
b/bsd-user/aarch64/target_arch_signal.h
index bff752a67ab..b72ba7aa504 100644
--- a/bsd-user/aarch64/target_arch_signal.h
+++ b/bsd-user/aarch64/target_arch_signal.h
@@ -77,4 +77,6 @@ struct target_sigframe {
target_ucontext_t sf_uc; /* saved ucontext */
};
+#define TARGET_SIGSTACK_ALIGN 16
+
#endif /* TARGET_ARCH_SIGNAL_H */
diff --git a/bsd-user/arm/target_arch_signal.h
b/bsd-user/arm/target_arch_signal.h
index 02b2b33e07a..10f96b8bfc9 100644
--- a/bsd-user/arm/target_arch_signal.h
+++ b/bsd-user/arm/target_arch_signal.h
@@ -86,4 +86,6 @@ struct target_sigframe {
target_mcontext_vfp_t sf_vfp; /* actual saved VFP context */
};
+#define TARGET_SIGSTACK_ALIGN 8
+
#endif /* TARGET_ARCH_SIGNAL_H */
diff --git a/bsd-user/i386/target_arch_signal.h
b/bsd-user/i386/target_arch_signal.h
index 279dadc22c7..2c14153ab6b 100644
--- a/bsd-user/i386/target_arch_signal.h
+++ b/bsd-user/i386/target_arch_signal.h
@@ -88,4 +88,6 @@ struct target_sigframe {
uint32_t __spare__[2];
};
+#define TARGET_SIGSTACK_ALIGN 8
+
#endif /* TARGET_ARCH_SIGNAL_H */
diff --git a/bsd-user/signal.c b/bsd-user/signal.c
index 8b6654b91da..da49b9bffc1 100644
--- a/bsd-user/signal.c
+++ b/bsd-user/signal.c
@@ -728,14 +728,7 @@ static inline abi_ulong get_sigframe(struct
target_sigaction *ka,
sp = ts->sigaltstack_used.ss_sp + ts->sigaltstack_used.ss_size;
}
-/* TODO: make this a target_arch function / define */
-#if defined(TARGET_ARM)
- return (sp - frame_size) & ~7;
-#elif defined(TARGET_AARCH64)
- return (sp - frame_size) & ~15;
-#else
- return sp - frame_size;
-#endif
+ return ROUND_DOWN(sp - frame_size, TARGET_SIGSTACK_ALIGN);
}
/* compare to $M/$M/exec_machdep.c sendsig and sys/kern/kern_sig.c sigexit */
diff --git a/bsd-user/x86_64/target_arch_signal.h
b/bsd-user/x86_64/target_arch_signal.h
index ca24bf1e7f7..f833ee66cef 100644
--- a/bsd-user/x86_64/target_arch_signal.h
+++ b/bsd-user/x86_64/target_arch_signal.h
@@ -97,4 +97,6 @@ struct target_sigframe {
uint32_t __spare__[2];
};
+#define TARGET_SIGSTACK_ALIGN 16
+
#endif /* TARGET_ARCH_SIGNAL_H */
--
2.45.1
- [PULL 00/14] Bsd user for 9.1 patches, Warner Losh, 2024/07/23
- [PULL 02/14] bsd-user:Add AArch64 register handling and related functions, Warner Losh, 2024/07/23
- [PULL 01/14] bsd-user:Add CPU initialization and management functions, Warner Losh, 2024/07/23
- [PULL 05/14] bsd-user:Add get_mcontext function for ARM AArch64, Warner Losh, 2024/07/23
- [PULL 03/14] bsd-user:Add ARM AArch64 support and capabilities, Warner Losh, 2024/07/23
- [PULL 04/14] bsd-user:Add ARM AArch64 signal handling support, Warner Losh, 2024/07/23
- [PULL 14/14] bsd-user: Add aarch64 build to tree, Warner Losh, 2024/07/23
- [PULL 10/14] bsd-user: Hard wire aarch64 to be 4k pages only, Warner Losh, 2024/07/23
- [PULL 06/14] bsd-user:Add setup_sigframe_arch function for ARM AArch64, Warner Losh, 2024/07/23
- [PULL 07/14] bsd-user:Add set_mcontext function for ARM AArch64, Warner Losh, 2024/07/23
- [PULL 12/14] bsd-user: Define TARGET_SIGSTACK_ALIGN and use it to round stack,
Warner Losh <=
- [PULL 13/14] bsd-user: Make compile for non-linux user-mode stuff, Warner Losh, 2024/07/23
- [PULL 09/14] bsd-user: Simplify the implementation of execve, Warner Losh, 2024/07/23
- [PULL 08/14] bsd-user:Add AArch64 improvements and signal handling functions, Warner Losh, 2024/07/23
- [PULL 11/14] bsd-user: Sync fork_start/fork_end with linux-user, Warner Losh, 2024/07/23
- Re: [PULL 00/14] Bsd user for 9.1 patches, Richard Henderson, 2024/07/24