linux-stable/arch
Feng Tang a7a1849899 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 16:18:19 +02:00
..
alpha alpha: remove __init annotation from exported page_is_ram() 2023-08-16 18:22:03 +02:00
arc ARC: define ASM_NL and __ALIGN(_STR) outside #ifdef __ASSEMBLY__ guard 2023-07-23 13:47:15 +02:00
arm ARM: dts: imx: Set default tuning step for imx6sx usdhc 2023-08-26 14:23:35 +02:00
arm64 arm64: dts: rockchip: Disable HS400 for eMMC on ROCK Pi 4 2023-08-26 14:23:37 +02:00
csky
h8300
hexagon
ia64 ia64/cpu: Switch to arch_cpu_finalize_init() 2023-08-08 19:58:30 +02:00
m68k m68k/cpu: Switch to arch_cpu_finalize_init() 2023-08-08 19:58:30 +02:00
microblaze
mips MIPS: cpu-features: Use boot_cpu_type for CPU type based features 2023-08-30 16:18:11 +02:00
nds32
nios2 nios2: dts: Fix tse_mac "max-frame-size" property 2023-06-21 15:59:14 +02:00
openrisc openrisc: Properly store r31 to pt_regs on unhandled exceptions 2023-05-11 23:00:37 +09:00
parisc init: Remove check_bugs() leftovers 2023-08-08 19:58:31 +02:00
powerpc powerpc/rtas_flash: allow user copy to flash block cache objects 2023-08-26 14:23:31 +02:00
riscv riscv: uaccess: Return the number of bytes effectively not copied 2023-08-26 14:23:36 +02:00
s390 KVM: s390: fix sthyi error handling 2023-08-11 15:13:49 +02:00
sh sh/cpu: Switch to arch_cpu_finalize_init() 2023-08-08 19:58:31 +02:00
sparc sparc/cpu: Switch to arch_cpu_finalize_init() 2023-08-08 19:58:31 +02:00
um um/cpu: Switch to arch_cpu_finalize_init() 2023-08-08 19:58:31 +02:00
x86 x86/fpu: Set X86_FEATURE_OSXSAVE feature after enabling OSXSAVE in CR4 2023-08-30 16:18:19 +02:00
xtensa init: Remove check_bugs() leftovers 2023-08-08 19:58:31 +02:00
.gitignore
Kconfig init: Provide arch_cpu_finalize_init() 2023-08-08 19:58:30 +02:00