Skip to content

Commit 28f20a1

Browse files
committed
Merge tag 'x86-urgent-2023-08-26' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 fixes from Ingo Molnar: "Fix an FPU invalidation bug on exec(), and fix a performance regression due to a missing setting of X86_FEATURE_OSXSAVE" * tag 'x86-urgent-2023-08-26' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/fpu: Set X86_FEATURE_OSXSAVE feature after enabling OSXSAVE in CR4 x86/fpu: Invalidate FPU state correctly on exec()
2 parents 3b35375 + 2c66ca3 commit 28f20a1

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

arch/x86/kernel/fpu/context.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
* FPU state for a task MUST let the rest of the kernel know that the
2020
* FPU registers are no longer valid for this task.
2121
*
22-
* Either one of these invalidation functions is enough. Invalidate
23-
* a resource you control: CPU if using the CPU for something else
22+
* Invalidate a resource you control: CPU if using the CPU for something else
2423
* (with preemption disabled), FPU for the current task, or a task that
2524
* is prevented from running by the current task.
2625
*/

arch/x86/kernel/fpu/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ static void fpu_reset_fpregs(void)
679679
struct fpu *fpu = &current->thread.fpu;
680680

681681
fpregs_lock();
682-
fpu__drop(fpu);
682+
__fpu_invalidate_fpregs_state(fpu);
683683
/*
684684
* This does not change the actual hardware registers. It just
685685
* resets the memory image and sets TIF_NEED_FPU_LOAD so a

arch/x86/kernel/fpu/xstate.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,13 @@ void __init fpu__init_system_xstate(unsigned int legacy_size)
882882
goto out_disable;
883883
}
884884

885+
/*
886+
* CPU capabilities initialization runs before FPU init. So
887+
* X86_FEATURE_OSXSAVE is not set. Now that XSAVE is completely
888+
* functional, set the feature bit so depending code works.
889+
*/
890+
setup_force_cpu_cap(X86_FEATURE_OSXSAVE);
891+
885892
print_xstate_offset_size();
886893
pr_info("x86/fpu: Enabled xstate features 0x%llx, context size is %d bytes, using '%s' format.\n",
887894
fpu_kernel_cfg.max_features,

0 commit comments

Comments
 (0)