svn commit: r364180 - in head/sys/riscv: include riscv
John Baldwin
jhb at FreeBSD.org
Wed Aug 12 20:29:51 UTC 2020
Author: jhb
Date: Wed Aug 12 20:29:49 2020
New Revision: 364180
URL: https://svnweb.freebsd.org/changeset/base/364180
Log:
Use uintptr_t instead of uint64_t for pointers in stack frames.
Reviewed by: mhorne
Obtained from: CheriBSD
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D25995
Modified:
head/sys/riscv/include/stack.h
head/sys/riscv/riscv/db_trace.c
head/sys/riscv/riscv/stack_machdep.c
head/sys/riscv/riscv/unwind.c
Modified: head/sys/riscv/include/stack.h
==============================================================================
--- head/sys/riscv/include/stack.h Wed Aug 12 20:05:43 2020 (r364179)
+++ head/sys/riscv/include/stack.h Wed Aug 12 20:29:49 2020 (r364180)
@@ -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 *);
Modified: head/sys/riscv/riscv/db_trace.c
==============================================================================
--- head/sys/riscv/riscv/db_trace.c Wed Aug 12 20:05:43 2020 (r364179)
+++ head/sys/riscv/riscv/db_trace.c Wed Aug 12 20:29:49 2020 (r364180)
@@ -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);
}
Modified: head/sys/riscv/riscv/stack_machdep.c
==============================================================================
--- head/sys/riscv/riscv/stack_machdep.c Wed Aug 12 20:05:43 2020 (r364179)
+++ head/sys/riscv/riscv/stack_machdep.c Wed Aug 12 20:29:49 2020 (r364180)
@@ -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);
}
Modified: head/sys/riscv/riscv/unwind.c
==============================================================================
--- head/sys/riscv/riscv/unwind.c Wed Aug 12 20:05:43 2020 (r364179)
+++ head/sys/riscv/riscv/unwind.c Wed Aug 12 20:29:49 2020 (r364180)
@@ -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);
}
More information about the svn-src-head
mailing list