| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- From f9bdf4dc3a7719aa39df4abe58efe3db3fb8b037 Mon Sep 17 00:00:00 2001
- From: Thomas Gleixner <[email protected]>
- Date: Mon, 4 Dec 2017 15:07:32 +0100
- Subject: [PATCH 162/232] x86/cpufeatures: Make CPU bugs sticky
- MIME-Version: 1.0
- Content-Type: text/plain; charset=UTF-8
- Content-Transfer-Encoding: 8bit
- CVE-2017-5754
- There is currently no way to force CPU bug bits like CPU feature bits. That
- makes it impossible to set a bug bit once at boot and have it stick for all
- upcoming CPUs.
- Extend the force set/clear arrays to handle bug bits as well.
- Signed-off-by: Thomas Gleixner <[email protected]>
- Reviewed-by: Borislav Petkov <[email protected]>
- Cc: Andy Lutomirski <[email protected]>
- Cc: Boris Ostrovsky <[email protected]>
- Cc: Borislav Petkov <[email protected]>
- Cc: Borislav Petkov <[email protected]>
- Cc: Brian Gerst <[email protected]>
- Cc: Dave Hansen <[email protected]>
- Cc: Dave Hansen <[email protected]>
- Cc: David Laight <[email protected]>
- Cc: Denys Vlasenko <[email protected]>
- Cc: Eduardo Valentin <[email protected]>
- Cc: Greg KH <[email protected]>
- Cc: H. Peter Anvin <[email protected]>
- Cc: Josh Poimboeuf <[email protected]>
- Cc: Juergen Gross <[email protected]>
- Cc: Linus Torvalds <[email protected]>
- Cc: Peter Zijlstra <[email protected]>
- Cc: Rik van Riel <[email protected]>
- Cc: Will Deacon <[email protected]>
- Cc: [email protected]
- Cc: [email protected]
- Cc: [email protected]
- Cc: [email protected]
- Link: https://lkml.kernel.org/r/[email protected]
- Signed-off-by: Ingo Molnar <[email protected]>
- (cherry picked from commit 6cbd2171e89b13377261d15e64384df60ecb530e)
- Signed-off-by: Andy Whitcroft <[email protected]>
- Signed-off-by: Kleber Sacilotto de Souza <[email protected]>
- (cherry picked from commit aab40a666a40cd015ca4a53231bed544fc679dcb)
- Signed-off-by: Fabian Grünbichler <[email protected]>
- ---
- arch/x86/include/asm/cpufeature.h | 2 ++
- arch/x86/include/asm/processor.h | 4 ++--
- arch/x86/kernel/cpu/common.c | 6 +++---
- 3 files changed, 7 insertions(+), 5 deletions(-)
- diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
- index 225fd8374fae..8b9915561ed1 100644
- --- a/arch/x86/include/asm/cpufeature.h
- +++ b/arch/x86/include/asm/cpufeature.h
- @@ -134,6 +134,8 @@ extern void clear_cpu_cap(struct cpuinfo_x86 *c, unsigned int bit);
- set_bit(bit, (unsigned long *)cpu_caps_set); \
- } while (0)
-
- +#define setup_force_cpu_bug(bit) setup_force_cpu_cap(bit)
- +
- #if defined(CC_HAVE_ASM_GOTO) && defined(CONFIG_X86_FAST_FEATURE_TESTS)
- /*
- * Static testing of CPU features. Used the same as boot_cpu_has().
- diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
- index bccec7ed1676..59a317f8e0ec 100644
- --- a/arch/x86/include/asm/processor.h
- +++ b/arch/x86/include/asm/processor.h
- @@ -162,8 +162,8 @@ extern struct cpuinfo_x86 new_cpu_data;
- #include <linux/thread_info.h>
-
- extern struct x86_hw_tss doublefault_tss;
- -extern __u32 cpu_caps_cleared[NCAPINTS];
- -extern __u32 cpu_caps_set[NCAPINTS];
- +extern __u32 cpu_caps_cleared[NCAPINTS + NBUGINTS];
- +extern __u32 cpu_caps_set[NCAPINTS + NBUGINTS];
-
- #ifdef CONFIG_SMP
- DECLARE_PER_CPU_READ_MOSTLY(struct cpuinfo_x86, cpu_info);
- diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
- index 7992e5a8076c..fcdba90e0890 100644
- --- a/arch/x86/kernel/cpu/common.c
- +++ b/arch/x86/kernel/cpu/common.c
- @@ -452,8 +452,8 @@ static const char *table_lookup_model(struct cpuinfo_x86 *c)
- return NULL; /* Not found */
- }
-
- -__u32 cpu_caps_cleared[NCAPINTS];
- -__u32 cpu_caps_set[NCAPINTS];
- +__u32 cpu_caps_cleared[NCAPINTS + NBUGINTS];
- +__u32 cpu_caps_set[NCAPINTS + NBUGINTS];
-
- void load_percpu_segment(int cpu)
- {
- @@ -812,7 +812,7 @@ static void apply_forced_caps(struct cpuinfo_x86 *c)
- {
- int i;
-
- - for (i = 0; i < NCAPINTS; i++) {
- + for (i = 0; i < NCAPINTS + NBUGINTS; i++) {
- c->x86_capability[i] &= ~cpu_caps_cleared[i];
- c->x86_capability[i] |= cpu_caps_set[i];
- }
- --
- 2.14.2
|