From: David Woodhouse Date: Thu, 25 Jan 2018 16:14:11 +0000 (+0000) Subject: x86/cpufeatures: Add AMD feature bits for Speculation Control X-Git-Tag: v4.1.12-124.31.3~1159 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=b04e47417d9cd3ccda59073f5ce37728bc264b8f;p=users%2Fjedix%2Flinux-maple.git x86/cpufeatures: Add AMD feature bits for Speculation Control AMD exposes the PRED_CMD/SPEC_CTRL MSRs slightly differently to Intel. See http://lkml.kernel.org/r/2b3e25cc-286d-8bd0-aeaf-9ac4aae39de8@amd.com Signed-off-by: David Woodhouse Signed-off-by: Thomas Gleixner Reviewed-by: Greg Kroah-Hartman Cc: Tom Lendacky Cc: gnomes@lxorguk.ukuu.org.uk Cc: ak@linux.intel.com Cc: ashok.raj@intel.com Cc: dave.hansen@intel.com Cc: karahmed@amazon.de Cc: arjan@linux.intel.com Cc: torvalds@linux-foundation.org Cc: peterz@infradead.org Cc: bp@alien8.de Cc: pbonzini@redhat.com Cc: tim.c.chen@linux.intel.com Cc: gregkh@linux-foundation.org Link: https://lkml.kernel.org/r/1516896855-7642-4-git-send-email-dwmw@amazon.co.uk Conflicts: arch/x86/include/asm/cpufeatures.h [Upstream has the NCAPINTS raised so there is another array to stuff all the 0x80000008 cpuid leaf in. But we don't have that so we just toggle the global ones] Orabug: 27477743 CVE: CVE-2017-5715 Signed-off-by: Konrad Rzeszutek Wilk --- diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index b4b794f11022..892972ff4137 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -754,9 +754,13 @@ void get_cpu_cap(struct cpuinfo_x86 *c) c->x86_virt_bits = (eax >> 8) & 0xff; c->x86_phys_bits = eax & 0xff; - /* Only look for X86_FEATURE_IBPB. */ + /* Only look for X86_FEATURE_{IBPB, SPEC_CTRL, STIBP}. */ if (ebx & BIT(12)) set_cpu_cap(c, X86_FEATURE_IBPB); + if (ebx & BIT(14)) + set_cpu_cap(c, X86_FEATURE_SPEC_CTRL); + if (ebx & BIT(15)) + set_cpu_cap(c, X86_FEATURE_STIPB); } #ifdef CONFIG_X86_32 else if (cpu_has(c, X86_FEATURE_PAE) || cpu_has(c, X86_FEATURE_PSE36))