aboutsummaryrefslogtreecommitdiff
path: root/bsd-user
diff options
context:
space:
mode:
authorWarner Losh <imp@bsdimp.com>2024-06-23 15:29:42 -0600
committerWarner Losh <imp@bsdimp.com>2024-07-23 10:56:30 -0600
commit5fa2a10ba6822fc1e500e921dcae344db46e1649 (patch)
tree53a8955280e815b90aee881addd0b245ad0c339e /bsd-user
parent5b6828d194fba3c170a5f717cc1fc3d35645aadd (diff)
downloadqemu-5fa2a10ba6822fc1e500e921dcae344db46e1649.zip
qemu-5fa2a10ba6822fc1e500e921dcae344db46e1649.tar.gz
qemu-5fa2a10ba6822fc1e500e921dcae344db46e1649.tar.bz2
bsd-user: Define TARGET_SIGSTACK_ALIGN and use it to round stack
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>
Diffstat (limited to 'bsd-user')
-rw-r--r--bsd-user/aarch64/target_arch_signal.h2
-rw-r--r--bsd-user/arm/target_arch_signal.h2
-rw-r--r--bsd-user/i386/target_arch_signal.h2
-rw-r--r--bsd-user/signal.c9
-rw-r--r--bsd-user/x86_64/target_arch_signal.h2
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 bff752a..b72ba7a 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 02b2b33..10f96b8 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 279dadc..2c14153 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 8b6654b..da49b9b 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 ca24bf1..f833ee6 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 */