tlbflush.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. /*
  2. * arch/arm/include/asm/tlbflush.h
  3. *
  4. * Copyright (C) 1999-2003 Russell King
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #ifndef _ASMARM_TLBFLUSH_H
  11. #define _ASMARM_TLBFLUSH_H
  12. #ifdef CONFIG_MMU
  13. #include <asm/glue.h>
  14. #define TLB_V3_PAGE (1 << 0)
  15. #define TLB_V4_U_PAGE (1 << 1)
  16. #define TLB_V4_D_PAGE (1 << 2)
  17. #define TLB_V4_I_PAGE (1 << 3)
  18. #define TLB_V6_U_PAGE (1 << 4)
  19. #define TLB_V6_D_PAGE (1 << 5)
  20. #define TLB_V6_I_PAGE (1 << 6)
  21. #define TLB_V3_FULL (1 << 8)
  22. #define TLB_V4_U_FULL (1 << 9)
  23. #define TLB_V4_D_FULL (1 << 10)
  24. #define TLB_V4_I_FULL (1 << 11)
  25. #define TLB_V6_U_FULL (1 << 12)
  26. #define TLB_V6_D_FULL (1 << 13)
  27. #define TLB_V6_I_FULL (1 << 14)
  28. #define TLB_V6_U_ASID (1 << 16)
  29. #define TLB_V6_D_ASID (1 << 17)
  30. #define TLB_V6_I_ASID (1 << 18)
  31. #define TLB_BTB (1 << 28)
  32. /* Unified Inner Shareable TLB operations (ARMv7 MP extensions) */
  33. #define TLB_V7_UIS_PAGE (1 << 19)
  34. #define TLB_V7_UIS_FULL (1 << 20)
  35. #define TLB_V7_UIS_ASID (1 << 21)
  36. /* Inner Shareable BTB operation (ARMv7 MP extensions) */
  37. #define TLB_V7_IS_BTB (1 << 22)
  38. #define TLB_L2CLEAN_FR (1 << 29) /* Feroceon */
  39. #define TLB_DCLEAN (1 << 30)
  40. #define TLB_WB (1 << 31)
  41. /*
  42. * MMU TLB Model
  43. * =============
  44. *
  45. * We have the following to choose from:
  46. * v3 - ARMv3
  47. * v4 - ARMv4 without write buffer
  48. * v4wb - ARMv4 with write buffer without I TLB flush entry instruction
  49. * v4wbi - ARMv4 with write buffer with I TLB flush entry instruction
  50. * fr - Feroceon (v4wbi with non-outer-cacheable page table walks)
  51. * fa - Faraday (v4 with write buffer with UTLB and branch target buffer (BTB))
  52. * v6wbi - ARMv6 with write buffer with I TLB flush entry instruction
  53. * v7wbi - identical to v6wbi
  54. */
  55. #undef _TLB
  56. #undef MULTI_TLB
  57. #ifdef CONFIG_SMP_ON_UP
  58. #define MULTI_TLB 1
  59. #endif
  60. #define v3_tlb_flags (TLB_V3_FULL | TLB_V3_PAGE)
  61. #ifdef CONFIG_CPU_TLB_V3
  62. # define v3_possible_flags v3_tlb_flags
  63. # define v3_always_flags v3_tlb_flags
  64. # ifdef _TLB
  65. # define MULTI_TLB 1
  66. # else
  67. # define _TLB v3
  68. # endif
  69. #else
  70. # define v3_possible_flags 0
  71. # define v3_always_flags (-1UL)
  72. #endif
  73. #define v4_tlb_flags (TLB_V4_U_FULL | TLB_V4_U_PAGE)
  74. #ifdef CONFIG_CPU_TLB_V4WT
  75. # define v4_possible_flags v4_tlb_flags
  76. # define v4_always_flags v4_tlb_flags
  77. # ifdef _TLB
  78. # define MULTI_TLB 1
  79. # else
  80. # define _TLB v4
  81. # endif
  82. #else
  83. # define v4_possible_flags 0
  84. # define v4_always_flags (-1UL)
  85. #endif
  86. #define fa_tlb_flags (TLB_WB | TLB_BTB | TLB_DCLEAN | \
  87. TLB_V4_U_FULL | TLB_V4_U_PAGE)
  88. #ifdef CONFIG_CPU_TLB_FA
  89. # define fa_possible_flags fa_tlb_flags
  90. # define fa_always_flags fa_tlb_flags
  91. # ifdef _TLB
  92. # define MULTI_TLB 1
  93. # else
  94. # define _TLB fa
  95. # endif
  96. #else
  97. # define fa_possible_flags 0
  98. # define fa_always_flags (-1UL)
  99. #endif
  100. #define v4wbi_tlb_flags (TLB_WB | TLB_DCLEAN | \
  101. TLB_V4_I_FULL | TLB_V4_D_FULL | \
  102. TLB_V4_I_PAGE | TLB_V4_D_PAGE)
  103. #ifdef CONFIG_CPU_TLB_V4WBI
  104. # define v4wbi_possible_flags v4wbi_tlb_flags
  105. # define v4wbi_always_flags v4wbi_tlb_flags
  106. # ifdef _TLB
  107. # define MULTI_TLB 1
  108. # else
  109. # define _TLB v4wbi
  110. # endif
  111. #else
  112. # define v4wbi_possible_flags 0
  113. # define v4wbi_always_flags (-1UL)
  114. #endif
  115. #define fr_tlb_flags (TLB_WB | TLB_DCLEAN | TLB_L2CLEAN_FR | \
  116. TLB_V4_I_FULL | TLB_V4_D_FULL | \
  117. TLB_V4_I_PAGE | TLB_V4_D_PAGE)
  118. #ifdef CONFIG_CPU_TLB_FEROCEON
  119. # define fr_possible_flags fr_tlb_flags
  120. # define fr_always_flags fr_tlb_flags
  121. # ifdef _TLB
  122. # define MULTI_TLB 1
  123. # else
  124. # define _TLB v4wbi
  125. # endif
  126. #else
  127. # define fr_possible_flags 0
  128. # define fr_always_flags (-1UL)
  129. #endif
  130. #define v4wb_tlb_flags (TLB_WB | TLB_DCLEAN | \
  131. TLB_V4_I_FULL | TLB_V4_D_FULL | \
  132. TLB_V4_D_PAGE)
  133. #ifdef CONFIG_CPU_TLB_V4WB
  134. # define v4wb_possible_flags v4wb_tlb_flags
  135. # define v4wb_always_flags v4wb_tlb_flags
  136. # ifdef _TLB
  137. # define MULTI_TLB 1
  138. # else
  139. # define _TLB v4wb
  140. # endif
  141. #else
  142. # define v4wb_possible_flags 0
  143. # define v4wb_always_flags (-1UL)
  144. #endif
  145. #define v6wbi_tlb_flags (TLB_WB | TLB_DCLEAN | TLB_BTB | \
  146. TLB_V6_I_FULL | TLB_V6_D_FULL | \
  147. TLB_V6_I_PAGE | TLB_V6_D_PAGE | \
  148. TLB_V6_I_ASID | TLB_V6_D_ASID)
  149. #ifdef CONFIG_CPU_TLB_V6
  150. # define v6wbi_possible_flags v6wbi_tlb_flags
  151. # define v6wbi_always_flags v6wbi_tlb_flags
  152. # ifdef _TLB
  153. # define MULTI_TLB 1
  154. # else
  155. # define _TLB v6wbi
  156. # endif
  157. #else
  158. # define v6wbi_possible_flags 0
  159. # define v6wbi_always_flags (-1UL)
  160. #endif
  161. #define v7wbi_tlb_flags_smp (TLB_WB | TLB_DCLEAN | TLB_V7_IS_BTB | \
  162. TLB_V7_UIS_FULL | TLB_V7_UIS_PAGE | TLB_V7_UIS_ASID)
  163. #define v7wbi_tlb_flags_up (TLB_WB | TLB_DCLEAN | TLB_BTB | \
  164. TLB_V6_U_FULL | TLB_V6_U_PAGE | TLB_V6_U_ASID)
  165. #ifdef CONFIG_CPU_TLB_V7
  166. # ifdef CONFIG_SMP_ON_UP
  167. # define v7wbi_possible_flags (v7wbi_tlb_flags_smp | v7wbi_tlb_flags_up)
  168. # define v7wbi_always_flags (v7wbi_tlb_flags_smp & v7wbi_tlb_flags_up)
  169. # elif defined(CONFIG_SMP)
  170. # define v7wbi_possible_flags v7wbi_tlb_flags_smp
  171. # define v7wbi_always_flags v7wbi_tlb_flags_smp
  172. # else
  173. # define v7wbi_possible_flags v7wbi_tlb_flags_up
  174. # define v7wbi_always_flags v7wbi_tlb_flags_up
  175. # endif
  176. # ifdef _TLB
  177. # define MULTI_TLB 1
  178. # else
  179. # define _TLB v7wbi
  180. # endif
  181. #else
  182. # define v7wbi_possible_flags 0
  183. # define v7wbi_always_flags (-1UL)
  184. #endif
  185. #ifndef _TLB
  186. #error Unknown TLB model
  187. #endif
  188. #ifndef __ASSEMBLY__
  189. #include <linux/sched.h>
  190. struct cpu_tlb_fns {
  191. void (*flush_user_range)(unsigned long, unsigned long, struct vm_area_struct *);
  192. void (*flush_kern_range)(unsigned long, unsigned long);
  193. unsigned long tlb_flags;
  194. };
  195. /*
  196. * Select the calling method
  197. */
  198. #ifdef MULTI_TLB
  199. #define __cpu_flush_user_tlb_range cpu_tlb.flush_user_range
  200. #define __cpu_flush_kern_tlb_range cpu_tlb.flush_kern_range
  201. #else
  202. #define __cpu_flush_user_tlb_range __glue(_TLB,_flush_user_tlb_range)
  203. #define __cpu_flush_kern_tlb_range __glue(_TLB,_flush_kern_tlb_range)
  204. extern void __cpu_flush_user_tlb_range(unsigned long, unsigned long, struct vm_area_struct *);
  205. extern void __cpu_flush_kern_tlb_range(unsigned long, unsigned long);
  206. #endif
  207. extern struct cpu_tlb_fns cpu_tlb;
  208. #define __cpu_tlb_flags cpu_tlb.tlb_flags
  209. /*
  210. * TLB Management
  211. * ==============
  212. *
  213. * The arch/arm/mm/tlb-*.S files implement these methods.
  214. *
  215. * The TLB specific code is expected to perform whatever tests it
  216. * needs to determine if it should invalidate the TLB for each
  217. * call. Start addresses are inclusive and end addresses are
  218. * exclusive; it is safe to round these addresses down.
  219. *
  220. * flush_tlb_all()
  221. *
  222. * Invalidate the entire TLB.
  223. *
  224. * flush_tlb_mm(mm)
  225. *
  226. * Invalidate all TLB entries in a particular address
  227. * space.
  228. * - mm - mm_struct describing address space
  229. *
  230. * flush_tlb_range(mm,start,end)
  231. *
  232. * Invalidate a range of TLB entries in the specified
  233. * address space.
  234. * - mm - mm_struct describing address space
  235. * - start - start address (may not be aligned)
  236. * - end - end address (exclusive, may not be aligned)
  237. *
  238. * flush_tlb_page(vaddr,vma)
  239. *
  240. * Invalidate the specified page in the specified address range.
  241. * - vaddr - virtual address (may not be aligned)
  242. * - vma - vma_struct describing address range
  243. *
  244. * flush_kern_tlb_page(kaddr)
  245. *
  246. * Invalidate the TLB entry for the specified page. The address
  247. * will be in the kernels virtual memory space. Current uses
  248. * only require the D-TLB to be invalidated.
  249. * - kaddr - Kernel virtual memory address
  250. */
  251. /*
  252. * We optimise the code below by:
  253. * - building a set of TLB flags that might be set in __cpu_tlb_flags
  254. * - building a set of TLB flags that will always be set in __cpu_tlb_flags
  255. * - if we're going to need __cpu_tlb_flags, access it once and only once
  256. *
  257. * This allows us to build optimal assembly for the single-CPU type case,
  258. * and as close to optimal given the compiler constrants for multi-CPU
  259. * case. We could do better for the multi-CPU case if the compiler
  260. * implemented the "%?" method, but this has been discontinued due to too
  261. * many people getting it wrong.
  262. */
  263. #define possible_tlb_flags (v3_possible_flags | \
  264. v4_possible_flags | \
  265. v4wbi_possible_flags | \
  266. fr_possible_flags | \
  267. v4wb_possible_flags | \
  268. fa_possible_flags | \
  269. v6wbi_possible_flags | \
  270. v7wbi_possible_flags)
  271. #define always_tlb_flags (v3_always_flags & \
  272. v4_always_flags & \
  273. v4wbi_always_flags & \
  274. fr_always_flags & \
  275. v4wb_always_flags & \
  276. fa_always_flags & \
  277. v6wbi_always_flags & \
  278. v7wbi_always_flags)
  279. #define tlb_flag(f) ((always_tlb_flags & (f)) || (__tlb_flag & possible_tlb_flags & (f)))
  280. static inline void local_flush_tlb_all(void)
  281. {
  282. const int zero = 0;
  283. const unsigned int __tlb_flag = __cpu_tlb_flags;
  284. if (tlb_flag(TLB_WB))
  285. dsb();
  286. if (tlb_flag(TLB_V3_FULL))
  287. asm("mcr p15, 0, %0, c6, c0, 0" : : "r" (zero) : "cc");
  288. if (tlb_flag(TLB_V4_U_FULL | TLB_V6_U_FULL))
  289. asm("mcr p15, 0, %0, c8, c7, 0" : : "r" (zero) : "cc");
  290. if (tlb_flag(TLB_V4_D_FULL | TLB_V6_D_FULL))
  291. asm("mcr p15, 0, %0, c8, c6, 0" : : "r" (zero) : "cc");
  292. if (tlb_flag(TLB_V4_I_FULL | TLB_V6_I_FULL))
  293. asm("mcr p15, 0, %0, c8, c5, 0" : : "r" (zero) : "cc");
  294. if (tlb_flag(TLB_V7_UIS_FULL))
  295. asm("mcr p15, 0, %0, c8, c3, 0" : : "r" (zero) : "cc");
  296. if (tlb_flag(TLB_BTB)) {
  297. /* flush the branch target cache */
  298. asm("mcr p15, 0, %0, c7, c5, 6" : : "r" (zero) : "cc");
  299. dsb();
  300. isb();
  301. }
  302. if (tlb_flag(TLB_V7_IS_BTB)) {
  303. /* flush the branch target cache */
  304. asm("mcr p15, 0, %0, c7, c1, 6" : : "r" (zero) : "cc");
  305. dsb();
  306. isb();
  307. }
  308. }
  309. static inline void local_flush_tlb_mm(struct mm_struct *mm)
  310. {
  311. const int zero = 0;
  312. const int asid = ASID(mm);
  313. const unsigned int __tlb_flag = __cpu_tlb_flags;
  314. if (tlb_flag(TLB_WB))
  315. dsb();
  316. if (cpumask_test_cpu(get_cpu(), mm_cpumask(mm))) {
  317. if (tlb_flag(TLB_V3_FULL))
  318. asm("mcr p15, 0, %0, c6, c0, 0" : : "r" (zero) : "cc");
  319. if (tlb_flag(TLB_V4_U_FULL))
  320. asm("mcr p15, 0, %0, c8, c7, 0" : : "r" (zero) : "cc");
  321. if (tlb_flag(TLB_V4_D_FULL))
  322. asm("mcr p15, 0, %0, c8, c6, 0" : : "r" (zero) : "cc");
  323. if (tlb_flag(TLB_V4_I_FULL))
  324. asm("mcr p15, 0, %0, c8, c5, 0" : : "r" (zero) : "cc");
  325. }
  326. put_cpu();
  327. if (tlb_flag(TLB_V6_U_ASID))
  328. asm("mcr p15, 0, %0, c8, c7, 2" : : "r" (asid) : "cc");
  329. if (tlb_flag(TLB_V6_D_ASID))
  330. asm("mcr p15, 0, %0, c8, c6, 2" : : "r" (asid) : "cc");
  331. if (tlb_flag(TLB_V6_I_ASID))
  332. asm("mcr p15, 0, %0, c8, c5, 2" : : "r" (asid) : "cc");
  333. if (tlb_flag(TLB_V7_UIS_ASID))
  334. #ifdef CONFIG_ARM_ERRATA_720789
  335. asm("mcr p15, 0, %0, c8, c3, 0" : : "r" (zero) : "cc");
  336. #else
  337. asm("mcr p15, 0, %0, c8, c3, 2" : : "r" (asid) : "cc");
  338. #endif
  339. if (tlb_flag(TLB_BTB)) {
  340. /* flush the branch target cache */
  341. asm("mcr p15, 0, %0, c7, c5, 6" : : "r" (zero) : "cc");
  342. dsb();
  343. }
  344. if (tlb_flag(TLB_V7_IS_BTB)) {
  345. /* flush the branch target cache */
  346. asm("mcr p15, 0, %0, c7, c1, 6" : : "r" (zero) : "cc");
  347. dsb();
  348. isb();
  349. }
  350. }
  351. static inline void
  352. local_flush_tlb_page(struct vm_area_struct *vma, unsigned long uaddr)
  353. {
  354. const int zero = 0;
  355. const unsigned int __tlb_flag = __cpu_tlb_flags;
  356. uaddr = (uaddr & PAGE_MASK) | ASID(vma->vm_mm);
  357. if (tlb_flag(TLB_WB))
  358. dsb();
  359. if (cpumask_test_cpu(smp_processor_id(), mm_cpumask(vma->vm_mm))) {
  360. if (tlb_flag(TLB_V3_PAGE))
  361. asm("mcr p15, 0, %0, c6, c0, 0" : : "r" (uaddr) : "cc");
  362. if (tlb_flag(TLB_V4_U_PAGE))
  363. asm("mcr p15, 0, %0, c8, c7, 1" : : "r" (uaddr) : "cc");
  364. if (tlb_flag(TLB_V4_D_PAGE))
  365. asm("mcr p15, 0, %0, c8, c6, 1" : : "r" (uaddr) : "cc");
  366. if (tlb_flag(TLB_V4_I_PAGE))
  367. asm("mcr p15, 0, %0, c8, c5, 1" : : "r" (uaddr) : "cc");
  368. if (!tlb_flag(TLB_V4_I_PAGE) && tlb_flag(TLB_V4_I_FULL))
  369. asm("mcr p15, 0, %0, c8, c5, 0" : : "r" (zero) : "cc");
  370. }
  371. if (tlb_flag(TLB_V6_U_PAGE))
  372. asm("mcr p15, 0, %0, c8, c7, 1" : : "r" (uaddr) : "cc");
  373. if (tlb_flag(TLB_V6_D_PAGE))
  374. asm("mcr p15, 0, %0, c8, c6, 1" : : "r" (uaddr) : "cc");
  375. if (tlb_flag(TLB_V6_I_PAGE))
  376. asm("mcr p15, 0, %0, c8, c5, 1" : : "r" (uaddr) : "cc");
  377. if (tlb_flag(TLB_V7_UIS_PAGE))
  378. #ifdef CONFIG_ARM_ERRATA_720789
  379. asm("mcr p15, 0, %0, c8, c3, 3" : : "r" (uaddr & PAGE_MASK) : "cc");
  380. #else
  381. asm("mcr p15, 0, %0, c8, c3, 1" : : "r" (uaddr) : "cc");
  382. #endif
  383. if (tlb_flag(TLB_BTB)) {
  384. /* flush the branch target cache */
  385. asm("mcr p15, 0, %0, c7, c5, 6" : : "r" (zero) : "cc");
  386. dsb();
  387. }
  388. if (tlb_flag(TLB_V7_IS_BTB)) {
  389. /* flush the branch target cache */
  390. asm("mcr p15, 0, %0, c7, c1, 6" : : "r" (zero) : "cc");
  391. dsb();
  392. isb();
  393. }
  394. }
  395. static inline void local_flush_tlb_kernel_page(unsigned long kaddr)
  396. {
  397. const int zero = 0;
  398. const unsigned int __tlb_flag = __cpu_tlb_flags;
  399. kaddr &= PAGE_MASK;
  400. if (tlb_flag(TLB_WB))
  401. dsb();
  402. if (tlb_flag(TLB_V3_PAGE))
  403. asm("mcr p15, 0, %0, c6, c0, 0" : : "r" (kaddr) : "cc");
  404. if (tlb_flag(TLB_V4_U_PAGE))
  405. asm("mcr p15, 0, %0, c8, c7, 1" : : "r" (kaddr) : "cc");
  406. if (tlb_flag(TLB_V4_D_PAGE))
  407. asm("mcr p15, 0, %0, c8, c6, 1" : : "r" (kaddr) : "cc");
  408. if (tlb_flag(TLB_V4_I_PAGE))
  409. asm("mcr p15, 0, %0, c8, c5, 1" : : "r" (kaddr) : "cc");
  410. if (!tlb_flag(TLB_V4_I_PAGE) && tlb_flag(TLB_V4_I_FULL))
  411. asm("mcr p15, 0, %0, c8, c5, 0" : : "r" (zero) : "cc");
  412. if (tlb_flag(TLB_V6_U_PAGE))
  413. asm("mcr p15, 0, %0, c8, c7, 1" : : "r" (kaddr) : "cc");
  414. if (tlb_flag(TLB_V6_D_PAGE))
  415. asm("mcr p15, 0, %0, c8, c6, 1" : : "r" (kaddr) : "cc");
  416. if (tlb_flag(TLB_V6_I_PAGE))
  417. asm("mcr p15, 0, %0, c8, c5, 1" : : "r" (kaddr) : "cc");
  418. if (tlb_flag(TLB_V7_UIS_PAGE))
  419. asm("mcr p15, 0, %0, c8, c3, 1" : : "r" (kaddr) : "cc");
  420. if (tlb_flag(TLB_BTB)) {
  421. /* flush the branch target cache */
  422. asm("mcr p15, 0, %0, c7, c5, 6" : : "r" (zero) : "cc");
  423. dsb();
  424. isb();
  425. }
  426. if (tlb_flag(TLB_V7_IS_BTB)) {
  427. /* flush the branch target cache */
  428. asm("mcr p15, 0, %0, c7, c1, 6" : : "r" (zero) : "cc");
  429. dsb();
  430. isb();
  431. }
  432. }
  433. /*
  434. * flush_pmd_entry
  435. *
  436. * Flush a PMD entry (word aligned, or double-word aligned) to
  437. * RAM if the TLB for the CPU we are running on requires this.
  438. * This is typically used when we are creating PMD entries.
  439. *
  440. * clean_pmd_entry
  441. *
  442. * Clean (but don't drain the write buffer) if the CPU requires
  443. * these operations. This is typically used when we are removing
  444. * PMD entries.
  445. */
  446. static inline void flush_pmd_entry(pmd_t *pmd)
  447. {
  448. const unsigned int __tlb_flag = __cpu_tlb_flags;
  449. if (tlb_flag(TLB_DCLEAN))
  450. asm("mcr p15, 0, %0, c7, c10, 1 @ flush_pmd"
  451. : : "r" (pmd) : "cc");
  452. if (tlb_flag(TLB_L2CLEAN_FR))
  453. asm("mcr p15, 1, %0, c15, c9, 1 @ L2 flush_pmd"
  454. : : "r" (pmd) : "cc");
  455. if (tlb_flag(TLB_WB))
  456. dsb();
  457. }
  458. static inline void clean_pmd_entry(pmd_t *pmd)
  459. {
  460. const unsigned int __tlb_flag = __cpu_tlb_flags;
  461. if (tlb_flag(TLB_DCLEAN))
  462. asm("mcr p15, 0, %0, c7, c10, 1 @ flush_pmd"
  463. : : "r" (pmd) : "cc");
  464. if (tlb_flag(TLB_L2CLEAN_FR))
  465. asm("mcr p15, 1, %0, c15, c9, 1 @ L2 flush_pmd"
  466. : : "r" (pmd) : "cc");
  467. }
  468. #undef tlb_flag
  469. #undef always_tlb_flags
  470. #undef possible_tlb_flags
  471. /*
  472. * Convert calls to our calling convention.
  473. */
  474. #define local_flush_tlb_range(vma,start,end) __cpu_flush_user_tlb_range(start,end,vma)
  475. #define local_flush_tlb_kernel_range(s,e) __cpu_flush_kern_tlb_range(s,e)
  476. #ifndef CONFIG_SMP
  477. #define flush_tlb_all local_flush_tlb_all
  478. #define flush_tlb_mm local_flush_tlb_mm
  479. #define flush_tlb_page local_flush_tlb_page
  480. #define flush_tlb_kernel_page local_flush_tlb_kernel_page
  481. #define flush_tlb_range local_flush_tlb_range
  482. #define flush_tlb_kernel_range local_flush_tlb_kernel_range
  483. #else
  484. extern void flush_tlb_all(void);
  485. extern void flush_tlb_mm(struct mm_struct *mm);
  486. extern void flush_tlb_page(struct vm_area_struct *vma, unsigned long uaddr);
  487. extern void flush_tlb_kernel_page(unsigned long kaddr);
  488. extern void flush_tlb_range(struct vm_area_struct *vma, unsigned long start, unsigned long end);
  489. extern void flush_tlb_kernel_range(unsigned long start, unsigned long end);
  490. #endif
  491. /*
  492. * If PG_dcache_clean is not set for the page, we need to ensure that any
  493. * cache entries for the kernels virtual memory range are written
  494. * back to the page. On ARMv6 and later, the cache coherency is handled via
  495. * the set_pte_at() function.
  496. */
  497. #if __LINUX_ARM_ARCH__ < 6
  498. extern void update_mmu_cache(struct vm_area_struct *vma, unsigned long addr,
  499. pte_t *ptep);
  500. #else
  501. static inline void update_mmu_cache(struct vm_area_struct *vma,
  502. unsigned long addr, pte_t *ptep)
  503. {
  504. }
  505. #endif
  506. #endif
  507. #endif /* CONFIG_MMU */
  508. #endif