HomeFreeBSD

x86: initialize use_xsave once

Description

x86: initialize use_xsave once

The explanation from https://reviews.freebsd.org/D39637 by stevek:
The "use_xsave" variable is a global and that is only supposed to be
initialized early before scheduling gets started. However, with the way
the ifuncs for "fpusave" and "fpurestore" are implemented, the value
could be changed at runtime when scheduling is active if "use_xsave"
was set to 0 by the tunable. This leaves a window of opportunity where
"use_xsave" gets re-initialized to 1 and a context switch could occur
with a thread that was not set up to be able to use xsave functionality.
This can lead to an "privileged instruction fault".

The fix is to protect "use_xsave" from being initialized more than once.

Reported and reviewed by: stevek
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D39660

Details

Provenance
kibAuthored on Apr 18 2023, 3:50 PM
Differential Revision
D39660: x86: initialize use_xsave once
Parents
rG93ca6ff2958c: umtx: allow to configure minimal timeout (in nanoseconds)
Branches
Unknown
Tags
Unknown