Star64_linux/arch/x86/kernel
Feng Tang 91b56fc98b 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-09-05 01:25:09 +08:00
..
acpi x86: ACPI: cstate: Optimize C3 entry on AMD CPUs 2023-04-19 17:58:59 +08:00
apic x86/apic: Fix kernel panic when booting with intremap=off and x2apic_phys 2023-08-20 15:24:05 +08:00
cpu x86/srso: Correct the mitigation status when SMT is disabled 2023-08-28 23:27:08 +08:00
fpu x86/fpu: Set X86_FEATURE_OSXSAVE feature after enabling OSXSAVE in CR4 2023-09-05 01:25:09 +08:00
kprobes x86/kprobes: Fix arch_check_optimized_kprobe check within optimized_kprobe range 2023-04-19 18:00:18 +08:00
.gitignore
alternative.c x86/srso: Fix return thunks in generated code 2023-08-20 16:01:30 +08:00
amd_gart_64.c x86/amd_gart: don't set failed sg dma_address to DMA_MAPPING_ERROR 2021-08-09 17:13:06 +02:00
amd_nb.c hwmon: (k10temp) Add support for yellow carp 2021-08-27 13:54:58 -07:00
aperture_64.c memblock: make memblock_find_in_range method private 2021-09-03 09:58:17 -07:00
apm_32.c
asm-offsets.c
asm-offsets_32.c
asm-offsets_64.c
audit_64.c
bootflag.c
cc_platform.c x86/sev: Add an x86 version of cc_platform_has() 2023-04-19 16:57:58 +08:00
check.c
cpuid.c
crash.c x86/crash: Disable virt in core NMI crash handler to avoid double shootdown 2023-04-19 18:00:18 +08:00
crash_core_32.c
crash_core_64.c
crash_dump_32.c
crash_dump_64.c
devicetree.c
doublefault_32.c
dumpstack.c x86/show_trace_log_lvl: Ensure stack pointer is aligned, again 2023-06-06 18:43:22 +08:00
dumpstack_32.c
dumpstack_64.c x86/mm/64: Improve stack overflow warnings 2023-04-19 16:57:07 +08:00
e820.c x86/boot: Fix memremap of setup_indirect structures 2023-04-19 17:46:17 +08:00
early-quirks.c x86/gpu: Reserve stolen memory for first integrated Intel GPU 2023-04-19 17:43:46 +08:00
early_printk.c
ebda.c
eisa.c
espfix_64.c
ftrace.c ftrace/x86: Add back ftrace_expected for ftrace bug reports 2023-04-19 17:58:15 +08:00
ftrace_32.S x86: Prepare asm files for straight-line-speculation 2023-04-19 17:48:43 +08:00
ftrace_64.S x86/ibt,ftrace: Make function-graph play nice 2023-04-19 17:52:58 +08:00
head32.c
head64.c x86: Clear .brk area at early boot 2023-04-19 17:51:26 +08:00
head_32.S x86/asm/32: Fix ANNOTATE_UNRET_SAFE use on 32-bit 2023-04-19 17:51:34 +08:00
head_64.S objtool: Add entry UNRET validation 2023-04-19 17:51:32 +08:00
hpet.c rtc: Check return value from mc146818_get_time() 2023-04-19 17:47:43 +08:00
hw_breakpoint.c
i8237.c
i8253.c
i8259.c x86/i8259: Mark legacy PIC interrupts with IRQ_LEVEL 2023-04-19 17:59:06 +08:00
idt.c X86 interrupt related changes: 2021-06-29 12:36:59 -07:00
io_delay.c
ioport.c
irq.c x86/irq: Ensure PI wakeup handler is unregistered before module unload 2023-04-19 16:56:57 +08:00
irq_32.c
irq_64.c
irq_work.c
irqflags.S x86: Prepare asm files for straight-line-speculation 2023-04-19 17:48:43 +08:00
irqinit.c x86/i8259: Mark legacy PIC interrupts with IRQ_LEVEL 2023-04-19 17:59:06 +08:00
itmt.c
jailhouse.c
jump_label.c jump_labels: Mark __jump_label_transform() as __always_inlined to work around aggressive compiler un-inlining 2021-07-13 06:32:05 +02:00
kdebugfs.c x86/boot: Fix memremap of setup_indirect structures 2023-04-19 17:46:17 +08:00
kexec-bzimage64.c
kgdb.c
ksysfs.c x86/boot: Fix memremap of setup_indirect structures 2023-04-19 17:46:17 +08:00
kvm.c x86, kvm: use proper ASM macros for kvm_vcpu_is_preempted 2023-04-19 17:50:48 +08:00
kvmclock.c x86/kvmclock: Move this_cpu_pvti into kvmclock.h 2021-09-30 04:08:01 -04:00
ldt.c memcg: enable accounting for ldt_struct objects 2021-09-03 09:58:13 -07:00
machine_kexec_32.c x86/kexec: Set_[gi]dt() -> native_[gi]dt_invalidate() in machine_kexec_*.c 2021-05-21 12:36:45 +02:00
machine_kexec_64.c x86/kexec: fix memory leak of elf header buffer 2023-04-19 17:49:21 +08:00
Makefile x86/sev: Add an x86 version of cc_platform_has() 2023-04-19 16:57:58 +08:00
mmconf-fam10h_64.c
module.c x86: Undo return-thunk damage 2023-04-19 17:51:30 +08:00
mpparse.c x86: Avoid magic number with ELCR register accesses 2021-08-10 23:31:43 +02:00
msr.c
nmi.c
nmi_selftest.c
paravirt-spinlocks.c
paravirt.c x86: Prepare inline-asm for straight-line-speculation 2023-04-19 17:48:43 +08:00
pci-dma.c
pci-iommu_table.c
pci-swiotlb.c
pcspeaker.c
perf_regs.c
platform-quirks.c
pmem.c x86/pmem: Fix platform-device leak in error path 2023-04-19 17:52:10 +08:00
probe_roms.c
process.c x86: Mark stop_this_cpu() __noreturn 2023-04-19 17:59:45 +08:00
process.h
process_32.c x86/resctl: fix scheduler confusion with 'current' 2023-04-19 18:00:36 +08:00
process_64.c x86/resctl: fix scheduler confusion with 'current' 2023-04-19 18:00:36 +08:00
ptrace.c x86/ptrace: Fix xfpregs_set()'s incorrect xmm clearing 2023-04-19 17:45:37 +08:00
pvclock.c
quirks.c
reboot.c x86/reboot: Disable virtualization in an emergency if SVM is supported 2023-04-19 18:00:18 +08:00
reboot_fixups_32.c
relocate_kernel_32.S x86/kexec: Disable RET on kexec 2023-04-19 17:51:33 +08:00
relocate_kernel_64.S x86/kexec: Disable RET on kexec 2023-04-19 17:51:33 +08:00
resource.c
rtc.c
setup.c x86/boot: Fix memremap of setup_indirect structures 2023-04-19 17:46:17 +08:00
setup_percpu.c memblock: introduce saner 'memblock_free_ptr()' interface 2021-09-14 13:23:22 -07:00
sev-shared.c x86/sev: Return an error on a returned non-zero SW_EXITINFO1[31:0] 2021-10-01 11:14:41 +02:00
sev.c x86/sev: Fix SEV-ES INS/OUTS instructions for word, dword, and qword 2023-04-19 17:42:48 +08:00
sev_verify_cbit.S x86: Prepare asm files for straight-line-speculation 2023-04-19 17:48:43 +08:00
signal.c x86/init: Initialize signal frame size late 2023-08-20 16:01:28 +08:00
signal_compat.c signal: Deliver SIGTRAP on perf event asynchronously if blocked 2023-04-19 17:49:35 +08:00
smp.c x86/reboot: Disable SVM, not just VMX, when stopping CPUs 2023-04-19 18:00:18 +08:00
smpboot.c x86/smp: Use dedicated cache-line for mwait_play_dead() 2023-08-20 15:24:10 +08:00
stacktrace.c
static_call.c x86/static_call: Fix __static_call_fixup() 2023-08-28 23:27:07 +08:00
step.c ptrace: Reimplement PTRACE_KILL by always sending SIGKILL 2023-04-19 17:49:21 +08:00
sys_ia32.c
sys_x86_64.c x86/mm: Cleanup the control_va_addr_alignment() __setup handler 2023-04-19 17:49:39 +08:00
tboot.c
time.c
tls.c
tls.h
topology.c
trace.c trace/osnoise: Fix 'no previous prototype' warnings 2021-06-28 14:12:26 -04:00
trace_clock.c
tracepoint.c
traps.c x86/CPU/AMD: Fix the DIV(0) initial fix attempt 2023-08-28 23:27:07 +08:00
tsc.c x86/tsc: Disable clocksource watchdog for TSC on qualified platorms 2023-04-19 17:42:50 +08:00
tsc_msr.c
tsc_sync.c x86/tsc: Add a timer to make sure TSC_adjust is always checked 2023-04-19 17:42:50 +08:00
umip.c x86/insn: Extend error reporting from insn_fetch_from_user[_inatomic]() 2021-06-15 11:39:30 +02:00
unwind_frame.c
unwind_guess.c
unwind_orc.c x86/unwind/orc: Fix unreliable stack dump with gcov 2023-04-19 17:55:50 +08:00
uprobes.c uprobes/x86: Allow to probe a NOP instruction with 0x66 prefix 2023-04-19 17:57:16 +08:00
verify_cpu.S x86: Prepare asm files for straight-line-speculation 2023-04-19 17:48:43 +08:00
vm86_32.c signal: Replace force_fatal_sig with force_exit_sig when in doubt 2023-04-19 17:42:21 +08:00
vmlinux.lds.S x86/retpoline,kprobes: Fix position of thunk sections with CONFIG_LTO_CLANG 2023-08-28 23:27:08 +08:00
vsmp_64.c
x86_init.c x86/rtc: Remove __init for runtime functions 2023-06-06 18:05:22 +08:00