From: Kanth Ghatraju Date: Thu, 11 Jan 2018 21:52:30 +0000 (-0500) Subject: x86/cpufeatures: Add X86_BUG_CPU_MELTDOWN X-Git-Tag: v4.1.12-124.31.3~1264 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=5b50ee83a19f8137a69c2cfb3fd829f58b1adbf2;p=users%2Fjedix%2Flinux-maple.git x86/cpufeatures: Add X86_BUG_CPU_MELTDOWN Add the BUG bit to indicate that the CPU is affected by the leak due to lack of isolation of kernel and user space page tables. Currently AMD CPUs are not affected by this. Orabug: 27353383 Signed-off-by: Kanth Ghatraju Reviewed-by: Darren Kenny Reviewed-by: Konrad Rzeszutek Wilk Signed-off-by: Konrad Rzeszutek Wilk --- diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h index 3afc42414a4c..ad042957d1f4 100644 --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h @@ -280,6 +280,9 @@ #define X86_BUG_CLFLUSH_MONITOR X86_BUG(7) /* AAI65, CLFLUSH required before MONITOR */ #define X86_BUG_SYSRET_SS_ATTRS X86_BUG(8) /* SYSRET doesn't fix up SS attrs */ +/*Keep the bits consistent with upstream */ +#define X86_BUG_CPU_MELTDOWN X86_BUG(14) /* CPU is insecure and need PTI */ + #if defined(__KERNEL__) && !defined(__ASSEMBLY__) #include @@ -361,6 +364,8 @@ extern const char * const x86_bug_flags[NBUGINTS*32]; set_bit(bit, (unsigned long *)cpu_caps_set); \ } while (0) +#define setup_force_cpu_bug(bit) setup_force_cpu_cap(bit) + #define cpu_has_fpu boot_cpu_has(X86_FEATURE_FPU) #define cpu_has_de boot_cpu_has(X86_FEATURE_DE) #define cpu_has_pse boot_cpu_has(X86_FEATURE_PSE) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index ecc4c2cf47c9..bb29cca8b84a 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -842,6 +842,9 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c) this_cpu->c_bsp_init(c); setup_force_cpu_cap(X86_FEATURE_ALWAYS); + + if (c->x86_vendor != X86_VENDOR_AMD) + setup_force_cpu_bug(X86_BUG_CPU_MELTDOWN); } void __init early_cpu_init(void)