Re: [PATCH v2] x86/fpu: Put non-enabled dynamic features into init state on sigreturn

From: Chang S. Bae

Date: Wed Dec 02 2026 - 13:12:15 EST


On 11/27/2026 1:00 AM, Daniel Wade wrote:
A dynamic feature not enabled by a task is expected to be in init state
while that task owns the FPU registers. The direct sigreturn path limits
both restore and init masks to fpstate::user_xfeatures. If the task loses
registers inside rt_sigreturn(), another task's tiles can remain there:

A: rt_sigreturn() with AMX permitted, XTILE_DATA not enabled, faults or
is preempted; TIF_NEED_FPU_LOAD is set.
B: runs on the same CPU and leaves nonzero XTILE_DATA in the registers.
A: resumes with XFD set. XRSTOR leaves XTILE_DATA untouched, then
fpregs_mark_activate() marks the registers as A's.
A: first AMX instruction traps. fpstate_realloc() clears XFD without
reloading, so TILESTORED reads B's tile data.

Nit: Vagin's note [*] looks a bit more illustrative to me.

[*]: https://lore.kernel.org/CANaxB-zWf3BkCM8hsd0pXTULHi2ZmpRnLgpp2BFzT=_XwMdRrw@xxxxxxxxxxxxxx

A supplies TILECFG in its signal frame, avoiding LDTILECFG, which would
zero the tile data before TILESTORED.

If the task no longer owns the FPU registers, reset any state its signal
frame did not restore, including XTILE_DATA. Otherwise keep the old mask.

Reviewed-by: Chang S. Bae <chang.seok.bae@xxxxxxxxx>

Thanks,
Chang