HomeFreeBSD

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

Description

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

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.

Reviewed by: olce
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D51557

Details

Provenance
dumbbellAuthored on Jul 26 2025, 12:17 PM
Reviewer
olce
Differential Revision
D51557: linuxkpi: Call `lkpi_fpu_safe_exec()` in the implementation of kvmalloc()
Parents
rG3c4b3bab19ca: chroot: Remove always-true checks
Branches
Unknown
Tags
Unknown