0178-x86-mm-Add-comments-to-clarify-which-TLB-flush-funct.patch 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. From 0e75b184111dbcd07911712bd87991df186c5fd3 Mon Sep 17 00:00:00 2001
  2. From: Peter Zijlstra <[email protected]>
  3. Date: Tue, 5 Dec 2017 13:34:52 +0100
  4. Subject: [PATCH 178/242] x86/mm: Add comments to clarify which TLB-flush
  5. functions are supposed to flush what
  6. MIME-Version: 1.0
  7. Content-Type: text/plain; charset=UTF-8
  8. Content-Transfer-Encoding: 8bit
  9. CVE-2017-5754
  10. Per popular request..
  11. Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
  12. Signed-off-by: Thomas Gleixner <[email protected]>
  13. Cc: Andy Lutomirski <[email protected]>
  14. Cc: Boris Ostrovsky <[email protected]>
  15. Cc: Borislav Petkov <[email protected]>
  16. Cc: Brian Gerst <[email protected]>
  17. Cc: Dave Hansen <[email protected]>
  18. Cc: David Laight <[email protected]>
  19. Cc: Denys Vlasenko <[email protected]>
  20. Cc: Eduardo Valentin <[email protected]>
  21. Cc: Greg KH <[email protected]>
  22. Cc: H. Peter Anvin <[email protected]>
  23. Cc: Josh Poimboeuf <[email protected]>
  24. Cc: Juergen Gross <[email protected]>
  25. Cc: Linus Torvalds <[email protected]>
  26. Cc: Peter Zijlstra <[email protected]>
  27. Cc: Will Deacon <[email protected]>
  28. Cc: [email protected]
  29. Cc: [email protected]
  30. Cc: [email protected]
  31. Cc: [email protected]
  32. Cc: [email protected]
  33. Signed-off-by: Ingo Molnar <[email protected]>
  34. (backported from commit 3f67af51e56f291d7417d77c4f67cd774633c5e1)
  35. Signed-off-by: Andy Whitcroft <[email protected]>
  36. Signed-off-by: Kleber Sacilotto de Souza <[email protected]>
  37. (cherry picked from commit 8394b666c2b3b1fc5279a897c96b196531923f3b)
  38. Signed-off-by: Fabian Grünbichler <[email protected]>
  39. ---
  40. arch/x86/include/asm/tlbflush.h | 24 ++++++++++++++++++++++--
  41. 1 file changed, 22 insertions(+), 2 deletions(-)
  42. diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
  43. index bc1460b4737b..ed5d483c4a1b 100644
  44. --- a/arch/x86/include/asm/tlbflush.h
  45. +++ b/arch/x86/include/asm/tlbflush.h
  46. @@ -216,6 +216,10 @@ static inline void cr4_set_bits_and_update_boot(unsigned long mask)
  47. cr4_set_bits(mask);
  48. }
  49. +
  50. +/*
  51. + * flush the entire current user mapping
  52. + */
  53. static inline void __native_flush_tlb(void)
  54. {
  55. /*
  56. @@ -228,6 +232,9 @@ static inline void __native_flush_tlb(void)
  57. preempt_enable();
  58. }
  59. +/*
  60. + * flush everything
  61. + */
  62. static inline void __native_flush_tlb_global(void)
  63. {
  64. unsigned long cr4, flags;
  65. @@ -257,17 +264,27 @@ static inline void __native_flush_tlb_global(void)
  66. raw_local_irq_restore(flags);
  67. }
  68. +/*
  69. + * flush one page in the user mapping
  70. + */
  71. static inline void __native_flush_tlb_single(unsigned long addr)
  72. {
  73. asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
  74. }
  75. +/*
  76. + * flush everything
  77. + */
  78. static inline void __flush_tlb_all(void)
  79. {
  80. - if (boot_cpu_has(X86_FEATURE_PGE))
  81. + if (boot_cpu_has(X86_FEATURE_PGE)) {
  82. __flush_tlb_global();
  83. - else
  84. + } else {
  85. + /*
  86. + * !PGE -> !PCID (setup_pcid()), thus every flush is total.
  87. + */
  88. __flush_tlb();
  89. + }
  90. /*
  91. * Note: if we somehow had PCID but not PGE, then this wouldn't work --
  92. @@ -278,6 +295,9 @@ static inline void __flush_tlb_all(void)
  93. */
  94. }
  95. +/*
  96. + * flush one page in the kernel mapping
  97. + */
  98. static inline void __flush_tlb_one(unsigned long addr)
  99. {
  100. count_vm_tlb_event(NR_TLB_LOCAL_FLUSH_ONE);
  101. --
  102. 2.14.2