Changeset View
Changeset View
Standalone View
Standalone View
sys/arm64/arm64/stack_machdep.c
Show All 35 Lines | |||||
#include <sys/mutex.h> | #include <sys/mutex.h> | ||||
#include <sys/proc.h> | #include <sys/proc.h> | ||||
#include <sys/stack.h> | #include <sys/stack.h> | ||||
#include <machine/vmparam.h> | #include <machine/vmparam.h> | ||||
#include <machine/pcb.h> | #include <machine/pcb.h> | ||||
#include <machine/stack.h> | #include <machine/stack.h> | ||||
static void | static void __nosanitizeaddress | ||||
stack_capture(struct thread *td, struct stack *st, struct unwind_state *frame) | stack_capture(struct thread *td, struct stack *st, struct unwind_state *frame) | ||||
{ | { | ||||
stack_zero(st); | stack_zero(st); | ||||
while (1) { | while (1) { | ||||
if (!unwind_frame(td, frame)) | if (!unwind_frame(td, frame)) | ||||
break; | break; | ||||
if (!INKERNEL((vm_offset_t)frame->pc)) | if (!INKERNEL((vm_offset_t)frame->pc)) | ||||
break; | break; | ||||
if (stack_put(st, frame->pc) == -1) | if (stack_put(st, frame->pc) == -1) | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
int | int __nosanitizeaddress | ||||
markj: Do we really need this annotation anywhere except stack_capture()? | |||||
kevansAuthorUnsubmitted Done Inline ActionsWe discussed this a bit OOB and I removed the annotation from all three of these, as stack_save_td() doesn't support capturing a running thread. I may add back in a comment to note that x86 prevents KASAN/KMSAN there potentially due to inconsistencies arising from that scenario, but it's unclear if there's any plan/desire to change this. kevans: We discussed this a bit OOB and I removed the annotation from all three of these, as… | |||||
stack_save_td(struct stack *st, struct thread *td) | stack_save_td(struct stack *st, struct thread *td) | ||||
{ | { | ||||
struct unwind_state frame; | struct unwind_state frame; | ||||
THREAD_LOCK_ASSERT(td, MA_OWNED); | THREAD_LOCK_ASSERT(td, MA_OWNED); | ||||
KASSERT(!TD_IS_SWAPPED(td), | KASSERT(!TD_IS_SWAPPED(td), | ||||
("stack_save_td: thread %p is swapped", td)); | ("stack_save_td: thread %p is swapped", td)); | ||||
if (TD_IS_RUNNING(td)) | if (TD_IS_RUNNING(td)) | ||||
return (EOPNOTSUPP); | return (EOPNOTSUPP); | ||||
frame.fp = td->td_pcb->pcb_x[29]; | frame.fp = td->td_pcb->pcb_x[29]; | ||||
frame.pc = ADDR_MAKE_CANONICAL(td->td_pcb->pcb_lr); | frame.pc = ADDR_MAKE_CANONICAL(td->td_pcb->pcb_lr); | ||||
stack_capture(td, st, &frame); | stack_capture(td, st, &frame); | ||||
return (0); | return (0); | ||||
} | } | ||||
void | void __nosanitizeaddress | ||||
stack_save(struct stack *st) | stack_save(struct stack *st) | ||||
{ | { | ||||
struct unwind_state frame; | struct unwind_state frame; | ||||
frame.fp = (uintptr_t)__builtin_frame_address(0); | frame.fp = (uintptr_t)__builtin_frame_address(0); | ||||
frame.pc = (uintptr_t)stack_save; | frame.pc = (uintptr_t)stack_save; | ||||
stack_capture(curthread, st, &frame); | stack_capture(curthread, st, &frame); | ||||
} | } |
Do we really need this annotation anywhere except stack_capture()?