Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F171838204
D59647.id186632.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D59647.id186632.diff
View Options
diff --git a/sys/conf/ldscript.riscv b/sys/conf/ldscript.riscv
--- a/sys/conf/ldscript.riscv
+++ b/sys/conf/ldscript.riscv
@@ -32,6 +32,7 @@
*(.note.gnu.build-id)
PROVIDE (__build_id_end = .);
}
+ .eh_frame : { KEEP (*(.eh_frame)) }
.rel.text :
{ *(.rel.text) *(.rel.gnu.linkonce.t*) }
.rela.text :
diff --git a/sys/riscv/include/asm.h b/sys/riscv/include/asm.h
--- a/sys/riscv/include/asm.h
+++ b/sys/riscv/include/asm.h
@@ -45,8 +45,8 @@
#define _C_LABEL(x) x
#define ENTRY(sym) \
- .text; .globl sym; .type sym,@function; .align 4; sym: .cfi_startproc;
-#define END(sym) .cfi_endproc; .size sym, . - sym
+ .text; .globl sym; .type sym,@function; .align 4; sym:
+#define END(sym) .size sym, . - sym
#define EENTRY(sym) \
.globl sym; sym:
diff --git a/sys/riscv/include/frame.h b/sys/riscv/include/frame.h
--- a/sys/riscv/include/frame.h
+++ b/sys/riscv/include/frame.h
@@ -41,7 +41,8 @@
#include <sys/ucontext.h>
/*
- * NOTE: keep this structure in sync with struct reg and struct mcontext.
+ * NOTE: keep this structure in sync with struct reg, struct mcontext, and the
+ * trap frame CFI information.
*/
struct trapframe {
uint64_t tf_ra;
diff --git a/sys/riscv/include/trap_cfi.h b/sys/riscv/include/trap_cfi.h
new file mode 100644
--- /dev/null
+++ b/sys/riscv/include/trap_cfi.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2026 FreeBSD Foundation
+ *
+ * This software was developed by Minsoo Choo under sponsorship from the
+ * FreeBSD Foundation.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#ifndef _MACHINE_TRAP_CFI_H_
+#define _MACHINE_TRAP_CFI_H_
+
+#include "assym.inc"
+
+ .cfi_sections .eh_frame
+
+/* DWARF register 64 is the RISC-V alternate frame return column. */
+#define CFI_RA_COLUMN 64
+#define CFI_TF_SIZE (TF_SCAUSE + 8)
+
+.macro trap_cfi_entry name, state=empty
+ .cfi_startproc
+ .cfi_signal_frame
+ .cfi_return_column CFI_RA_COLUMN
+ .cfi_def_cfa sp, 0
+ .cfi_undefined CFI_RA_COLUMN
+.ifc \state,full
+ trap_cfi_full
+.endif
+.ifc \state,terminal
+ .cfi_def_cfa sp, CFI_TF_SIZE
+.endif
+.endm
+
+.macro trap_cfi_end name
+ .cfi_endproc
+.endm
+
+.macro trap_cfi_saved reg, off
+ .cfi_offset \reg, \off - CFI_TF_SIZE
+.endm
+
+.macro trap_cfi_full
+ .cfi_def_cfa sp, CFI_TF_SIZE
+ .cfi_same_value zero
+ trap_cfi_saved ra, TF_RA
+ trap_cfi_saved sp, TF_SP
+ trap_cfi_saved gp, TF_GP
+ trap_cfi_saved tp, TF_TP
+ trap_cfi_saved t0, TF_T + 0 * 8
+ trap_cfi_saved t1, TF_T + 1 * 8
+ trap_cfi_saved t2, TF_T + 2 * 8
+ trap_cfi_saved t3, TF_T + 3 * 8
+ trap_cfi_saved t4, TF_T + 4 * 8
+ trap_cfi_saved t5, TF_T + 5 * 8
+ trap_cfi_saved t6, TF_T + 6 * 8
+ trap_cfi_saved s0, TF_S + 0 * 8
+ trap_cfi_saved s1, TF_S + 1 * 8
+ trap_cfi_saved s2, TF_S + 2 * 8
+ trap_cfi_saved s3, TF_S + 3 * 8
+ trap_cfi_saved s4, TF_S + 4 * 8
+ trap_cfi_saved s5, TF_S + 5 * 8
+ trap_cfi_saved s6, TF_S + 6 * 8
+ trap_cfi_saved s7, TF_S + 7 * 8
+ trap_cfi_saved s8, TF_S + 8 * 8
+ trap_cfi_saved s9, TF_S + 9 * 8
+ trap_cfi_saved s10, TF_S + 10 * 8
+ trap_cfi_saved s11, TF_S + 11 * 8
+ trap_cfi_saved a0, TF_A + 0 * 8
+ trap_cfi_saved a1, TF_A + 1 * 8
+ trap_cfi_saved a2, TF_A + 2 * 8
+ trap_cfi_saved a3, TF_A + 3 * 8
+ trap_cfi_saved a4, TF_A + 4 * 8
+ trap_cfi_saved a5, TF_A + 5 * 8
+ trap_cfi_saved a6, TF_A + 6 * 8
+ trap_cfi_saved a7, TF_A + 7 * 8
+ .cfi_offset CFI_RA_COLUMN, TF_SEPC - CFI_TF_SIZE
+.endm
+
+#endif /* _MACHINE_TRAP_CFI_H_ */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Sep 14, 11:04 PM (14 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38929766
Default Alt Text
D59647.id186632.diff (3 KB)
Attached To
Mode
D59647: trap_cfi(9): add assembly interface for riscv
Attached
Detach File
Event Timeline
Log In to Comment