Page MenuHomeFreeBSD

linuxkpi: Call `lkpi_fpu_safe_exec()` in the implementation of kvmalloc()
ClosedPublic

Authored by dumbbell on Jul 26 2025, 12:39 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Oct 10, 12:02 AM
Unknown Object (File)
Fri, Oct 10, 12:01 AM
Unknown Object (File)
Fri, Oct 10, 12:01 AM
Unknown Object (File)
Thu, Oct 9, 8:06 PM
Unknown Object (File)
Sat, Oct 4, 4:51 PM
Unknown Object (File)
Fri, Oct 3, 5:44 PM
Unknown Object (File)
Fri, Oct 3, 3:15 PM
Unknown Object (File)
Thu, Oct 2, 8:41 AM
Subscribers

Details

Summary

kvmalloc() was a simple wrapper around the FreeBSD native malloc(). Unlike the more involved implementation of kmalloc(), it didn't end and being the FPU context around the actual call to malloc().

This caused the following panic in the amdgup DRM driver:

panic: malloc: called with spinlock or critical section held

... triggered by the call:

struct dc_3dlut *lut = kvzalloc(sizeof(*lut), GFP_KERNEL);

(for the record, GFP_KERNEL is defined as M_WAITOK)

Replicating the same behaviour as kmalloc(), in other words, ending the FPU context before the call to the underlying malloc(), and beginning it again afterwards solves the problem.

Sponsored by: The FreeBSD Foundation.

Diff Detail

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