linux-stable/arch/x86/kernel
Pawan Gupta ae34a4f4a2 x86/bugs: Make sure MSR_SPEC_CTRL is updated properly upon resume from S3
commit 6606515742 upstream.

The "force" argument to write_spec_ctrl_current() is currently ambiguous
as it does not guarantee the MSR write. This is due to the optimization
that writes to the MSR happen only when the new value differs from the
cached value.

This is fine in most cases, but breaks for S3 resume when the cached MSR
value gets out of sync with the hardware MSR value due to S3 resetting
it.

When x86_spec_ctrl_current is same as x86_spec_ctrl_base, the MSR write
is skipped. Which results in SPEC_CTRL mitigations not getting restored.

Move the MSR write from write_spec_ctrl_current() to a new function that
unconditionally writes to the MSR. Update the callers accordingly and
rename functions.

  [ bp: Rework a bit. ]

Fixes: caa0ff24d5 ("x86/bugs: Keep a per-CPU IA32_SPEC_CTRL value")
Suggested-by: Borislav Petkov <bp@alien8.de>
Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Cc: <stable@kernel.org>
Link: https://lore.kernel.org/r/806d39b0bfec2fe8f50dc5446dff20f5bb24a959.1669821572.git.pawan.kumar.gupta@linux.intel.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-12-08 11:23:04 +01:00
..
acpi ACPI / x86: Work around broken XSDT on Advantech DAC-BJ01 board 2022-03-28 08:46:47 +02:00
apic x86: Fix return value of __setup handlers 2022-06-14 18:11:35 +02:00
cpu x86/bugs: Make sure MSR_SPEC_CTRL is updated properly upon resume from S3 2022-12-08 11:23:04 +01:00
fpu x86/fpu: Make init_fpstate correct with optimized XSAVE 2021-08-26 08:36:11 -04:00
kprobes x86: kprobes: Prohibit probing on instruction which has emulate prefix 2022-05-15 19:54:47 +02:00
.gitignore
alternative.c
amd_gart_64.c
amd_nb.c x86/amd_nb: Add AMD family 17h model 60h PCI IDs 2020-06-22 09:31:17 +02:00
apb_timer.c
aperture_64.c
apm_32.c
asm-offsets.c
asm-offsets_32.c
asm-offsets_64.c Merge branch 'x86-apic-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2019-09-17 12:04:39 -07:00
audit_64.c
bootflag.c
check.c
cpuid.c
crash.c x86/crash: Fix crash_setup_memmap_entries() out-of-bounds access 2021-04-28 13:19:16 +02:00
crash_dump_32.c
crash_dump_64.c
devicetree.c
doublefault.c x86/doublefault/32: Fix stack canaries in the double fault handler 2019-11-29 10:09:51 +01:00
dumpstack.c
dumpstack_32.c
dumpstack_64.c x86/dumpstack/64: Don't evaluate exception stacks before setup 2019-11-05 00:51:35 +01:00
e820.c
early-quirks.c x86/gpu: Reserve stolen memory for first integrated Intel GPU 2022-01-27 09:19:26 +01:00
early_printk.c
ebda.c
eisa.c
espfix_64.c
ftrace.c
ftrace_32.S x86/asm/32: Add ENDs to some functions and relabel with SYM_CODE_* 2021-01-17 14:05:30 +01:00
ftrace_64.S
head32.c
head64.c x86: Clear .brk area at early boot 2022-07-21 20:59:27 +02:00
head_32.S x86/asm/32: Add ENDs to some functions and relabel with SYM_CODE_* 2021-01-17 14:05:30 +01:00
head_64.S
hpet.c x86/hpet: Use another crystalball to evaluate HPET usability 2021-10-13 10:08:21 +02:00
hw_breakpoint.c
i8237.c
i8253.c
i8259.c x86/i8259: Use printk_deferred() to prevent deadlock 2020-08-05 09:59:52 +02:00
idt.c x86/idt: Keep spurious entries unset in system_vectors 2020-06-24 17:50:43 +02:00
ima_arch.c x86/ima: use correct identifier for SetupMode variable 2020-02-28 17:22:18 +01:00
io_delay.c
ioport.c
irq.c x86/irq: Ensure PI wakeup handler is unregistered before module unload 2021-11-17 09:48:19 +01:00
irq_32.c
irq_64.c x86: fix vmap arguments in map_irq_stack 2020-06-22 09:30:57 +02:00
irq_work.c
irqflags.S
irqinit.c
itmt.c
jailhouse.c
jump_label.c
kdebugfs.c
kexec-bzimage64.c x86/kexec: Use up-to-dated screen_info copy to fill boot params 2020-11-10 12:37:29 +01:00
kgdb.c
ksysfs.c
kvm.c x86/kvm: Preserve BSP MSR_KVM_POLL_CONTROL across suspend/resume 2022-05-12 12:23:47 +02:00
kvmclock.c x86/kvmclock: Move this_cpu_pvti into kvmclock.h 2021-10-06 15:42:31 +02:00
ldt.c
livepatch.c
machine_kexec_32.c
machine_kexec_64.c
Makefile
mmconf-fam10h_64.c
module.c x86/build: Treat R_386_PLT32 relocation as R_386_PC32 2021-03-07 12:20:45 +01:00
mpparse.c
msr.c
nmi.c x86/nmi: Fix nmi_handle() duration miscalculation 2020-10-29 09:57:30 +01:00
nmi_selftest.c
paravirt-spinlocks.c
paravirt.c
paravirt_patch.c
pci-calgary_64.c
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 2022-08-25 11:17:33 +02:00
probe_roms.c
process.c x86/bugs: Make sure MSR_SPEC_CTRL is updated properly upon resume from S3 2022-12-08 11:23:04 +01:00
process.h x86: Use the correct SPDX License Identifier in headers 2019-10-01 20:31:35 +02:00
process_32.c x86/fpu: Correct pkru/xstate inconsistency 2022-03-02 11:41:03 +01:00
process_64.c x86/fpu: Correct pkru/xstate inconsistency 2022-03-02 11:41:03 +01:00
ptrace.c
pvclock.c
quirks.c
reboot.c x86/mm: Flush global TLB when switching to trampoline page-table 2022-01-27 09:19:42 +01:00
reboot_fixups_32.c
relocate_kernel_32.S
relocate_kernel_64.S
resource.c
rtc.c
setup.c ACPI: x86: Call acpi_boot_table_init() after acpi_table_upgrade() 2021-05-07 10:51:37 +02:00
setup_percpu.c
signal.c x86/signal: Detect and prevent an alternate signal stack overflow 2021-07-20 16:10:49 +02:00
signal_compat.c
smp.c
smpboot.c x86/hotplug: Silence APIC only after all interrupts are migrated 2020-09-03 11:27:06 +02:00
stacktrace.c x86/stacktrace: Fix reliable check for empty user task stacks 2020-08-05 09:59:51 +02:00
step.c ptrace: Reimplement PTRACE_KILL by always sending SIGKILL 2022-06-14 18:11:24 +02:00
sys_x86_64.c x86/mm: Cleanup the control_va_addr_alignment() __setup handler 2022-06-14 18:11:35 +02:00
sysfb.c
sysfb_efi.c
sysfb_simplefb.c x86/sysfb: Fix check for bad VRAM size 2020-02-24 08:36:29 +01:00
tboot.c iommu/vt-d: Avoid panic if iommu init fails in tboot system 2020-11-24 13:29:17 +01:00
tce_64.c
time.c x86_64: Fix jiffies ODR violation 2020-06-17 16:40:24 +02:00
tls.c
tls.h
topology.c
trace_clock.c
tracepoint.c
traps.c
tsc.c x86/tsc: Disable clocksource watchdog for TSC on qualified platorms 2021-12-08 09:01:14 +01:00
tsc_msr.c x86/tsr: Fix tsc frequency enumeration bug on Lightning Mountain SoC 2020-08-21 13:05:36 +02:00
tsc_sync.c x86/tsc: Add a timer to make sure TSC_adjust is always checked 2021-12-08 09:01:14 +01:00
umip.c x86/umip: Add emulation (spoofing) for UMIP covered instructions in 64-bit processes as well 2019-09-10 08:36:16 +02:00
unwind_frame.c
unwind_guess.c
unwind_orc.c x86/unwind/orc: Fix unreliable stack dump with gcov 2022-11-03 23:56:55 +09:00
uprobes.c x86/uprobes: Do not use prefixes.nbytes when looping over prefixes.bytes 2020-12-11 13:23:30 +01:00
verify_cpu.S
vm86_32.c
vmlinux.lds.S x86, vmlinux.lds: Page-align end of ..page_aligned sections 2020-07-29 10:18:45 +02:00
vsmp_64.c
x86_init.c x86/timer: Don't skip PIT setup when APIC is disabled or in legacy mode 2020-02-11 04:35:52 -08:00