Skip to content

Commit

Permalink
bsd-user: Define TARGET_SIGSTACK_ALIGN and use it to round stack
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
  • Loading branch information
bsdimp committed Jul 23, 2024
1 parent 5b6828d commit 5fa2a10
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
2 changes: 2 additions & 0 deletions bsd-user/aarch64/target_arch_signal.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,6 @@ struct target_sigframe {
target_ucontext_t sf_uc; /* saved ucontext */
};

#define TARGET_SIGSTACK_ALIGN 16

#endif /* TARGET_ARCH_SIGNAL_H */
2 changes: 2 additions & 0 deletions bsd-user/arm/target_arch_signal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
2 changes: 2 additions & 0 deletions bsd-user/i386/target_arch_signal.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,6 @@ struct target_sigframe {
uint32_t __spare__[2];
};

#define TARGET_SIGSTACK_ALIGN 8

#endif /* TARGET_ARCH_SIGNAL_H */
9 changes: 1 addition & 8 deletions bsd-user/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 2 additions & 0 deletions bsd-user/x86_64/target_arch_signal.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,6 @@ struct target_sigframe {
uint32_t __spare__[2];
};

#define TARGET_SIGSTACK_ALIGN 16

#endif /* TARGET_ARCH_SIGNAL_H */

0 comments on commit 5fa2a10

Please sign in to comment.