0162-x86-cpufeatures-Make-CPU-bugs-sticky.patch 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. From f9bdf4dc3a7719aa39df4abe58efe3db3fb8b037 Mon Sep 17 00:00:00 2001
  2. From: Thomas Gleixner <[email protected]>
  3. Date: Mon, 4 Dec 2017 15:07:32 +0100
  4. Subject: [PATCH 162/232] x86/cpufeatures: Make CPU bugs sticky
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. CVE-2017-5754
  9. There is currently no way to force CPU bug bits like CPU feature bits. That
  10. makes it impossible to set a bug bit once at boot and have it stick for all
  11. upcoming CPUs.
  12. Extend the force set/clear arrays to handle bug bits as well.
  13. Signed-off-by: Thomas Gleixner <[email protected]>
  14. Reviewed-by: Borislav Petkov <[email protected]>
  15. Cc: Andy Lutomirski <[email protected]>
  16. Cc: Boris Ostrovsky <[email protected]>
  17. Cc: Borislav Petkov <[email protected]>
  18. Cc: Borislav Petkov <[email protected]>
  19. Cc: Brian Gerst <[email protected]>
  20. Cc: Dave Hansen <[email protected]>
  21. Cc: Dave Hansen <[email protected]>
  22. Cc: David Laight <[email protected]>
  23. Cc: Denys Vlasenko <[email protected]>
  24. Cc: Eduardo Valentin <[email protected]>
  25. Cc: Greg KH <[email protected]>
  26. Cc: H. Peter Anvin <[email protected]>
  27. Cc: Josh Poimboeuf <[email protected]>
  28. Cc: Juergen Gross <[email protected]>
  29. Cc: Linus Torvalds <[email protected]>
  30. Cc: Peter Zijlstra <[email protected]>
  31. Cc: Rik van Riel <[email protected]>
  32. Cc: Will Deacon <[email protected]>
  33. Cc: [email protected]
  34. Cc: [email protected]
  35. Cc: [email protected]
  36. Cc: [email protected]
  37. Link: https://lkml.kernel.org/r/[email protected]
  38. Signed-off-by: Ingo Molnar <[email protected]>
  39. (cherry picked from commit 6cbd2171e89b13377261d15e64384df60ecb530e)
  40. Signed-off-by: Andy Whitcroft <[email protected]>
  41. Signed-off-by: Kleber Sacilotto de Souza <[email protected]>
  42. (cherry picked from commit aab40a666a40cd015ca4a53231bed544fc679dcb)
  43. Signed-off-by: Fabian Grünbichler <[email protected]>
  44. ---
  45. arch/x86/include/asm/cpufeature.h | 2 ++
  46. arch/x86/include/asm/processor.h | 4 ++--
  47. arch/x86/kernel/cpu/common.c | 6 +++---
  48. 3 files changed, 7 insertions(+), 5 deletions(-)
  49. diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
  50. index 225fd8374fae..8b9915561ed1 100644
  51. --- a/arch/x86/include/asm/cpufeature.h
  52. +++ b/arch/x86/include/asm/cpufeature.h
  53. @@ -134,6 +134,8 @@ extern void clear_cpu_cap(struct cpuinfo_x86 *c, unsigned int bit);
  54. set_bit(bit, (unsigned long *)cpu_caps_set); \
  55. } while (0)
  56. +#define setup_force_cpu_bug(bit) setup_force_cpu_cap(bit)
  57. +
  58. #if defined(CC_HAVE_ASM_GOTO) && defined(CONFIG_X86_FAST_FEATURE_TESTS)
  59. /*
  60. * Static testing of CPU features. Used the same as boot_cpu_has().
  61. diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
  62. index bccec7ed1676..59a317f8e0ec 100644
  63. --- a/arch/x86/include/asm/processor.h
  64. +++ b/arch/x86/include/asm/processor.h
  65. @@ -162,8 +162,8 @@ extern struct cpuinfo_x86 new_cpu_data;
  66. #include <linux/thread_info.h>
  67. extern struct x86_hw_tss doublefault_tss;
  68. -extern __u32 cpu_caps_cleared[NCAPINTS];
  69. -extern __u32 cpu_caps_set[NCAPINTS];
  70. +extern __u32 cpu_caps_cleared[NCAPINTS + NBUGINTS];
  71. +extern __u32 cpu_caps_set[NCAPINTS + NBUGINTS];
  72. #ifdef CONFIG_SMP
  73. DECLARE_PER_CPU_READ_MOSTLY(struct cpuinfo_x86, cpu_info);
  74. diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
  75. index 7992e5a8076c..fcdba90e0890 100644
  76. --- a/arch/x86/kernel/cpu/common.c
  77. +++ b/arch/x86/kernel/cpu/common.c
  78. @@ -452,8 +452,8 @@ static const char *table_lookup_model(struct cpuinfo_x86 *c)
  79. return NULL; /* Not found */
  80. }
  81. -__u32 cpu_caps_cleared[NCAPINTS];
  82. -__u32 cpu_caps_set[NCAPINTS];
  83. +__u32 cpu_caps_cleared[NCAPINTS + NBUGINTS];
  84. +__u32 cpu_caps_set[NCAPINTS + NBUGINTS];
  85. void load_percpu_segment(int cpu)
  86. {
  87. @@ -812,7 +812,7 @@ static void apply_forced_caps(struct cpuinfo_x86 *c)
  88. {
  89. int i;
  90. - for (i = 0; i < NCAPINTS; i++) {
  91. + for (i = 0; i < NCAPINTS + NBUGINTS; i++) {
  92. c->x86_capability[i] &= ~cpu_caps_cleared[i];
  93. c->x86_capability[i] |= cpu_caps_set[i];
  94. }
  95. --
  96. 2.14.2