summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorskrll <skrll@NetBSD.org>2023-06-23 12:11:22 +0000
committerskrll <skrll@NetBSD.org>2023-06-23 12:11:22 +0000
commit0c13494198dc867c4fe90802a0bc3a7ca6fb18cd (patch)
tree80bd21076931e89304b27a99c6c6360a4fdd2535 /sys/arch
parent790814e76df3a6cd53903a641b2d6477b3138452 (diff)
Pad the trapframe so it's a multiple of 16 bytes so that when a trapframe
is created on the stack SP remains 16-byte aligned as per the ABI requirements. Patch from Rin with some updates from me.
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/riscv/include/frame.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/sys/arch/riscv/include/frame.h b/sys/arch/riscv/include/frame.h
index c847fc61fee..0080c7c7058 100644
--- a/sys/arch/riscv/include/frame.h
+++ b/sys/arch/riscv/include/frame.h
@@ -1,4 +1,4 @@
-/* $NetBSD: frame.h,v 1.5 2023/05/07 12:41:48 skrll Exp $ */
+/* $NetBSD: frame.h,v 1.6 2023/06/23 12:11:22 skrll Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -39,6 +39,7 @@ struct trapframe {
register_t tf_tval; // supervisor trap value
register_t tf_cause; // supervisor cause register
register_t tf_sr; // supervisor status register
+ register_t tf_pad; // For 16-byte alignment
#define tf_reg tf_regs.r_reg
#define tf_pc tf_regs.r_pc
#define tf_ra tf_reg[_X_RA]
@@ -74,6 +75,12 @@ struct trapframe {
#define tf_t6 tf_reg[_X_T6]
};
+/*
+ * Ensure the trapframe is a multiple of 16bytes so that stack
+ * alignment is preserved.
+ */
+__CTASSERT((sizeof(struct trapframe) & (16 - 1)) == 0);
+
#ifdef _LP64
// For COMPAT_NETBSD32 coredumps
struct trapframe32 {
@@ -81,11 +88,11 @@ struct trapframe32 {
register32_t tf_tval;
register32_t tf_cause;
register32_t tf_sr;
+ register32_t tf_pad;
};
#endif
-
#define lwp_trapframe(l) ((l)->l_md.md_utf)