hash_native_64.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  1. /*
  2. * native hashtable management.
  3. *
  4. * SMP scalability work:
  5. * Copyright (C) 2001 Anton Blanchard <anton@au.ibm.com>, IBM
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version
  10. * 2 of the License, or (at your option) any later version.
  11. */
  12. #undef DEBUG_LOW
  13. #include <linux/spinlock.h>
  14. #include <linux/bitops.h>
  15. #include <linux/of.h>
  16. #include <linux/threads.h>
  17. #include <linux/smp.h>
  18. #include <asm/machdep.h>
  19. #include <asm/mmu.h>
  20. #include <asm/mmu_context.h>
  21. #include <asm/pgtable.h>
  22. #include <asm/tlbflush.h>
  23. #include <asm/tlb.h>
  24. #include <asm/cputable.h>
  25. #include <asm/udbg.h>
  26. #include <asm/kexec.h>
  27. #include <asm/ppc-opcode.h>
  28. #ifdef DEBUG_LOW
  29. #define DBG_LOW(fmt...) udbg_printf(fmt)
  30. #else
  31. #define DBG_LOW(fmt...)
  32. #endif
  33. #define HPTE_LOCK_BIT 3
  34. DEFINE_RAW_SPINLOCK(native_tlbie_lock);
  35. static inline void __tlbie(unsigned long vpn, int psize, int apsize, int ssize)
  36. {
  37. unsigned long va;
  38. unsigned int penc;
  39. /*
  40. * We need 14 to 65 bits of va for a tlibe of 4K page
  41. * With vpn we ignore the lower VPN_SHIFT bits already.
  42. * And top two bits are already ignored because we can
  43. * only accomadate 76 bits in a 64 bit vpn with a VPN_SHIFT
  44. * of 12.
  45. */
  46. va = vpn << VPN_SHIFT;
  47. /*
  48. * clear top 16 bits of 64bit va, non SLS segment
  49. * Older versions of the architecture (2.02 and earler) require the
  50. * masking of the top 16 bits.
  51. */
  52. va &= ~(0xffffULL << 48);
  53. switch (psize) {
  54. case MMU_PAGE_4K:
  55. /* clear out bits after (52) [0....52.....63] */
  56. va &= ~((1ul << (64 - 52)) - 1);
  57. va |= ssize << 8;
  58. va |= mmu_psize_defs[apsize].sllp << 6;
  59. asm volatile(ASM_FTR_IFCLR("tlbie %0,0", PPC_TLBIE(%1,%0), %2)
  60. : : "r" (va), "r"(0), "i" (CPU_FTR_ARCH_206)
  61. : "memory");
  62. break;
  63. default:
  64. /* We need 14 to 14 + i bits of va */
  65. penc = mmu_psize_defs[psize].penc[apsize];
  66. va &= ~((1ul << mmu_psize_defs[apsize].shift) - 1);
  67. va |= penc << 12;
  68. va |= ssize << 8;
  69. /* Add AVAL part */
  70. if (psize != apsize) {
  71. /*
  72. * MPSS, 64K base page size and 16MB parge page size
  73. * We don't need all the bits, but rest of the bits
  74. * must be ignored by the processor.
  75. * vpn cover upto 65 bits of va. (0...65) and we need
  76. * 58..64 bits of va.
  77. */
  78. va |= (vpn & 0xfe);
  79. }
  80. va |= 1; /* L */
  81. asm volatile(ASM_FTR_IFCLR("tlbie %0,1", PPC_TLBIE(%1,%0), %2)
  82. : : "r" (va), "r"(0), "i" (CPU_FTR_ARCH_206)
  83. : "memory");
  84. break;
  85. }
  86. }
  87. static inline void __tlbiel(unsigned long vpn, int psize, int apsize, int ssize)
  88. {
  89. unsigned long va;
  90. unsigned int penc;
  91. /* VPN_SHIFT can be atmost 12 */
  92. va = vpn << VPN_SHIFT;
  93. /*
  94. * clear top 16 bits of 64 bit va, non SLS segment
  95. * Older versions of the architecture (2.02 and earler) require the
  96. * masking of the top 16 bits.
  97. */
  98. va &= ~(0xffffULL << 48);
  99. switch (psize) {
  100. case MMU_PAGE_4K:
  101. /* clear out bits after(52) [0....52.....63] */
  102. va &= ~((1ul << (64 - 52)) - 1);
  103. va |= ssize << 8;
  104. va |= mmu_psize_defs[apsize].sllp << 6;
  105. asm volatile(".long 0x7c000224 | (%0 << 11) | (0 << 21)"
  106. : : "r"(va) : "memory");
  107. break;
  108. default:
  109. /* We need 14 to 14 + i bits of va */
  110. penc = mmu_psize_defs[psize].penc[apsize];
  111. va &= ~((1ul << mmu_psize_defs[apsize].shift) - 1);
  112. va |= penc << 12;
  113. va |= ssize << 8;
  114. /* Add AVAL part */
  115. if (psize != apsize) {
  116. /*
  117. * MPSS, 64K base page size and 16MB parge page size
  118. * We don't need all the bits, but rest of the bits
  119. * must be ignored by the processor.
  120. * vpn cover upto 65 bits of va. (0...65) and we need
  121. * 58..64 bits of va.
  122. */
  123. va |= (vpn & 0xfe);
  124. }
  125. va |= 1; /* L */
  126. asm volatile(".long 0x7c000224 | (%0 << 11) | (1 << 21)"
  127. : : "r"(va) : "memory");
  128. break;
  129. }
  130. }
  131. static inline void tlbie(unsigned long vpn, int psize, int apsize,
  132. int ssize, int local)
  133. {
  134. unsigned int use_local = local && mmu_has_feature(MMU_FTR_TLBIEL);
  135. int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE);
  136. if (use_local)
  137. use_local = mmu_psize_defs[psize].tlbiel;
  138. if (lock_tlbie && !use_local)
  139. raw_spin_lock(&native_tlbie_lock);
  140. asm volatile("ptesync": : :"memory");
  141. if (use_local) {
  142. __tlbiel(vpn, psize, apsize, ssize);
  143. asm volatile("ptesync": : :"memory");
  144. } else {
  145. __tlbie(vpn, psize, apsize, ssize);
  146. asm volatile("eieio; tlbsync; ptesync": : :"memory");
  147. }
  148. if (lock_tlbie && !use_local)
  149. raw_spin_unlock(&native_tlbie_lock);
  150. }
  151. static inline void native_lock_hpte(struct hash_pte *hptep)
  152. {
  153. unsigned long *word = &hptep->v;
  154. while (1) {
  155. if (!test_and_set_bit_lock(HPTE_LOCK_BIT, word))
  156. break;
  157. while(test_bit(HPTE_LOCK_BIT, word))
  158. cpu_relax();
  159. }
  160. }
  161. static inline void native_unlock_hpte(struct hash_pte *hptep)
  162. {
  163. unsigned long *word = &hptep->v;
  164. clear_bit_unlock(HPTE_LOCK_BIT, word);
  165. }
  166. static long native_hpte_insert(unsigned long hpte_group, unsigned long vpn,
  167. unsigned long pa, unsigned long rflags,
  168. unsigned long vflags, int psize, int apsize, int ssize)
  169. {
  170. struct hash_pte *hptep = htab_address + hpte_group;
  171. unsigned long hpte_v, hpte_r;
  172. int i;
  173. if (!(vflags & HPTE_V_BOLTED)) {
  174. DBG_LOW(" insert(group=%lx, vpn=%016lx, pa=%016lx,"
  175. " rflags=%lx, vflags=%lx, psize=%d)\n",
  176. hpte_group, vpn, pa, rflags, vflags, psize);
  177. }
  178. for (i = 0; i < HPTES_PER_GROUP; i++) {
  179. if (! (hptep->v & HPTE_V_VALID)) {
  180. /* retry with lock held */
  181. native_lock_hpte(hptep);
  182. if (! (hptep->v & HPTE_V_VALID))
  183. break;
  184. native_unlock_hpte(hptep);
  185. }
  186. hptep++;
  187. }
  188. if (i == HPTES_PER_GROUP)
  189. return -1;
  190. hpte_v = hpte_encode_v(vpn, psize, apsize, ssize) | vflags | HPTE_V_VALID;
  191. hpte_r = hpte_encode_r(pa, psize, apsize) | rflags;
  192. if (!(vflags & HPTE_V_BOLTED)) {
  193. DBG_LOW(" i=%x hpte_v=%016lx, hpte_r=%016lx\n",
  194. i, hpte_v, hpte_r);
  195. }
  196. hptep->r = hpte_r;
  197. /* Guarantee the second dword is visible before the valid bit */
  198. eieio();
  199. /*
  200. * Now set the first dword including the valid bit
  201. * NOTE: this also unlocks the hpte
  202. */
  203. hptep->v = hpte_v;
  204. __asm__ __volatile__ ("ptesync" : : : "memory");
  205. return i | (!!(vflags & HPTE_V_SECONDARY) << 3);
  206. }
  207. static long native_hpte_remove(unsigned long hpte_group)
  208. {
  209. struct hash_pte *hptep;
  210. int i;
  211. int slot_offset;
  212. unsigned long hpte_v;
  213. DBG_LOW(" remove(group=%lx)\n", hpte_group);
  214. /* pick a random entry to start at */
  215. slot_offset = mftb() & 0x7;
  216. for (i = 0; i < HPTES_PER_GROUP; i++) {
  217. hptep = htab_address + hpte_group + slot_offset;
  218. hpte_v = hptep->v;
  219. if ((hpte_v & HPTE_V_VALID) && !(hpte_v & HPTE_V_BOLTED)) {
  220. /* retry with lock held */
  221. native_lock_hpte(hptep);
  222. hpte_v = hptep->v;
  223. if ((hpte_v & HPTE_V_VALID)
  224. && !(hpte_v & HPTE_V_BOLTED))
  225. break;
  226. native_unlock_hpte(hptep);
  227. }
  228. slot_offset++;
  229. slot_offset &= 0x7;
  230. }
  231. if (i == HPTES_PER_GROUP)
  232. return -1;
  233. /* Invalidate the hpte. NOTE: this also unlocks it */
  234. hptep->v = 0;
  235. return i;
  236. }
  237. static inline int __hpte_actual_psize(unsigned int lp, int psize)
  238. {
  239. int i, shift;
  240. unsigned int mask;
  241. /* start from 1 ignoring MMU_PAGE_4K */
  242. for (i = 1; i < MMU_PAGE_COUNT; i++) {
  243. /* invalid penc */
  244. if (mmu_psize_defs[psize].penc[i] == -1)
  245. continue;
  246. /*
  247. * encoding bits per actual page size
  248. * PTE LP actual page size
  249. * rrrr rrrz >=8KB
  250. * rrrr rrzz >=16KB
  251. * rrrr rzzz >=32KB
  252. * rrrr zzzz >=64KB
  253. * .......
  254. */
  255. shift = mmu_psize_defs[i].shift - LP_SHIFT;
  256. if (shift > LP_BITS)
  257. shift = LP_BITS;
  258. mask = (1 << shift) - 1;
  259. if ((lp & mask) == mmu_psize_defs[psize].penc[i])
  260. return i;
  261. }
  262. return -1;
  263. }
  264. static inline int hpte_actual_psize(struct hash_pte *hptep, int psize)
  265. {
  266. /* Look at the 8 bit LP value */
  267. unsigned int lp = (hptep->r >> LP_SHIFT) & ((1 << LP_BITS) - 1);
  268. if (!(hptep->v & HPTE_V_VALID))
  269. return -1;
  270. /* First check if it is large page */
  271. if (!(hptep->v & HPTE_V_LARGE))
  272. return MMU_PAGE_4K;
  273. return __hpte_actual_psize(lp, psize);
  274. }
  275. static long native_hpte_updatepp(unsigned long slot, unsigned long newpp,
  276. unsigned long vpn, int psize, int ssize,
  277. int local)
  278. {
  279. struct hash_pte *hptep = htab_address + slot;
  280. unsigned long hpte_v, want_v;
  281. int ret = 0;
  282. int actual_psize;
  283. want_v = hpte_encode_avpn(vpn, psize, ssize);
  284. DBG_LOW(" update(vpn=%016lx, avpnv=%016lx, group=%lx, newpp=%lx)",
  285. vpn, want_v & HPTE_V_AVPN, slot, newpp);
  286. native_lock_hpte(hptep);
  287. hpte_v = hptep->v;
  288. actual_psize = hpte_actual_psize(hptep, psize);
  289. if (actual_psize < 0) {
  290. native_unlock_hpte(hptep);
  291. return -1;
  292. }
  293. /* Even if we miss, we need to invalidate the TLB */
  294. if (!HPTE_V_COMPARE(hpte_v, want_v)) {
  295. DBG_LOW(" -> miss\n");
  296. ret = -1;
  297. } else {
  298. DBG_LOW(" -> hit\n");
  299. /* Update the HPTE */
  300. hptep->r = (hptep->r & ~(HPTE_R_PP | HPTE_R_N)) |
  301. (newpp & (HPTE_R_PP | HPTE_R_N | HPTE_R_C));
  302. }
  303. native_unlock_hpte(hptep);
  304. /* Ensure it is out of the tlb too. */
  305. tlbie(vpn, psize, actual_psize, ssize, local);
  306. return ret;
  307. }
  308. static long native_hpte_find(unsigned long vpn, int psize, int ssize)
  309. {
  310. struct hash_pte *hptep;
  311. unsigned long hash;
  312. unsigned long i;
  313. long slot;
  314. unsigned long want_v, hpte_v;
  315. hash = hpt_hash(vpn, mmu_psize_defs[psize].shift, ssize);
  316. want_v = hpte_encode_avpn(vpn, psize, ssize);
  317. /* Bolted mappings are only ever in the primary group */
  318. slot = (hash & htab_hash_mask) * HPTES_PER_GROUP;
  319. for (i = 0; i < HPTES_PER_GROUP; i++) {
  320. hptep = htab_address + slot;
  321. hpte_v = hptep->v;
  322. if (HPTE_V_COMPARE(hpte_v, want_v) && (hpte_v & HPTE_V_VALID))
  323. /* HPTE matches */
  324. return slot;
  325. ++slot;
  326. }
  327. return -1;
  328. }
  329. /*
  330. * Update the page protection bits. Intended to be used to create
  331. * guard pages for kernel data structures on pages which are bolted
  332. * in the HPT. Assumes pages being operated on will not be stolen.
  333. *
  334. * No need to lock here because we should be the only user.
  335. */
  336. static void native_hpte_updateboltedpp(unsigned long newpp, unsigned long ea,
  337. int psize, int ssize)
  338. {
  339. int actual_psize;
  340. unsigned long vpn;
  341. unsigned long vsid;
  342. long slot;
  343. struct hash_pte *hptep;
  344. vsid = get_kernel_vsid(ea, ssize);
  345. vpn = hpt_vpn(ea, vsid, ssize);
  346. slot = native_hpte_find(vpn, psize, ssize);
  347. if (slot == -1)
  348. panic("could not find page to bolt\n");
  349. hptep = htab_address + slot;
  350. actual_psize = hpte_actual_psize(hptep, psize);
  351. if (actual_psize < 0)
  352. return;
  353. /* Update the HPTE */
  354. hptep->r = (hptep->r & ~(HPTE_R_PP | HPTE_R_N)) |
  355. (newpp & (HPTE_R_PP | HPTE_R_N));
  356. /* Ensure it is out of the tlb too. */
  357. tlbie(vpn, psize, actual_psize, ssize, 0);
  358. }
  359. static void native_hpte_invalidate(unsigned long slot, unsigned long vpn,
  360. int psize, int ssize, int local)
  361. {
  362. struct hash_pte *hptep = htab_address + slot;
  363. unsigned long hpte_v;
  364. unsigned long want_v;
  365. unsigned long flags;
  366. int actual_psize;
  367. local_irq_save(flags);
  368. DBG_LOW(" invalidate(vpn=%016lx, hash: %lx)\n", vpn, slot);
  369. want_v = hpte_encode_avpn(vpn, psize, ssize);
  370. native_lock_hpte(hptep);
  371. hpte_v = hptep->v;
  372. actual_psize = hpte_actual_psize(hptep, psize);
  373. if (actual_psize < 0) {
  374. native_unlock_hpte(hptep);
  375. local_irq_restore(flags);
  376. return;
  377. }
  378. /* Even if we miss, we need to invalidate the TLB */
  379. if (!HPTE_V_COMPARE(hpte_v, want_v))
  380. native_unlock_hpte(hptep);
  381. else
  382. /* Invalidate the hpte. NOTE: this also unlocks it */
  383. hptep->v = 0;
  384. /* Invalidate the TLB */
  385. tlbie(vpn, psize, actual_psize, ssize, local);
  386. local_irq_restore(flags);
  387. }
  388. static void hpte_decode(struct hash_pte *hpte, unsigned long slot,
  389. int *psize, int *apsize, int *ssize, unsigned long *vpn)
  390. {
  391. unsigned long avpn, pteg, vpi;
  392. unsigned long hpte_v = hpte->v;
  393. unsigned long vsid, seg_off;
  394. int size, a_size, shift;
  395. /* Look at the 8 bit LP value */
  396. unsigned int lp = (hpte->r >> LP_SHIFT) & ((1 << LP_BITS) - 1);
  397. if (!(hpte_v & HPTE_V_LARGE)) {
  398. size = MMU_PAGE_4K;
  399. a_size = MMU_PAGE_4K;
  400. } else {
  401. for (size = 0; size < MMU_PAGE_COUNT; size++) {
  402. /* valid entries have a shift value */
  403. if (!mmu_psize_defs[size].shift)
  404. continue;
  405. a_size = __hpte_actual_psize(lp, size);
  406. if (a_size != -1)
  407. break;
  408. }
  409. }
  410. /* This works for all page sizes, and for 256M and 1T segments */
  411. *ssize = hpte_v >> HPTE_V_SSIZE_SHIFT;
  412. shift = mmu_psize_defs[size].shift;
  413. avpn = (HPTE_V_AVPN_VAL(hpte_v) & ~mmu_psize_defs[size].avpnm);
  414. pteg = slot / HPTES_PER_GROUP;
  415. if (hpte_v & HPTE_V_SECONDARY)
  416. pteg = ~pteg;
  417. switch (*ssize) {
  418. case MMU_SEGSIZE_256M:
  419. /* We only have 28 - 23 bits of seg_off in avpn */
  420. seg_off = (avpn & 0x1f) << 23;
  421. vsid = avpn >> 5;
  422. /* We can find more bits from the pteg value */
  423. if (shift < 23) {
  424. vpi = (vsid ^ pteg) & htab_hash_mask;
  425. seg_off |= vpi << shift;
  426. }
  427. *vpn = vsid << (SID_SHIFT - VPN_SHIFT) | seg_off >> VPN_SHIFT;
  428. case MMU_SEGSIZE_1T:
  429. /* We only have 40 - 23 bits of seg_off in avpn */
  430. seg_off = (avpn & 0x1ffff) << 23;
  431. vsid = avpn >> 17;
  432. if (shift < 23) {
  433. vpi = (vsid ^ (vsid << 25) ^ pteg) & htab_hash_mask;
  434. seg_off |= vpi << shift;
  435. }
  436. *vpn = vsid << (SID_SHIFT_1T - VPN_SHIFT) | seg_off >> VPN_SHIFT;
  437. default:
  438. *vpn = size = 0;
  439. }
  440. *psize = size;
  441. *apsize = a_size;
  442. }
  443. /*
  444. * clear all mappings on kexec. All cpus are in real mode (or they will
  445. * be when they isi), and we are the only one left. We rely on our kernel
  446. * mapping being 0xC0's and the hardware ignoring those two real bits.
  447. *
  448. * TODO: add batching support when enabled. remember, no dynamic memory here,
  449. * athough there is the control page available...
  450. */
  451. static void native_hpte_clear(void)
  452. {
  453. unsigned long vpn = 0;
  454. unsigned long slot, slots, flags;
  455. struct hash_pte *hptep = htab_address;
  456. unsigned long hpte_v;
  457. unsigned long pteg_count;
  458. int psize, apsize, ssize;
  459. pteg_count = htab_hash_mask + 1;
  460. local_irq_save(flags);
  461. /* we take the tlbie lock and hold it. Some hardware will
  462. * deadlock if we try to tlbie from two processors at once.
  463. */
  464. raw_spin_lock(&native_tlbie_lock);
  465. slots = pteg_count * HPTES_PER_GROUP;
  466. for (slot = 0; slot < slots; slot++, hptep++) {
  467. /*
  468. * we could lock the pte here, but we are the only cpu
  469. * running, right? and for crash dump, we probably
  470. * don't want to wait for a maybe bad cpu.
  471. */
  472. hpte_v = hptep->v;
  473. /*
  474. * Call __tlbie() here rather than tlbie() since we
  475. * already hold the native_tlbie_lock.
  476. */
  477. if (hpte_v & HPTE_V_VALID) {
  478. hpte_decode(hptep, slot, &psize, &apsize, &ssize, &vpn);
  479. hptep->v = 0;
  480. __tlbie(vpn, psize, apsize, ssize);
  481. }
  482. }
  483. asm volatile("eieio; tlbsync; ptesync":::"memory");
  484. raw_spin_unlock(&native_tlbie_lock);
  485. local_irq_restore(flags);
  486. }
  487. /*
  488. * Batched hash table flush, we batch the tlbie's to avoid taking/releasing
  489. * the lock all the time
  490. */
  491. static void native_flush_hash_range(unsigned long number, int local)
  492. {
  493. unsigned long vpn;
  494. unsigned long hash, index, hidx, shift, slot;
  495. struct hash_pte *hptep;
  496. unsigned long hpte_v;
  497. unsigned long want_v;
  498. unsigned long flags;
  499. real_pte_t pte;
  500. struct ppc64_tlb_batch *batch = &__get_cpu_var(ppc64_tlb_batch);
  501. unsigned long psize = batch->psize;
  502. int ssize = batch->ssize;
  503. int i;
  504. local_irq_save(flags);
  505. for (i = 0; i < number; i++) {
  506. vpn = batch->vpn[i];
  507. pte = batch->pte[i];
  508. pte_iterate_hashed_subpages(pte, psize, vpn, index, shift) {
  509. hash = hpt_hash(vpn, shift, ssize);
  510. hidx = __rpte_to_hidx(pte, index);
  511. if (hidx & _PTEIDX_SECONDARY)
  512. hash = ~hash;
  513. slot = (hash & htab_hash_mask) * HPTES_PER_GROUP;
  514. slot += hidx & _PTEIDX_GROUP_IX;
  515. hptep = htab_address + slot;
  516. want_v = hpte_encode_avpn(vpn, psize, ssize);
  517. native_lock_hpte(hptep);
  518. hpte_v = hptep->v;
  519. if (!HPTE_V_COMPARE(hpte_v, want_v) ||
  520. !(hpte_v & HPTE_V_VALID))
  521. native_unlock_hpte(hptep);
  522. else
  523. hptep->v = 0;
  524. } pte_iterate_hashed_end();
  525. }
  526. if (mmu_has_feature(MMU_FTR_TLBIEL) &&
  527. mmu_psize_defs[psize].tlbiel && local) {
  528. asm volatile("ptesync":::"memory");
  529. for (i = 0; i < number; i++) {
  530. vpn = batch->vpn[i];
  531. pte = batch->pte[i];
  532. pte_iterate_hashed_subpages(pte, psize,
  533. vpn, index, shift) {
  534. __tlbiel(vpn, psize, psize, ssize);
  535. } pte_iterate_hashed_end();
  536. }
  537. asm volatile("ptesync":::"memory");
  538. } else {
  539. int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE);
  540. if (lock_tlbie)
  541. raw_spin_lock(&native_tlbie_lock);
  542. asm volatile("ptesync":::"memory");
  543. for (i = 0; i < number; i++) {
  544. vpn = batch->vpn[i];
  545. pte = batch->pte[i];
  546. pte_iterate_hashed_subpages(pte, psize,
  547. vpn, index, shift) {
  548. __tlbie(vpn, psize, psize, ssize);
  549. } pte_iterate_hashed_end();
  550. }
  551. asm volatile("eieio; tlbsync; ptesync":::"memory");
  552. if (lock_tlbie)
  553. raw_spin_unlock(&native_tlbie_lock);
  554. }
  555. local_irq_restore(flags);
  556. }
  557. void __init hpte_init_native(void)
  558. {
  559. ppc_md.hpte_invalidate = native_hpte_invalidate;
  560. ppc_md.hpte_updatepp = native_hpte_updatepp;
  561. ppc_md.hpte_updateboltedpp = native_hpte_updateboltedpp;
  562. ppc_md.hpte_insert = native_hpte_insert;
  563. ppc_md.hpte_remove = native_hpte_remove;
  564. ppc_md.hpte_clear_all = native_hpte_clear;
  565. ppc_md.flush_hash_range = native_flush_hash_range;
  566. }