Page MenuHomeFreeBSD

arm64: write PID in CONTEXTIDR_EL1 on ctx switch
AcceptedPublic

Authored by zachary.leaf_arm.com on Jul 31 2024, 10:11 AM.
Tags
None
Referenced Files
F102355337: D46192.diff
Mon, Nov 11, 3:37 AM
Unknown Object (File)
Thu, Nov 7, 5:05 PM
Unknown Object (File)
Mon, Nov 4, 11:04 PM
Unknown Object (File)
Thu, Oct 17, 10:24 AM
Unknown Object (File)
Tue, Oct 15, 10:27 PM
Unknown Object (File)
Tue, Oct 15, 1:30 PM
Unknown Object (File)
Sun, Oct 13, 7:22 PM
Unknown Object (File)
Oct 11 2024, 9:34 PM
Subscribers

Details

Summary

Debug and trace features such as Statistical Profiling Extension (SPE)
use the CONTEXTIDR_EL1 register to get the PID of the current process.

Add a sysctl switch to toggle writing the current PID into this register
in the thread switcher.

To make use of the feature, the following sysctl switch must be set:

sysctl machdep.pid_in_contextidr=1

Kernel code can also toggle the sysctl by writing directly to the global
var behind the sysctl arm64_pid_in_contextidr:

extern bool arm64_pid_in_contextidr;

Sponsored by: Arm Ltd

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 58895
Build 55782: arc lint + arc unit

Event Timeline

sys/arm64/arm64/swtch.S
59–60

This should save a load

This revision is now accepted and ready to land.Aug 28 2024, 10:54 AM
jrtc27 added a subscriber: jrtc27.
jrtc27 added inline comments.
sys/arm64/arm64/swtch.S
60
63

Presumably ldrw is right as pid_t is negative for errors, but maybe there are cases that matter here where it can be?

  • Use LDRB for bool arm64_pid_in_contextidr
  • Use LDRW for P_PID + add comment
  • Remove \label from pid_in_contextidr macro
  • Change ASSYM(PR_PID... to P_PID
sys/arm64/arm64/swtch.S
63

I think ldrw is correct. I can't see that struct proc->p_pid can ever be negative, only 0 or positive.

This revision is now accepted and ready to land.Thu, Oct 17, 10:06 AM