diff --git a/sys/riscv/include/stack.h b/sys/riscv/include/stack.h index 7f4be068ec27..40183afb9f4d 100644 --- a/sys/riscv/include/stack.h +++ b/sys/riscv/include/stack.h @@ -41,9 +41,9 @@ (va) <= VM_MAX_KERNEL_ADDRESS) struct unwind_state { - uint64_t fp; - uint64_t sp; - uint64_t pc; + uintptr_t fp; + uintptr_t sp; + uintptr_t pc; }; int unwind_frame(struct unwind_state *); diff --git a/sys/riscv/riscv/db_trace.c b/sys/riscv/riscv/db_trace.c index 2a783b2ed0f0..6d7b6b934d43 100644 --- a/sys/riscv/riscv/db_trace.c +++ b/sys/riscv/riscv/db_trace.c @@ -108,9 +108,9 @@ db_stack_trace_cmd(struct unwind_state *frame) db_printf("--- exception %ld, tval = %#lx\n", tf->tf_scause & EXCP_MASK, tf->tf_stval); - frame->sp = (uint64_t)tf->tf_sp; - frame->fp = (uint64_t)tf->tf_s[0]; - frame->pc = (uint64_t)tf->tf_sepc; + frame->sp = tf->tf_sp; + frame->fp = tf->tf_s[0]; + frame->pc = tf->tf_sepc; if (!INKERNEL(frame->fp)) break; continue; @@ -132,9 +132,9 @@ db_trace_thread(struct thread *thr, int count) ctx = kdb_thr_ctx(thr); - frame.sp = (uint64_t)ctx->pcb_sp; - frame.fp = (uint64_t)ctx->pcb_s[0]; - frame.pc = (uint64_t)ctx->pcb_ra; + frame.sp = ctx->pcb_sp; + frame.fp = ctx->pcb_s[0]; + frame.pc = ctx->pcb_ra; db_stack_trace_cmd(&frame); return (0); } @@ -143,12 +143,12 @@ void db_trace_self(void) { struct unwind_state frame; - uint64_t sp; + uintptr_t sp; __asm __volatile("mv %0, sp" : "=&r" (sp)); frame.sp = sp; - frame.fp = (uint64_t)__builtin_frame_address(0); - frame.pc = (uint64_t)db_trace_self; + frame.fp = (uintptr_t)__builtin_frame_address(0); + frame.pc = (uintptr_t)db_trace_self; db_stack_trace_cmd(&frame); } diff --git a/sys/riscv/riscv/stack_machdep.c b/sys/riscv/riscv/stack_machdep.c index 2e016f537f91..0fd88695b512 100644 --- a/sys/riscv/riscv/stack_machdep.c +++ b/sys/riscv/riscv/stack_machdep.c @@ -86,13 +86,13 @@ void stack_save(struct stack *st) { struct unwind_state frame; - uint64_t sp; + uintptr_t sp; __asm __volatile("mv %0, sp" : "=&r" (sp)); frame.sp = sp; - frame.fp = (uint64_t)__builtin_frame_address(0); - frame.pc = (uint64_t)stack_save; + frame.fp = (uintptr_t)__builtin_frame_address(0); + frame.pc = (uintptr_t)stack_save; stack_capture(st, &frame); } diff --git a/sys/riscv/riscv/unwind.c b/sys/riscv/riscv/unwind.c index 18fc1e250c9b..8b0cdeca2903 100644 --- a/sys/riscv/riscv/unwind.c +++ b/sys/riscv/riscv/unwind.c @@ -42,7 +42,7 @@ __FBSDID("$FreeBSD$"); int unwind_frame(struct unwind_state *frame) { - uint64_t fp; + uintptr_t fp; fp = frame->fp; @@ -50,8 +50,8 @@ unwind_frame(struct unwind_state *frame) return (-1); frame->sp = fp; - frame->fp = *(uint64_t *)(fp - 16); - frame->pc = *(uint64_t *)(fp - 8) - 4; + frame->fp = ((uintptr_t *)fp)[-2]; + frame->pc = ((uintptr_t *)fp)[-1] - 4; return (0); }