From 5b50ee83a19f8137a69c2cfb3fd829f58b1adbf2 Mon Sep 17 00:00:00 2001 From: Kanth Ghatraju Date: Thu, 11 Jan 2018 16:52:30 -0500 Subject: [PATCH] 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 --- arch/x86/include/asm/cpufeature.h | 5 +++++ arch/x86/kernel/cpu/common.c | 3 +++ 2 files changed, 8 insertions(+) diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h index 3afc42414a4cb..ad042957d1f4b 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 ecc4c2cf47c99..bb29cca8b84a6 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) -- 2.50.1