android_kernel_samsung_univ.../arch/x86/kernel
Thomas Gleixner ea8efcd441 x86/speculation: Handle HT correctly on AMD
commit 1f50ddb4f4189243c05926b842dc1a0332195f31 upstream

The AMD64_LS_CFG MSR is a per core MSR on Family 17H CPUs. That means when
hyperthreading is enabled the SSBD bit toggle needs to take both cores into
account. Otherwise the following situation can happen:

CPU0		CPU1

disable SSB
		disable SSB
		enable  SSB <- Enables it for the Core, i.e. for CPU0 as well

So after the SSB enable on CPU1 the task on CPU0 runs with SSB enabled
again.

On Intel the SSBD control is per core as well, but the synchronization
logic is implemented behind the per thread SPEC_CTRL MSR. It works like
this:

  CORE_SPEC_CTRL = THREAD0_SPEC_CTRL | THREAD1_SPEC_CTRL

i.e. if one of the threads enables a mitigation then this affects both and
the mitigation is only disabled in the core when both threads disabled it.

Add the necessary synchronization logic for AMD family 17H. Unfortunately
that requires a spinlock to serialize the access to the MSR, but the locks
are only shared between siblings.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Srivatsa S. Bhat <srivatsa@csail.mit.edu>
Reviewed-by: Matt Helsley (VMware) <matt.helsley@gmail.com>
Reviewed-by: Alexey Makhalov <amakhalov@vmware.com>
Reviewed-by: Bo Gan <ganb@vmware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-25 10:18:30 +02:00
..
acpi x86/acpi: Reduce code duplication in mp_override_legacy_irq() 2018-01-17 09:35:26 +01:00
apic x86/cpufeature: Replace the old static_cpu_has() with safe variant 2018-07-17 11:31:44 +02:00
cpu x86/cpufeatures: Add FEATURE_ZEN 2018-07-25 10:18:29 +02:00
fpu x86/fpu: Fix math emulation in eager fpu mode 2018-06-16 09:54:25 +02:00
kprobes kprobes/x86: Do not modify singlestep buffer while resuming 2018-07-11 16:03:47 +02:00
.gitignore
alternative.c x86/paravirt: Remove 'noreplace-paravirt' cmdline option 2018-02-25 11:03:54 +01:00
amd_gart_64.c
amd_nb.c x86/amd_nb: Fix boot crash on non-AMD systems 2016-07-27 09:47:29 -07:00
apb_timer.c
aperture_64.c
apm_32.c
asm-offsets_32.c
asm-offsets_64.c
asm-offsets.c
audit_64.c
bootflag.c
check.c
cpuid.c
crash_dump_32.c
crash_dump_64.c
crash.c
devicetree.c x86/devicetree: Fix device IRQ settings in DT 2018-05-30 07:49:13 +02:00
doublefault.c
dumpstack_32.c
dumpstack_64.c
dumpstack.c
e820.c x86/cpufeature: Carve out X86_FEATURE_* 2018-07-17 11:31:44 +02:00
early_printk.c
early-quirks.c drm/i915: Account for TSEG size when determining 865G stolen base 2016-10-31 04:13:58 -06:00
espfix_64.c kaiser: add "nokaiser" boot option, using ALTERNATIVE 2018-01-05 15:44:25 +01:00
ftrace.c ftrace/x86: Fix triple fault with graph tracing and suspend-to-ram 2017-05-02 21:19:56 -07:00
head_32.S x86/cpufeature: Carve out X86_FEATURE_* 2018-07-17 11:31:44 +02:00
head_64.S x86/boot: Simplify kernel load address alignment check 2018-07-17 11:31:45 +02:00
head.c
head32.c
head64.c x86/kasan: Fix boot with KASAN=y and PROFILE_ANNOTATED_BRANCHES=y 2017-03-22 12:04:18 +01:00
hpet.c x86/cpufeature: Carve out X86_FEATURE_* 2018-07-17 11:31:44 +02:00
hw_breakpoint.c x86/cpufeature: Remove unused and seldomly used cpu_has_xx macros 2018-06-16 09:54:24 +02:00
i386_ksyms_32.c x86/hweight: Get rid of the special calling convention 2018-04-24 09:32:04 +02:00
i8237.c
i8253.c
i8259.c x86: i8259: export legacy_pic symbol 2018-03-24 10:58:40 +01:00
io_delay.c
ioport.c x86/iopl: Fix iopl capability check on Xen PV 2016-04-12 09:08:38 -07:00
irq_32.c x86/retpoline/irq32: Convert assembler indirect jumps 2018-01-23 19:50:13 +01:00
irq_64.c
irq_work.c treewide: Remove old email address 2015-11-23 09:44:58 +01:00
irq.c x86/irq: Do not substract irq_tlb_count from irq_call_count 2017-12-25 14:22:09 +01:00
irqflags.S x86/paravirt: Make native_save_fl() extern inline 2018-07-25 10:18:18 +02:00
irqinit.c KAISER: Kernel Address Isolation 2018-01-05 15:44:23 +01:00
jump_label.c
kdebugfs.c
kexec-bzimage64.c
kgdb.c
ksysfs.c
kvm.c KVM: async_pf: make rcu irq exit if not triggered from idle task 2017-08-11 09:08:47 -07:00
kvmclock.c x86/vdso: Get pvclock data from the vvar VMA instead of the fixmap 2018-01-05 15:44:27 +01:00
ldt.c x86/mm: Factor out LDT init from context init 2018-07-25 10:18:21 +02:00
livepatch.c livepatch: Fix crash with !CONFIG_DEBUG_SET_MODULE_RONX 2015-11-06 11:10:03 +01:00
machine_kexec_32.c x86/kexec: Avoid double free_page() upon do_kexec_load() failure 2018-05-26 08:49:01 +02:00
machine_kexec_64.c x86/kexec: Avoid double free_page() upon do_kexec_load() failure 2018-05-26 08:49:01 +02:00
Makefile x86/paravirt: Make native_save_fl() extern inline 2018-07-25 10:18:18 +02:00
mcount_64.S x86/retpoline/ftrace: Convert ftrace assembler indirect jumps 2018-01-23 19:50:13 +01:00
mmconf-fam10h_64.c
module.c x86: Treat R_X86_64_PLT32 as R_X86_64_PC32 2018-03-18 11:17:52 +01:00
mpparse.c
msr.c x86/cpufeature: Carve out X86_FEATURE_* 2018-07-17 11:31:44 +02:00
nmi_selftest.c
nmi.c
paravirt_patch_32.c
paravirt_patch_64.c x86/paravirt: Dont patch flush_tlb_single 2018-01-05 15:44:26 +01:00
paravirt-spinlocks.c
paravirt.c x86/paravirt: Do not trace _paravirt_ident_*() functions 2016-09-24 10:07:37 +02:00
pci-calgary_64.c x86/pci-calgary: Fix iommu_free() comparison of unsigned expression >= 0 2017-05-14 13:32:55 +02:00
pci-dma.c mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd 2015-11-06 17:50:42 -08:00
pci-iommu_table.c
pci-nommu.c
pci-swiotlb.c
pcspeaker.c
perf_regs.c
pmem.c libnvdimm, e820: skip module loading when no type-12 2015-11-30 09:10:33 -08:00
probe_roms.c
process_32.c
process_64.c x86/iopl/64: Properly context-switch IOPL on Xen PV 2016-04-12 09:08:38 -07:00
process.c x86/speculation: Handle HT correctly on AMD 2018-07-25 10:18:30 +02:00
ptrace.c x86/dumpstack: Fix x86_32 kernel_stack_pointer() previous stack access 2016-10-16 17:36:15 +02:00
pvclock.c pvclock: Add CPU barriers to get correct version value 2016-08-10 11:49:27 +02:00
quirks.c
reboot_fixups_32.c
reboot.c x86/mm/64: Fix reboot interaction with CR4.PCIDE 2018-01-02 20:33:24 +01:00
relocate_kernel_32.S
relocate_kernel_64.S
resource.c
rtc.c x86/paravirt: Prevent rtc_cmos platform device init on PV guests 2015-12-19 21:35:13 +01:00
setup_percpu.c
setup.c x86/kaiser: Move feature detection up 2018-01-05 15:44:26 +01:00
signal_compat.c
signal.c x86/signal: Fix restart_syscall number for x32 tasks 2015-12-05 18:52:14 +01:00
smp.c
smpboot.c x86/speculation: Handle HT correctly on AMD 2018-07-25 10:18:30 +02:00
stacktrace.c
step.c
sys_x86_64.c mm: larger stack guard gap, between vmas 2017-06-26 07:13:11 +02:00
sysfb_efi.c x86/sysfb_efi: Fix valid BAR address range check 2016-05-11 11:21:20 +02:00
sysfb_simplefb.c
sysfb.c
tboot.c x86/pti: Make unpoison of pgd for trusted boot work for real 2018-02-03 17:04:25 +01:00
tce_64.c
test_nx.c
test_rodata.c
time.c
tls.c
tls.h
topology.c
trace_clock.c
tracepoint.c kaiser: merged update 2018-01-05 15:44:23 +01:00
traps.c x86/fpu: Fix math emulation in eager fpu mode 2018-06-16 09:54:25 +02:00
tsc_msr.c x86/tsc: Read all ratio bits from MSR_PLATFORM_INFO 2016-05-11 11:21:19 +02:00
tsc_sync.c
tsc.c x86/tsc: Prevent 32bit truncation in calc_hpet_ref() 2018-04-29 07:50:01 +02:00
uprobes.c uprobes/x86: Remove incorrect WARN_ON() in uprobe_init_insn() 2018-07-17 11:31:45 +02:00
verify_cpu.S x86/cpufeature: Carve out X86_FEATURE_* 2018-07-17 11:31:44 +02:00
vm86_32.c x86/cpufeature: Replace the old static_cpu_has() with safe variant 2018-07-17 11:31:44 +02:00
vmlinux.lds.S x86/alternatives: Add an auxilary section 2018-07-17 11:31:44 +02:00
vsmp_64.c
x86_init.c
x8664_ksyms_64.c x86/hweight: Get rid of the special calling convention 2018-04-24 09:32:04 +02:00