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)
Mar 14 2024, 4:59 PM
Unknown Object (File)
Mar 14 2024, 4:59 PM
Unknown Object (File)
Mar 14 2024, 4:59 PM
Unknown Object (File)
Mar 11 2024, 4:39 AM
Unknown Object (File)
Jan 10 2024, 5:08 PM
Unknown Object (File)
Jan 3 2024, 12:32 AM
Unknown Object (File)
Jan 3 2024, 12:32 AM
Unknown Object (File)
Jan 3 2024, 12:19 AM
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.