linux-stable/arch
Feng Tang 517771333f x86/fpu: Set X86_FEATURE_OSXSAVE feature after enabling OSXSAVE in CR4
commit 2c66ca3949 upstream.

0-Day found a 34.6% regression in stress-ng's 'af-alg' test case, and
bisected it to commit b81fac906a ("x86/fpu: Move FPU initialization into
arch_cpu_finalize_init()"), which optimizes the FPU init order, and moves
the CR4_OSXSAVE enabling into a later place:

   arch_cpu_finalize_init
       identify_boot_cpu
	   identify_cpu
	       generic_identify
                   get_cpu_cap --> setup cpu capability
       ...
       fpu__init_cpu
           fpu__init_cpu_xstate
               cr4_set_bits(X86_CR4_OSXSAVE);

As the FPU is not yet initialized the CPU capability setup fails to set
X86_FEATURE_OSXSAVE. Many security module like 'camellia_aesni_avx_x86_64'
depend on this feature and therefore fail to load, causing the regression.

Cure this by setting X86_FEATURE_OSXSAVE feature right after OSXSAVE
enabling.

[ tglx: Moved it into the actual BSP FPU initialization code and added a comment ]

Fixes: b81fac906a ("x86/fpu: Move FPU initialization into arch_cpu_finalize_init()")
Reported-by: kernel test robot <oliver.sang@intel.com>
Signed-off-by: Feng Tang <feng.tang@intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/lkml/202307192135.203ac24e-oliver.sang@intel.com
Link: https://lore.kernel.org/lkml/20230823065747.92257-1-feng.tang@intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-08-30 14:52:37 +02:00
..
alpha
arc
arm ARM: dts: imx: Set default tuning step for imx6sx usdhc 2023-08-23 17:32:50 +02:00
arm64 arm64/ptrace: Ensure that the task sees ZT writes on first use 2023-08-23 17:32:53 +02:00
csky
hexagon
ia64
loongarch LoongArch: Fix hw_breakpoint_control() for watchpoints 2023-08-30 14:52:37 +02:00
m68k
microblaze
mips
nios2
openrisc
parisc parisc: Fix CONFIG_TLB_PTLOCK to work with lightweight spinlock checks 2023-08-23 17:32:52 +02:00
powerpc mm: enable page walking API to lock vmas during the walk 2023-08-30 14:52:36 +02:00
riscv mm: enable page walking API to lock vmas during the walk 2023-08-30 14:52:36 +02:00
s390 mm: enable page walking API to lock vmas during the walk 2023-08-30 14:52:36 +02:00
sh
sparc
um
x86 x86/fpu: Set X86_FEATURE_OSXSAVE feature after enabling OSXSAVE in CR4 2023-08-30 14:52:37 +02:00
xtensa
.gitignore
Kconfig