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
Unknown Object (File)
Wed, Nov 20, 6:06 PM
Unknown Object (File)
Tue, Nov 19, 11:55 AM
Unknown Object (File)
Sun, Nov 17, 6:57 PM
Unknown Object (File)
Sat, Nov 16, 12:04 PM
Unknown Object (File)
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)
Oct 17 2024, 10:24 AM
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 Not Applicable
Unit
Tests Not Applicable

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