Page MenuHomeFreeBSD

hwpmc: simplify arm64 kernel stack unwinding
ClosedPublic

Authored by mhorne on May 2 2023, 3:03 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Oct 2, 9:36 AM
Unknown Object (File)
Wed, Oct 2, 1:39 AM
Unknown Object (File)
Tue, Oct 1, 10:26 PM
Unknown Object (File)
Mon, Sep 30, 9:08 AM
Unknown Object (File)
Sun, Sep 29, 4:04 PM
Unknown Object (File)
Thu, Sep 26, 8:07 PM
Unknown Object (File)
Wed, Sep 25, 3:37 PM
Unknown Object (File)
Tue, Sep 24, 3:32 AM
Subscribers

Details

Summary

Use the unwind_frame() function, which properly validates the frame
pointer and uses ADDR_MAKE_CANONICAL() for the pc, required when PAC is
enabled.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

mhorne requested review of this revision.May 2 2023, 3:03 PM

FYI, locally I have a STACK_FOREACH() addition to the stack(9) KPI which would give us an MI way to loop through the list of PC addresses after a call to stack_save(). Possibly this can be used to simplify this or other cases further, at a small cost.

It is still half-baked, and not something I plan to tackle immediately.

This revision is now accepted and ready to land.May 2 2023, 5:48 PM
sys/dev/hwpmc/hwpmc_arm64_md.c
91

unwind_frame() doesn't check whether the returned PC is in the kernel, so this represents a behaviour change.

Add back the check for PMC_IN_KERNEL(pc).

This revision now requires review to proceed.May 3 2023, 3:03 PM
mhorne added inline comments.
sys/dev/hwpmc/hwpmc_arm64_md.c
91

Thank you, great catch.

This revision is now accepted and ready to land.May 3 2023, 5:30 PM
This revision was automatically updated to reflect the committed changes.
mhorne marked an inline comment as done.