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
Unknown Object (File)
Thu, Nov 7, 10:38 AM
Unknown Object (File)
Wed, Nov 6, 11:40 PM
Unknown Object (File)
Wed, Nov 6, 9:49 AM
Unknown Object (File)
Sun, Oct 20, 11:49 PM
Unknown Object (File)
Sun, Oct 20, 11:48 PM
Unknown Object (File)
Sun, Oct 20, 11:48 PM
Unknown Object (File)
Sun, Oct 20, 6:17 PM
Unknown Object (File)
Sun, Oct 20, 6:17 PM
Subscribers

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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.