linux-stable/arch/x86/kernel
Pawan Gupta 41296b85fa 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:28:42 +01:00
..
acpi x86: Prepare asm files for straight-line-speculation 2022-05-15 20:18:49 +02:00
apic x86: Fix return value of __setup handlers 2022-06-09 10:22:53 +02:00
cpu x86/bugs: Make sure MSR_SPEC_CTRL is updated properly upon resume from S3 2022-12-08 11:28:42 +01:00
fpu x86/fpu: Prevent FPU state corruption 2022-05-12 12:30:02 +02:00
kprobes x86/kprobes: Fix JNG/JNLE emulation 2022-08-25 11:39:57 +02:00
.gitignore
alternative.c x86/alternative: Fix race in try_get_desc() 2022-10-05 10:39:44 +02: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 x86: Fix various typos in comments, take #2 2021-03-21 23:50:28 +01:00
asm-offsets.c x86/paravirt: Switch iret pvops to ALTERNATIVE 2021-03-11 19:58:54 +01:00
asm-offsets_32.c x86/stackprotector/32: Make the canary into a regular percpu variable 2021-03-08 13:19:05 +01:00
asm-offsets_64.c x86/xen: Drop USERGS_SYSRET64 paravirt call 2021-02-10 12:32:07 +01:00
audit_64.c
bootflag.c
cc_platform.c x86/sev: Add an x86 version of cc_platform_has() 2021-11-18 19:17:21 +01:00
check.c
cpuid.c smp: Cleanup smp_call_function*() 2020-11-24 16:47:49 +01:00
crash.c x86/crash: Remove crash_reserve_low_1M() 2021-06-07 12:14:45 +02:00
crash_core_32.c
crash_core_64.c
crash_dump_32.c
crash_dump_64.c
devicetree.c
doublefault_32.c x86/stackprotector/32: Make the canary into a regular percpu variable 2021-03-08 13:19:05 +01:00
dumpstack.c x86/dumpstack: use %pSb/%pBb for backtrace printing 2021-07-08 11:48:22 -07:00
dumpstack_32.c
dumpstack_64.c x86/mm/64: Improve stack overflow warnings 2021-11-18 19:16:10 +01:00
e820.c x86/boot: Fix memremap of setup_indirect structures 2022-03-16 14:23:45 +01:00
early-quirks.c x86/gpu: Reserve stolen memory for first integrated Intel GPU 2022-01-27 11:02:51 +01:00
early_printk.c
ebda.c
eisa.c
espfix_64.c
ftrace.c x86/ftrace: Use alternative RET encoding 2022-08-21 15:17:48 +02:00
ftrace_32.S x86: Prepare asm files for straight-line-speculation 2022-05-15 20:18:49 +02:00
ftrace_64.S x86/ibt,ftrace: Make function-graph play nice 2022-08-21 15:17:48 +02:00
head32.c
head64.c x86: Clear .brk area at early boot 2022-07-21 21:24:40 +02:00
head_32.S x86/asm/32: Fix ANNOTATE_UNRET_SAFE use on 32-bit 2022-07-23 12:54:12 +02:00
head_64.S objtool: Add entry UNRET validation 2022-07-23 12:54:06 +02:00
hpet.c rtc: Check return value from mc146818_get_time() 2022-04-13 20:59:14 +02:00
hw_breakpoint.c x86/debug: Prevent data breakpoints on cpu_dr7 2021-02-05 20:13:12 +01:00
i8237.c
i8253.c
i8259.c x86: Avoid magic number with ELCR register accesses 2021-08-10 23:31:43 +02: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 2021-11-18 19:15:56 +01:00
irq_32.c softirq: Move do_softirq_own_stack() to generic asm header 2021-02-10 23:34:16 +01:00
irq_64.c x86/softirq/64: Inline do_softirq_own_stack() 2021-02-10 23:34:17 +01:00
irq_work.c
irqflags.S x86: Prepare asm files for straight-line-speculation 2022-05-15 20:18:49 +02:00
irqinit.c
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 2022-03-16 14:23:45 +01:00
kexec-bzimage64.c x86: Use ELF fields defined in 'struct kimage' 2021-03-08 12:06:29 -07:00
kgdb.c x86: Fix various typos in comments 2021-03-18 15:31:53 +01:00
ksysfs.c x86/boot: Fix memremap of setup_indirect structures 2022-03-16 14:23:45 +01:00
kvm.c x86, kvm: use proper ASM macros for kvm_vcpu_is_preempted 2022-07-02 16:41:12 +02: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 2022-06-09 10:22:29 +02:00
Makefile x86/sev: Add an x86 version of cc_platform_has() 2021-11-18 19:17:21 +01:00
mmconf-fam10h_64.c x86/msr: Rename MSR_K8_SYSCFG to MSR_AMD64_SYSCFG 2021-05-10 07:51:38 +02:00
module.c x86: Undo return-thunk damage 2022-07-23 12:53:58 +02:00
mpparse.c x86: Avoid magic number with ELCR register accesses 2021-08-10 23:31:43 +02:00
msr.c x86/MSR: Filter MSR writes through X86_IOC_WRMSR_REGS ioctl too 2021-01-27 19:06:47 +01:00
nmi.c x86/sev-es: Rename sev-es.{ch} to sev.{ch} 2021-05-10 07:40:27 +02:00
nmi_selftest.c
paravirt-spinlocks.c x86/paravirt: Add new features for paravirt patching 2021-03-11 19:51:49 +01:00
paravirt.c x86: Prepare inline-asm for straight-line-speculation 2022-05-15 20:18:50 +02:00
pci-dma.c
pci-iommu_table.c x86: Remove definition of DEBUG 2021-01-15 08:23:10 +01:00
pci-swiotlb.c
pcspeaker.c
perf_regs.c - Remove all uses of TIF_IA32 and TIF_X32 and reclaim the two bits in the end 2020-12-14 13:45:26 -08:00
platform-quirks.c
pmem.c x86/pmem: Fix platform-device leak in error path 2022-08-17 14:23:07 +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:28:42 +01:00
process.h
process_32.c
process_64.c x86/fpu: Add PKRU storage outside of task XSAVE buffer 2021-06-23 19:37:45 +02:00
ptrace.c x86/ptrace: Fix xfpregs_set()'s incorrect xmm clearing 2022-03-02 11:47:47 +01:00
pvclock.c x86: Fix various typos in comments 2021-03-18 15:31:53 +01:00
quirks.c
reboot.c x86/mm: Flush global TLB when switching to trampoline page-table 2022-01-27 11:04:35 +01:00
reboot_fixups_32.c
relocate_kernel_32.S x86/kexec: Disable RET on kexec 2022-07-23 12:54:11 +02:00
relocate_kernel_64.S x86/kexec: Disable RET on kexec 2022-07-23 12:54:11 +02:00
resource.c
rtc.c
setup.c x86/boot: Fix memremap of setup_indirect structures 2022-03-16 14:23:45 +01: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 2021-12-08 09:04:53 +01:00
sev_verify_cbit.S x86: Prepare asm files for straight-line-speculation 2022-05-15 20:18:49 +02:00
signal.c Fixes and improvements for FPU handling on x86: 2021-07-07 11:12:01 -07:00
signal_compat.c signal: Deliver SIGTRAP on perf event asynchronously if blocked 2022-06-09 10:22:48 +02:00
smp.c x86: Fix various typos in comments, take #2 2021-03-21 23:50:28 +01:00
smpboot.c x86/smp: Add a per-cpu view of SMT state 2021-07-28 11:42:23 +02:00
stacktrace.c stacktrace: Move documentation for arch_stack_walk_reliable() to header 2021-03-10 15:52:31 +01:00
static_call.c x86/static_call: Serialize __static_call_fixup() properly 2022-07-23 12:54:11 +02:00
step.c ptrace: Reimplement PTRACE_KILL by always sending SIGKILL 2022-06-09 10:22:29 +02:00
sys_ia32.c
sys_x86_64.c x86/mm: Cleanup the control_va_addr_alignment() __setup handler 2022-06-09 10:22:54 +02:00
tboot.c x86/boot/tboot: Avoid Wstringop-overread-warning 2021-03-23 00:16:13 +01:00
time.c
tls.c x86/stackprotector/32: Make the canary into a regular percpu variable 2021-03-08 13:19:05 +01:00
tls.h
topology.c x86: Fix various typos in comments 2021-03-18 15:31:53 +01:00
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/traps: Use pt_regs directly in fixup_bad_iret() 2022-07-23 12:53:47 +02:00
tsc.c x86/tsc: Disable clocksource watchdog for TSC on qualified platorms 2021-12-08 09:04:56 +01:00
tsc_msr.c
tsc_sync.c x86/tsc: Add a timer to make sure TSC_adjust is always checked 2021-12-08 09:04:56 +01: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 2022-11-03 23:59:16 +09:00
uprobes.c x86/uprobes: Convert to insn_decode() 2021-03-15 12:05:03 +01:00
verify_cpu.S x86: Prepare asm files for straight-line-speculation 2022-05-15 20:18:49 +02:00
vm86_32.c signal: Replace force_fatal_sig with force_exit_sig when in doubt 2021-11-25 09:49:07 +01:00
vmlinux.lds.S x86: Add magic AMD return-thunk 2022-07-23 12:54:01 +02:00
vsmp_64.c
x86_init.c