OpenCloudOS-Kernel/arch/x86/kernel
Borislav Petkov bb8c13d61a x86/microcode: Fix CPU synchronization routine
Emanuel reported an issue with a hang during microcode update because my
dumb idea to use one atomic synchronization variable for both rendezvous
- before and after update - was simply bollocks:

  microcode: microcode_reload_late: late_cpus: 4
  microcode: __reload_late: cpu 2 entered
  microcode: __reload_late: cpu 1 entered
  microcode: __reload_late: cpu 3 entered
  microcode: __reload_late: cpu 0 entered
  microcode: __reload_late: cpu 1 left
  microcode: Timeout while waiting for CPUs rendezvous, remaining: 1

CPU1 above would finish, leave and the others will still spin waiting for
it to join.

So do two synchronization atomics instead, which makes the code a lot more
straightforward.

Also, since the update is serialized and it also takes quite some time per
microcode engine, increase the exit timeout by the number of CPUs on the
system.

That's ok because the moment all CPUs are done, that timeout will be cut
short.

Furthermore, panic when some of the CPUs timeout when returning from a
microcode update: we can't allow a system with not all cores updated.

Also, as an optimization, do not do the exit sync if microcode wasn't
updated.

Reported-by: Emanuel Czirai <xftroxgpx@protonmail.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Emanuel Czirai <xftroxgpx@protonmail.com>
Tested-by: Ashok Raj <ashok.raj@intel.com>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Link: https://lkml.kernel.org/r/20180314183615.17629-2-bp@alien8.de
2018-03-16 20:55:51 +01:00
..
acpi ACPI: SPCR: Make SPCR available to x86 2018-02-07 11:39:58 +01:00
apic x86/IO-APIC: Avoid warning in 32-bit builds 2018-02-20 09:33:40 +01:00
cpu x86/microcode: Fix CPU synchronization routine 2018-03-16 20:55:51 +01:00
fpu Merge commit 'upstream-x86-entry' into WIP.x86/mm 2017-12-17 12:58:53 +01:00
kprobes x86/kprobes: Fix kernel crash when probing .entry_trampoline code 2018-03-09 09:58:36 +01:00
.gitignore
Makefile Merge branch 'x86-platform-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2018-01-29 18:17:39 -08:00
alternative.c x86/paravirt: Remove 'noreplace-paravirt' cmdline option 2018-01-31 10:37:45 +01:00
amd_gart_64.c dma-mapping: move swiotlb arch helpers to a new header 2018-01-10 16:40:54 +01:00
amd_nb.c x86/cpu: Rename cpu_data.x86_mask to cpu_data.x86_stepping 2018-02-15 01:15:52 +01:00
apb_timer.c Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2016-12-25 14:30:04 -08:00
aperture_64.c x86/gart: Exclude GART aperture from vmcore 2018-01-11 15:09:24 +01:00
apm_32.c vfs: do bulk POLL* -> EPOLL* replacement 2018-02-11 14:34:03 -08:00
asm-offsets.c x86/mm: Use/Fix PCID to optimize user/kernel switches 2017-12-23 21:13:00 +01:00
asm-offsets_32.c x86/cpu: Rename cpu_data.x86_mask to cpu_data.x86_stepping 2018-02-15 01:15:52 +01:00
asm-offsets_64.c x86/entry/64: Separate cpu_current_top_of_stack from TSS.sp0 2017-12-17 13:59:56 +01:00
audit_64.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
bootflag.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
check.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
cpuid.c Merge branch 'smp-hotplug-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2016-12-12 19:25:04 -08:00
crash.c resource: Fix resource_size.cocci warnings 2017-11-07 20:44:56 +01:00
crash_dump_32.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
crash_dump_64.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
devicetree.c x86: remove arch specific early_init_dt_alloc_memory_arch 2018-01-30 11:17:37 -06:00
doublefault.c x86/entry: Fix assumptions that the HW TSS is at the beginning of cpu_tss 2017-12-17 13:59:55 +01:00
dumpstack.c x86/dumpstack: Avoid uninitlized variable 2018-02-02 23:33:50 +01:00
dumpstack_32.c x86/entry: Rename SYSENTER_stack to CPU_ENTRY_AREA_entry_stack 2017-12-22 20:13:02 +01:00
dumpstack_64.c x86/entry: Rename SYSENTER_stack to CPU_ENTRY_AREA_entry_stack 2017-12-22 20:13:02 +01:00
e820.c x86/boot/e820: Add support to determine the E820 type of an address 2017-07-18 11:38:01 +02:00
early-quirks.c x86/gpu: add CFL to early quirks 2017-12-15 13:18:00 -08:00
early_printk.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
ebda.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
eisa.c x86/eisa: Add missing include 2017-08-31 21:34:48 +02:00
espfix_64.c kmemcheck: stop using GFP_NOTRACK and SLAB_NOTRACK 2017-11-15 18:21:04 -08:00
ftrace.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
ftrace_32.S x86/retpoline/ftrace: Convert ftrace assembler indirect jumps 2018-01-12 00:14:30 +01:00
ftrace_64.S Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2018-01-28 12:19:23 -08:00
head32.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
head64.c x86/mm: Encrypt the initrd earlier for BSP microcode update 2018-01-16 01:50:59 +01:00
head_32.S x86/cpu: Rename cpu_data.x86_mask to cpu_data.x86_stepping 2018-02-15 01:15:52 +01:00
head_64.S x86/boot, objtool: Annotate indirect jump in secondary_startup_64() 2018-02-21 09:05:03 +01:00
hpet.c x86/hpet: Cure interface abuse in the resume path 2017-08-01 13:02:37 +02:00
hw_breakpoint.c
i8237.c
i8253.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
i8259.c Merge branch 'linus' into x86/apic, to resolve conflicts 2017-11-07 10:51:10 +01:00
idt.c x86/idt: Mark IDT tables __initconst 2018-01-14 20:09:45 +01:00
io_delay.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
ioport.c x86/syscalls: Use proper syscall definition for sys_ioperm() 2018-03-07 07:57:30 +01:00
irq.c x86/irq: Count Hyper-V reenlightenment interrupts 2018-01-30 23:55:33 +01:00
irq_32.c x86/retpoline/irq32: Convert assembler indirect jumps 2018-01-12 00:14:32 +01:00
irq_64.c x86/irq/64: Print the offending IP in the stack overflow warning 2017-12-17 13:59:53 +01:00
irq_work.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
irqinit.c Revert "x86/apic: Remove init_bsp_APIC()" 2018-01-14 12:14:51 +01:00
itmt.c x86/headers: Remove duplicate #includes 2017-12-12 11:32:24 +01:00
jailhouse.c x86/jailhouse: Respect pci=lastbus command line settings 2018-01-20 08:15:44 +01:00
jump_label.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
kdebugfs.c x86, mpparse, x86/acpi, x86/PCI, x86/dmi, SFI: Use memremap() for RAM mappings 2017-07-18 11:37:58 +02:00
kexec-bzimage64.c x86/boot/e820: Rename the e820_table_firmware to e820_table_kexec 2017-07-05 10:09:02 +02:00
kgdb.c sched/x86: Add 'struct inactive_task_frame' to better document the sleeping task stack frame 2016-08-24 12:27:41 +02:00
ksysfs.c x86/sysfs: Fix off-by-one error in loop termination 2017-09-25 09:36:16 +02:00
kvm.c KVM: X86: use paravirtualized TLB Shootdown 2018-01-16 16:34:13 +01:00
kvmclock.c xen: features and fixes for v4.15-rc1 2017-11-16 13:06:27 -08:00
ldt.c x86/ldt: Make LDT pgtable free conditional 2017-12-31 16:55:09 +01:00
livepatch.c livepatch/x86: apply alternatives and paravirt patches after relocations 2016-08-18 23:41:55 +02:00
machine_kexec_32.c x86-32: Fix kexec with stack canary (CONFIG_CC_STACKPROTECTOR) 2017-12-27 20:59:41 +01:00
machine_kexec_64.c x86/mm, kexec: Fix memory corruption with SME on successive kexecs 2017-07-30 12:09:12 +02:00
mmconf-fam10h_64.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
module.c x86/module: Detect and skip invalid relocations 2017-11-05 09:52:16 +01:00
mpparse.c Merge branch 'x86-pti-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2018-02-14 17:02:15 -08:00
msr.c x86/msr: Remove bogus cleanup from the error path 2016-12-25 10:47:41 +01:00
nmi.c locking/atomics: COCCINELLE/treewide: Convert trivial ACCESS_ONCE() patterns to READ_ONCE()/WRITE_ONCE() 2017-10-25 11:01:08 +02:00
nmi_selftest.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
paravirt-spinlocks.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
paravirt.c x86/mm: Rename flush_tlb_single() and flush_tlb_one() to __flush_tlb_one_[user|kernel]() 2018-02-15 01:15:52 +01:00
paravirt_patch_32.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
paravirt_patch_64.c x86/paravirt: Dont patch flush_tlb_single 2017-12-17 14:27:52 +01:00
pci-calgary_64.c x86, calgary: Convert timers to use timer_setup() 2017-11-02 15:50:32 -07:00
pci-dma.c dma-mapping: add an arch_dma_supported hook 2018-01-15 09:34:59 +01:00
pci-iommu_table.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pci-nommu.c dma-mapping: move swiotlb arch helpers to a new header 2018-01-10 16:40:54 +01:00
pci-swiotlb.c swiotlb: rename swiotlb_free to swiotlb_exit 2018-01-15 09:35:39 +01:00
pcspeaker.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
perf_regs.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
platform-quirks.c x86/platform: Control warm reset setup via legacy feature flag 2018-01-14 21:11:53 +01:00
pmem.c resource: Provide resource struct in resource walk callback 2017-11-07 15:35:57 +01:00
probe_roms.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
process.c Merge branch 'x86-cleanups-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2018-01-30 13:01:09 -08:00
process_32.c x86/entry/64: Make cpu_entry_area.tss read-only 2017-12-17 14:27:52 +01:00
process_64.c x86/asm: Move 'status' from thread_struct to thread_info 2018-01-30 15:30:36 +01:00
ptrace.c x86/asm: Move 'status' from thread_struct to thread_info 2018-01-30 15:30:36 +01:00
pvclock.c x86/pvclock: add setter for pvclock_pvti_cpu0_va 2017-11-08 16:33:14 -05:00
quirks.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
reboot.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
reboot_fixups_32.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
relocate_kernel_32.S
relocate_kernel_64.S x86/kexec: Make kexec (mostly) work in 5-level paging mode 2018-01-31 08:39:40 +01:00
resource.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
rtc.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
setup.c x86/cpu_entry_area: Sync cpu_entry_area to initial_page_table 2018-03-01 09:48:27 +01:00
setup_percpu.c x86/cpu_entry_area: Sync cpu_entry_area to initial_page_table 2018-03-01 09:48:27 +01:00
signal.c x86/asm: Move 'status' from thread_struct to thread_info 2018-01-30 15:30:36 +01:00
signal_compat.c signal: Unify and correct copy_siginfo_to_user32 2018-01-15 19:56:20 -06:00
smp.c x86/tracing: Disentangle pagefault and resched IPI tracing key 2017-08-29 11:42:29 +02:00
smpboot.c Merge branch 'x86-cleanups-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2018-01-30 13:01:09 -08:00
stacktrace.c Merge branch 'x86-pti-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2018-01-03 16:41:07 -08:00
step.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
sys_x86_64.c x86/mm: Prevent non-MAP_FIXED mapping across DEFAULT_MAP_WINDOW border 2017-11-16 11:43:11 +01:00
sysfb.c
sysfb_efi.c
sysfb_simplefb.c x86/sysfb: Fix lfb_size calculation 2016-11-16 09:38:23 +01:00
tboot.c x86/pti: Make unpoison of pgd for trusted boot work for real 2018-01-11 23:36:59 +01:00
tce_64.c
time.c x86/time: Unconditionally register legacy timer interrupt 2018-01-14 20:18:23 +01:00
tls.c x86/ldt: Make the LDT mapping RO 2017-12-23 21:13:01 +01:00
tls.h
topology.c
trace_clock.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
tracepoint.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
traps.c x86/debug: Use UD2 for WARN() 2018-02-15 01:15:50 +01:00
tsc.c x86/tsc: Introduce early tsc clocksource 2018-01-14 20:18:23 +01:00
tsc_msr.c x86/tsc: Set TSC_KNOWN_FREQ and TSC_RELIABLE flags on Intel Atom SoCs 2016-11-18 10:58:31 +01:00
tsc_sync.c Merge branch 'x86-timers-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2017-11-13 19:07:38 -08:00
umip.c x86/umip: Fix insn_get_code_seg_params()'s return value 2017-11-23 20:17:59 +01:00
unwind_frame.c x86/unwind: Disable unwinder warnings on 32-bit 2017-10-10 12:49:49 +02:00
unwind_guess.c x86/unwind: Add the ORC unwinder 2017-07-26 13:18:20 +02:00
unwind_orc.c extable: Make init_kernel_text() global 2018-02-21 16:54:06 +01:00
uprobes.c uprobes/x86: Emulate push insns for uprobe on x86 2017-12-11 18:42:11 +01:00
verify_cpu.S x86/boot: Annotate verify_cpu() as a callable function 2017-09-28 09:39:03 +02:00
vm86_32.c x86/vm86/32: Fix POPF emulation 2018-03-14 09:21:01 +01:00
vmlinux.lds.S x86/kprobes: Fix kernel crash when probing .entry_trampoline code 2018-03-09 09:58:36 +01:00
vsmp_64.c x86/apic: Remove unused callbacks 2017-09-25 20:51:58 +02:00
x86_init.c Merge branch 'x86-apic-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2017-11-13 18:29:23 -08:00