Page MenuHomeFreeBSD

arm64: write PID in CONTEXTIDR_EL1 on ctx switch
Needs ReviewPublic

Authored by zachary.leaf_arm.com on Jul 31 2024, 10:11 AM.
Tags
None
Referenced Files
F95437025: D46192.id143236.diff
Fri, Sep 20, 8:27 PM
F95394335: D46192.id143236.diff
Fri, Sep 20, 2:54 PM
Unknown Object (File)
Thu, Sep 19, 9:25 AM
Unknown Object (File)
Tue, Sep 17, 6:05 AM
Unknown Object (File)
Tue, Sep 17, 4:01 AM
Unknown Object (File)
Mon, Sep 9, 4:16 PM
Unknown Object (File)
Mon, Sep 9, 1:02 AM
Unknown Object (File)
Sun, Sep 8, 8:20 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 59140
Build 56027: 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.Wed, Aug 28, 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.