tlbflush.h 16 KB

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