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
F106343783: D46192.id142341.diff
Sun, Dec 29, 12:57 AM
F106264579: D46192.diff
Sat, Dec 28, 4:52 AM
Unknown Object (File)
Fri, Dec 27, 2:41 AM
Unknown Object (File)
Mon, Dec 23, 7:24 AM
Unknown Object (File)
Sun, Dec 22, 6:59 AM
Unknown Object (File)
Nov 20 2024, 6:06 PM
Unknown Object (File)
Nov 19 2024, 11:55 AM
Unknown Object (File)
Nov 17 2024, 6:57 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.Oct 17 2024, 10:06 AM