]> www.infradead.org Git - users/jedix/linux-maple.git/commit
x86/speculation: Handle HT correctly on AMD
authorThomas Gleixner <tglx@linutronix.de>
Wed, 9 May 2018 19:53:09 +0000 (21:53 +0200)
committerBrian Maly <brian.maly@oracle.com>
Mon, 4 Jun 2018 17:34:30 +0000 (13:34 -0400)
commit70877876c7e81c04de0db03b263a5e68f5447e70
treec5df5e30a6620ff1a2ac604ef80619764da76a0b
parentc8d942f580e26c3a16696218064e4362b039f351
x86/speculation: Handle HT correctly on AMD

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>
Orabug: 28063992
CVE: CVE-2018-3639

(cherry picked from commit 1f50ddb4)
Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
Signed-off-by: Brian Maly <brian.maly@oracle.com>
Conflicts:
arch/x86/kernel/process.c
arch/x86/kernel/smpboot.c
[Contextual changes: in UEK4 files are pretty different and do not match the diff]

Signed-off-by: Brian Maly <brian.maly@oracle.com>
arch/x86/include/asm/spec-ctrl.h
arch/x86/kernel/process.c
arch/x86/kernel/smpboot.c