0276-x86-idle-Disable-IBRS-when-offlining-cpu-and-re-enab.patch 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: Tim Chen <[email protected]>
  3. Date: Wed, 15 Nov 2017 12:24:19 -0800
  4. Subject: [PATCH] x86/idle: Disable IBRS when offlining cpu and re-enable on
  5. wakeup
  6. MIME-Version: 1.0
  7. Content-Type: text/plain; charset=UTF-8
  8. Content-Transfer-Encoding: 8bit
  9. CVE-2017-5753
  10. CVE-2017-5715
  11. Clear IBRS when cpu is offlined and set it when brining it back online.
  12. Signed-off-by: Tim Chen <[email protected]>
  13. Signed-off-by: Andy Whitcroft <[email protected]>
  14. Signed-off-by: Kleber Sacilotto de Souza <[email protected]>
  15. (cherry picked from commit 9bcf662c1690880b2464fe99d0f58dce53c0d89f)
  16. Signed-off-by: Fabian Grünbichler <[email protected]>
  17. ---
  18. arch/x86/kernel/smpboot.c | 7 +++++++
  19. 1 file changed, 7 insertions(+)
  20. diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
  21. index 398e8324fea4..a652bff7add4 100644
  22. --- a/arch/x86/kernel/smpboot.c
  23. +++ b/arch/x86/kernel/smpboot.c
  24. @@ -77,6 +77,7 @@
  25. #include <asm/i8259.h>
  26. #include <asm/realmode.h>
  27. #include <asm/misc.h>
  28. +#include <asm/microcode.h>
  29. /* Number of siblings per CPU package */
  30. int smp_num_siblings = 1;
  31. @@ -1692,9 +1693,15 @@ void native_play_dead(void)
  32. play_dead_common();
  33. tboot_shutdown(TB_SHUTDOWN_WFS);
  34. + if (boot_cpu_has(X86_FEATURE_SPEC_CTRL))
  35. + native_wrmsrl(MSR_IA32_SPEC_CTRL, 0);
  36. +
  37. mwait_play_dead(); /* Only returns on failure */
  38. if (cpuidle_play_dead())
  39. hlt_play_dead();
  40. +
  41. + if (boot_cpu_has(X86_FEATURE_SPEC_CTRL))
  42. + native_wrmsrl(MSR_IA32_SPEC_CTRL, FEATURE_ENABLE_IBRS);
  43. }
  44. #else /* ... !CONFIG_HOTPLUG_CPU */
  45. --
  46. 2.14.2