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()

Changed files
+9 -3
arch
x86
+1 -2
arch/x86/kernel/fpu/context.h
··· 19 19 * FPU state for a task MUST let the rest of the kernel know that the 20 20 * FPU registers are no longer valid for this task. 21 21 * 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 24 23 * (with preemption disabled), FPU for the current task, or a task that 25 24 * is prevented from running by the current task. 26 25 */
+1 -1
arch/x86/kernel/fpu/core.c
··· 679 679 struct fpu *fpu = &current->thread.fpu; 680 680 681 681 fpregs_lock(); 682 - fpu__drop(fpu); 682 + __fpu_invalidate_fpregs_state(fpu); 683 683 /* 684 684 * This does not change the actual hardware registers. It just 685 685 * resets the memory image and sets TIF_NEED_FPU_LOAD so a
+7
arch/x86/kernel/fpu/xstate.c
··· 882 882 goto out_disable; 883 883 } 884 884 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 + 885 892 print_xstate_offset_size(); 886 893 pr_info("x86/fpu: Enabled xstate features 0x%llx, context size is %d bytes, using '%s' format.\n", 887 894 fpu_kernel_cfg.max_features,