Page MenuHomeFreeBSD

armv8_crypto: Switch to using FPU_KERN_NOCTX
ClosedPublic

Authored by jhb on Aug 24 2023, 4:23 PM.
Tags
None
Referenced Files
F96608065: D41578.diff
Wed, Sep 25, 5:26 PM
F96603250: D41578.diff
Wed, Sep 25, 4:47 PM
F96585818: D41578.diff
Wed, Sep 25, 2:56 PM
Unknown Object (File)
Tue, Sep 24, 4:21 PM
Unknown Object (File)
Tue, Sep 24, 11:58 AM
Unknown Object (File)
Tue, Sep 24, 1:20 AM
Unknown Object (File)
Sun, Sep 22, 4:55 AM
Unknown Object (File)
Fri, Sep 20, 8:19 PM
Subscribers

Diff Detail

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

Event Timeline

jhb requested review of this revision.Aug 24 2023, 4:23 PM

commit message should likely contain why this is safe...
I'm guessing because the crypto stuff restores the context and/or doesn't stomp on it in the first place... but I honestly don't know.

In D41578#947698, @imp wrote:

commit message should likely contain why this is safe...
I'm guessing because the crypto stuff restores the context and/or doesn't stomp on it in the first place... but I honestly don't know.

No, the crypto stuff uses the FPU context, that's why fpu_kern_enter is needed. What this does is use FPU_KERN_NOCTX which runs the operations in a critical section to avoid having to use an allocated context to save FPU state in. Instead, with NOCTX fpu_kern_enter initializes the FPU/vector state to a clean initial state and lets the FPU run and then at fpu_kern_leave it disables the FPU discarding the post-operation state and leaves the critical section.

With the current approach, you don't use a critical section while doing the operation, but you are saving the post-op state to ctx for no real reason. Instead, the real side effect is that ctx just provides a place to save the FPU state if we do a context switch during the operation. But there's no compelling need to pass the FPU state from one operation to another.

This revision is now accepted and ready to land.Aug 28 2023, 4:13 PM
This revision was automatically updated to reflect the committed changes.