0015-x86-mm-Add-the-nopcid-boot-option-to-turn-off-PCID.patch 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. From 95e4ae0f4ad738ff6ec8e44ab9fa5529d4369655 Mon Sep 17 00:00:00 2001
  2. From: Andy Lutomirski <[email protected]>
  3. Date: Thu, 29 Jun 2017 08:53:20 -0700
  4. Subject: [PATCH 015/232] x86/mm: Add the 'nopcid' boot option to turn off PCID
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. CVE-2017-5754
  9. The parameter is only present on x86_64 systems to save a few bytes,
  10. as PCID is always disabled on x86_32.
  11. Signed-off-by: Andy Lutomirski <[email protected]>
  12. Reviewed-by: Nadav Amit <[email protected]>
  13. Reviewed-by: Borislav Petkov <[email protected]>
  14. Reviewed-by: Thomas Gleixner <[email protected]>
  15. Cc: Andrew Morton <[email protected]>
  16. Cc: Arjan van de Ven <[email protected]>
  17. Cc: Borislav Petkov <[email protected]>
  18. Cc: Dave Hansen <[email protected]>
  19. Cc: Linus Torvalds <[email protected]>
  20. Cc: Mel Gorman <[email protected]>
  21. Cc: Peter Zijlstra <[email protected]>
  22. Cc: Rik van Riel <[email protected]>
  23. Cc: [email protected]
  24. Link: http://lkml.kernel.org/r/8bbb2e65bcd249a5f18bfb8128b4689f08ac2b60.1498751203.git.luto@kernel.org
  25. Signed-off-by: Ingo Molnar <[email protected]>
  26. (cherry picked from commit 0790c9aad84901ca1bdc14746175549c8b5da215)
  27. Signed-off-by: Andy Whitcroft <[email protected]>
  28. Signed-off-by: Kleber Sacilotto de Souza <[email protected]>
  29. (cherry picked from commit 62d3a63645c17611fe8ccc0c5adc5e840d9cff7b)
  30. Signed-off-by: Fabian Grünbichler <[email protected]>
  31. ---
  32. Documentation/admin-guide/kernel-parameters.txt | 2 ++
  33. arch/x86/kernel/cpu/common.c | 18 ++++++++++++++++++
  34. 2 files changed, 20 insertions(+)
  35. diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
  36. index 73fd6abac39b..3510e255ef4c 100644
  37. --- a/Documentation/admin-guide/kernel-parameters.txt
  38. +++ b/Documentation/admin-guide/kernel-parameters.txt
  39. @@ -2700,6 +2700,8 @@
  40. nopat [X86] Disable PAT (page attribute table extension of
  41. pagetables) support.
  42. + nopcid [X86-64] Disable the PCID cpu feature.
  43. +
  44. norandmaps Don't use address space randomization. Equivalent to
  45. echo 0 > /proc/sys/kernel/randomize_va_space
  46. diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
  47. index c8b39870f33e..904485e7b230 100644
  48. --- a/arch/x86/kernel/cpu/common.c
  49. +++ b/arch/x86/kernel/cpu/common.c
  50. @@ -168,6 +168,24 @@ static int __init x86_mpx_setup(char *s)
  51. }
  52. __setup("nompx", x86_mpx_setup);
  53. +#ifdef CONFIG_X86_64
  54. +static int __init x86_pcid_setup(char *s)
  55. +{
  56. + /* require an exact match without trailing characters */
  57. + if (strlen(s))
  58. + return 0;
  59. +
  60. + /* do not emit a message if the feature is not present */
  61. + if (!boot_cpu_has(X86_FEATURE_PCID))
  62. + return 1;
  63. +
  64. + setup_clear_cpu_cap(X86_FEATURE_PCID);
  65. + pr_info("nopcid: PCID feature disabled\n");
  66. + return 1;
  67. +}
  68. +__setup("nopcid", x86_pcid_setup);
  69. +#endif
  70. +
  71. static int __init x86_noinvpcid_setup(char *s)
  72. {
  73. /* noinvpcid doesn't accept parameters */
  74. --
  75. 2.14.2