pgtable.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. /*
  2. * Copyright 2010 Tilera Corporation. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation, version 2.
  7. *
  8. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  11. * NON INFRINGEMENT. See the GNU General Public License for
  12. * more details.
  13. *
  14. * This file contains the functions and defines necessary to modify and use
  15. * the TILE page table tree.
  16. */
  17. #ifndef _ASM_TILE_PGTABLE_H
  18. #define _ASM_TILE_PGTABLE_H
  19. #include <hv/hypervisor.h>
  20. #ifndef __ASSEMBLY__
  21. #include <linux/bitops.h>
  22. #include <linux/threads.h>
  23. #include <linux/slab.h>
  24. #include <linux/list.h>
  25. #include <linux/spinlock.h>
  26. #include <asm/processor.h>
  27. #include <asm/fixmap.h>
  28. struct mm_struct;
  29. struct vm_area_struct;
  30. /*
  31. * ZERO_PAGE is a global shared page that is always zero: used
  32. * for zero-mapped memory areas etc..
  33. */
  34. extern unsigned long empty_zero_page[PAGE_SIZE/sizeof(unsigned long)];
  35. #define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
  36. extern pgd_t swapper_pg_dir[];
  37. extern pgprot_t swapper_pgprot;
  38. extern struct kmem_cache *pgd_cache;
  39. extern spinlock_t pgd_lock;
  40. extern struct list_head pgd_list;
  41. /*
  42. * The very last slots in the pgd_t are for addresses unusable by Linux
  43. * (pgd_addr_invalid() returns true). So we use them for the list structure.
  44. * The x86 code we are modelled on uses the page->private/index fields
  45. * (older 2.6 kernels) or the lru list (newer 2.6 kernels), but since
  46. * our pgds are so much smaller than a page, it seems a waste to
  47. * spend a whole page on each pgd.
  48. */
  49. #define PGD_LIST_OFFSET \
  50. ((PTRS_PER_PGD * sizeof(pgd_t)) - sizeof(struct list_head))
  51. #define pgd_to_list(pgd) \
  52. ((struct list_head *)((char *)(pgd) + PGD_LIST_OFFSET))
  53. #define list_to_pgd(list) \
  54. ((pgd_t *)((char *)(list) - PGD_LIST_OFFSET))
  55. extern void pgtable_cache_init(void);
  56. extern void paging_init(void);
  57. extern void set_page_homes(void);
  58. #define FIRST_USER_ADDRESS 0
  59. #define _PAGE_PRESENT HV_PTE_PRESENT
  60. #define _PAGE_HUGE_PAGE HV_PTE_PAGE
  61. #define _PAGE_READABLE HV_PTE_READABLE
  62. #define _PAGE_WRITABLE HV_PTE_WRITABLE
  63. #define _PAGE_EXECUTABLE HV_PTE_EXECUTABLE
  64. #define _PAGE_ACCESSED HV_PTE_ACCESSED
  65. #define _PAGE_DIRTY HV_PTE_DIRTY
  66. #define _PAGE_GLOBAL HV_PTE_GLOBAL
  67. #define _PAGE_USER HV_PTE_USER
  68. /*
  69. * All the "standard" bits. Cache-control bits are managed elsewhere.
  70. * This is used to test for valid level-2 page table pointers by checking
  71. * all the bits, and to mask away the cache control bits for mprotect.
  72. */
  73. #define _PAGE_ALL (\
  74. _PAGE_PRESENT | \
  75. _PAGE_HUGE_PAGE | \
  76. _PAGE_READABLE | \
  77. _PAGE_WRITABLE | \
  78. _PAGE_EXECUTABLE | \
  79. _PAGE_ACCESSED | \
  80. _PAGE_DIRTY | \
  81. _PAGE_GLOBAL | \
  82. _PAGE_USER \
  83. )
  84. #define PAGE_NONE \
  85. __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED)
  86. #define PAGE_SHARED \
  87. __pgprot(_PAGE_PRESENT | _PAGE_READABLE | _PAGE_WRITABLE | \
  88. _PAGE_USER | _PAGE_ACCESSED)
  89. #define PAGE_SHARED_EXEC \
  90. __pgprot(_PAGE_PRESENT | _PAGE_READABLE | _PAGE_WRITABLE | \
  91. _PAGE_EXECUTABLE | _PAGE_USER | _PAGE_ACCESSED)
  92. #define PAGE_COPY_NOEXEC \
  93. __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED | _PAGE_READABLE)
  94. #define PAGE_COPY_EXEC \
  95. __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED | \
  96. _PAGE_READABLE | _PAGE_EXECUTABLE)
  97. #define PAGE_COPY \
  98. PAGE_COPY_NOEXEC
  99. #define PAGE_READONLY \
  100. __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED | _PAGE_READABLE)
  101. #define PAGE_READONLY_EXEC \
  102. __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED | \
  103. _PAGE_READABLE | _PAGE_EXECUTABLE)
  104. #define _PAGE_KERNEL_RO \
  105. (_PAGE_PRESENT | _PAGE_GLOBAL | _PAGE_READABLE | _PAGE_ACCESSED)
  106. #define _PAGE_KERNEL \
  107. (_PAGE_KERNEL_RO | _PAGE_WRITABLE | _PAGE_DIRTY)
  108. #define _PAGE_KERNEL_EXEC (_PAGE_KERNEL_RO | _PAGE_EXECUTABLE)
  109. #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
  110. #define PAGE_KERNEL_RO __pgprot(_PAGE_KERNEL_RO)
  111. #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
  112. #define page_to_kpgprot(p) PAGE_KERNEL
  113. /*
  114. * We could tighten these up, but for now writable or executable
  115. * implies readable.
  116. */
  117. #define __P000 PAGE_NONE
  118. #define __P001 PAGE_READONLY
  119. #define __P010 PAGE_COPY /* this is write-only, which we won't support */
  120. #define __P011 PAGE_COPY
  121. #define __P100 PAGE_READONLY_EXEC
  122. #define __P101 PAGE_READONLY_EXEC
  123. #define __P110 PAGE_COPY_EXEC
  124. #define __P111 PAGE_COPY_EXEC
  125. #define __S000 PAGE_NONE
  126. #define __S001 PAGE_READONLY
  127. #define __S010 PAGE_SHARED
  128. #define __S011 PAGE_SHARED
  129. #define __S100 PAGE_READONLY_EXEC
  130. #define __S101 PAGE_READONLY_EXEC
  131. #define __S110 PAGE_SHARED_EXEC
  132. #define __S111 PAGE_SHARED_EXEC
  133. /*
  134. * All the normal _PAGE_ALL bits are ignored for PMDs, except PAGE_PRESENT
  135. * and PAGE_HUGE_PAGE, which must be one and zero, respectively.
  136. * We set the ignored bits to zero.
  137. */
  138. #define _PAGE_TABLE _PAGE_PRESENT
  139. /* Inherit the caching flags from the old protection bits. */
  140. #define pgprot_modify(oldprot, newprot) \
  141. (pgprot_t) { ((oldprot).val & ~_PAGE_ALL) | (newprot).val }
  142. /* Just setting the PFN to zero suffices. */
  143. #define pte_pgprot(x) hv_pte_set_pfn((x), 0)
  144. /*
  145. * For PTEs and PDEs, we must clear the Present bit first when
  146. * clearing a page table entry, so clear the bottom half first and
  147. * enforce ordering with a barrier.
  148. */
  149. static inline void __pte_clear(pte_t *ptep)
  150. {
  151. #ifdef __tilegx__
  152. ptep->val = 0;
  153. #else
  154. u32 *tmp = (u32 *)ptep;
  155. tmp[0] = 0;
  156. barrier();
  157. tmp[1] = 0;
  158. #endif
  159. }
  160. #define pte_clear(mm, addr, ptep) __pte_clear(ptep)
  161. /*
  162. * The following only work if pte_present() is true.
  163. * Undefined behaviour if not..
  164. */
  165. #define pte_present hv_pte_get_present
  166. #define pte_mknotpresent hv_pte_clear_present
  167. #define pte_user hv_pte_get_user
  168. #define pte_read hv_pte_get_readable
  169. #define pte_dirty hv_pte_get_dirty
  170. #define pte_young hv_pte_get_accessed
  171. #define pte_write hv_pte_get_writable
  172. #define pte_exec hv_pte_get_executable
  173. #define pte_huge hv_pte_get_page
  174. #define pte_rdprotect hv_pte_clear_readable
  175. #define pte_exprotect hv_pte_clear_executable
  176. #define pte_mkclean hv_pte_clear_dirty
  177. #define pte_mkold hv_pte_clear_accessed
  178. #define pte_wrprotect hv_pte_clear_writable
  179. #define pte_mksmall hv_pte_clear_page
  180. #define pte_mkread hv_pte_set_readable
  181. #define pte_mkexec hv_pte_set_executable
  182. #define pte_mkdirty hv_pte_set_dirty
  183. #define pte_mkyoung hv_pte_set_accessed
  184. #define pte_mkwrite hv_pte_set_writable
  185. #define pte_mkhuge hv_pte_set_page
  186. #define pte_special(pte) 0
  187. #define pte_mkspecial(pte) (pte)
  188. /*
  189. * Use some spare bits in the PTE for user-caching tags.
  190. */
  191. #define pte_set_forcecache hv_pte_set_client0
  192. #define pte_get_forcecache hv_pte_get_client0
  193. #define pte_clear_forcecache hv_pte_clear_client0
  194. #define pte_set_anyhome hv_pte_set_client1
  195. #define pte_get_anyhome hv_pte_get_client1
  196. #define pte_clear_anyhome hv_pte_clear_client1
  197. /*
  198. * A migrating PTE has PAGE_PRESENT clear but all the other bits preserved.
  199. */
  200. #define pte_migrating hv_pte_get_migrating
  201. #define pte_mkmigrate(x) hv_pte_set_migrating(hv_pte_clear_present(x))
  202. #define pte_donemigrate(x) hv_pte_set_present(hv_pte_clear_migrating(x))
  203. #define pte_ERROR(e) \
  204. pr_err("%s:%d: bad pte 0x%016llx.\n", __FILE__, __LINE__, pte_val(e))
  205. #define pgd_ERROR(e) \
  206. pr_err("%s:%d: bad pgd 0x%016llx.\n", __FILE__, __LINE__, pgd_val(e))
  207. /* Return PA and protection info for a given kernel VA. */
  208. int va_to_cpa_and_pte(void *va, phys_addr_t *cpa, pte_t *pte);
  209. /*
  210. * __set_pte() ensures we write the 64-bit PTE with 32-bit words in
  211. * the right order on 32-bit platforms and also allows us to write
  212. * hooks to check valid PTEs, etc., if we want.
  213. */
  214. void __set_pte(pte_t *ptep, pte_t pte);
  215. /*
  216. * set_pte() sets the given PTE and also sanity-checks the
  217. * requested PTE against the page homecaching. Unspecified parts
  218. * of the PTE are filled in when it is written to memory, i.e. all
  219. * caching attributes if "!forcecache", or the home cpu if "anyhome".
  220. */
  221. extern void set_pte(pte_t *ptep, pte_t pte);
  222. #define set_pte_at(mm, addr, ptep, pteval) set_pte(ptep, pteval)
  223. #define set_pte_atomic(pteptr, pteval) set_pte(pteptr, pteval)
  224. #define pte_page(x) pfn_to_page(pte_pfn(x))
  225. static inline int pte_none(pte_t pte)
  226. {
  227. return !pte.val;
  228. }
  229. static inline unsigned long pte_pfn(pte_t pte)
  230. {
  231. return hv_pte_get_pfn(pte);
  232. }
  233. /* Set or get the remote cache cpu in a pgprot with remote caching. */
  234. extern pgprot_t set_remote_cache_cpu(pgprot_t prot, int cpu);
  235. extern int get_remote_cache_cpu(pgprot_t prot);
  236. static inline pte_t pfn_pte(unsigned long pfn, pgprot_t prot)
  237. {
  238. return hv_pte_set_pfn(prot, pfn);
  239. }
  240. /* Support for priority mappings. */
  241. extern void start_mm_caching(struct mm_struct *mm);
  242. extern void check_mm_caching(struct mm_struct *prev, struct mm_struct *next);
  243. /*
  244. * Support non-linear file mappings (see sys_remap_file_pages).
  245. * This is defined by CLIENT1 set but CLIENT0 and _PAGE_PRESENT clear, and the
  246. * file offset in the 32 high bits.
  247. */
  248. #define _PAGE_FILE HV_PTE_CLIENT1
  249. #define PTE_FILE_MAX_BITS 32
  250. #define pte_file(pte) (hv_pte_get_client1(pte) && !hv_pte_get_client0(pte))
  251. #define pte_to_pgoff(pte) ((pte).val >> 32)
  252. #define pgoff_to_pte(off) ((pte_t) { (((long long)(off)) << 32) | _PAGE_FILE })
  253. /*
  254. * Encode and de-code a swap entry (see <linux/swapops.h>).
  255. * We put the swap file type+offset in the 32 high bits;
  256. * I believe we can just leave the low bits clear.
  257. */
  258. #define __swp_type(swp) ((swp).val & 0x1f)
  259. #define __swp_offset(swp) ((swp).val >> 5)
  260. #define __swp_entry(type, off) ((swp_entry_t) { (type) | ((off) << 5) })
  261. #define __pte_to_swp_entry(pte) ((swp_entry_t) { (pte).val >> 32 })
  262. #define __swp_entry_to_pte(swp) ((pte_t) { (((long long) ((swp).val)) << 32) })
  263. /*
  264. * Conversion functions: convert a page and protection to a page entry,
  265. * and a page entry and page directory to the page they refer to.
  266. */
  267. #define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot))
  268. /*
  269. * If we are doing an mprotect(), just accept the new vma->vm_page_prot
  270. * value and combine it with the PFN from the old PTE to get a new PTE.
  271. */
  272. static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
  273. {
  274. return pfn_pte(pte_pfn(pte), newprot);
  275. }
  276. /*
  277. * The pgd page can be thought of an array like this: pgd_t[PTRS_PER_PGD]
  278. *
  279. * This macro returns the index of the entry in the pgd page which would
  280. * control the given virtual address.
  281. */
  282. #define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1))
  283. /*
  284. * pgd_offset() returns a (pgd_t *)
  285. * pgd_index() is used get the offset into the pgd page's array of pgd_t's.
  286. */
  287. #define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
  288. /*
  289. * A shortcut which implies the use of the kernel's pgd, instead
  290. * of a process's.
  291. */
  292. #define pgd_offset_k(address) pgd_offset(&init_mm, address)
  293. #if defined(CONFIG_HIGHPTE)
  294. extern pte_t *pte_offset_map(pmd_t *, unsigned long address);
  295. #define pte_unmap(pte) kunmap_atomic(pte)
  296. #else
  297. #define pte_offset_map(dir, address) pte_offset_kernel(dir, address)
  298. #define pte_unmap(pte) do { } while (0)
  299. #endif
  300. /* Clear a non-executable kernel PTE and flush it from the TLB. */
  301. #define kpte_clear_flush(ptep, vaddr) \
  302. do { \
  303. pte_clear(&init_mm, (vaddr), (ptep)); \
  304. local_flush_tlb_page(FLUSH_NONEXEC, (vaddr), PAGE_SIZE); \
  305. } while (0)
  306. /*
  307. * The kernel page tables contain what we need, and we flush when we
  308. * change specific page table entries.
  309. */
  310. #define update_mmu_cache(vma, address, pte) do { } while (0)
  311. #ifdef CONFIG_FLATMEM
  312. #define kern_addr_valid(addr) (1)
  313. #endif /* CONFIG_FLATMEM */
  314. #define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
  315. remap_pfn_range(vma, vaddr, pfn, size, prot)
  316. extern void vmalloc_sync_all(void);
  317. #endif /* !__ASSEMBLY__ */
  318. #ifdef __tilegx__
  319. #include <asm/pgtable_64.h>
  320. #else
  321. #include <asm/pgtable_32.h>
  322. #endif
  323. #ifndef __ASSEMBLY__
  324. static inline int pmd_none(pmd_t pmd)
  325. {
  326. /*
  327. * Only check low word on 32-bit platforms, since it might be
  328. * out of sync with upper half.
  329. */
  330. return (unsigned long)pmd_val(pmd) == 0;
  331. }
  332. static inline int pmd_present(pmd_t pmd)
  333. {
  334. return pmd_val(pmd) & _PAGE_PRESENT;
  335. }
  336. static inline int pmd_bad(pmd_t pmd)
  337. {
  338. return ((pmd_val(pmd) & _PAGE_ALL) != _PAGE_TABLE);
  339. }
  340. static inline unsigned long pages_to_mb(unsigned long npg)
  341. {
  342. return npg >> (20 - PAGE_SHIFT);
  343. }
  344. /*
  345. * The pmd can be thought of an array like this: pmd_t[PTRS_PER_PMD]
  346. *
  347. * This function returns the index of the entry in the pmd which would
  348. * control the given virtual address.
  349. */
  350. static inline unsigned long pmd_index(unsigned long address)
  351. {
  352. return (address >> PMD_SHIFT) & (PTRS_PER_PMD - 1);
  353. }
  354. #define __HAVE_ARCH_PMDP_TEST_AND_CLEAR_YOUNG
  355. static inline int pmdp_test_and_clear_young(struct vm_area_struct *vma,
  356. unsigned long address,
  357. pmd_t *pmdp)
  358. {
  359. return ptep_test_and_clear_young(vma, address, pmdp_ptep(pmdp));
  360. }
  361. #define __HAVE_ARCH_PMDP_SET_WRPROTECT
  362. static inline void pmdp_set_wrprotect(struct mm_struct *mm,
  363. unsigned long address, pmd_t *pmdp)
  364. {
  365. ptep_set_wrprotect(mm, address, pmdp_ptep(pmdp));
  366. }
  367. #define __HAVE_ARCH_PMDP_GET_AND_CLEAR
  368. static inline pmd_t pmdp_get_and_clear(struct mm_struct *mm,
  369. unsigned long address,
  370. pmd_t *pmdp)
  371. {
  372. return pte_pmd(ptep_get_and_clear(mm, address, pmdp_ptep(pmdp)));
  373. }
  374. static inline void __set_pmd(pmd_t *pmdp, pmd_t pmdval)
  375. {
  376. set_pte(pmdp_ptep(pmdp), pmd_pte(pmdval));
  377. }
  378. #define set_pmd_at(mm, addr, pmdp, pmdval) __set_pmd(pmdp, pmdval)
  379. /* Create a pmd from a PTFN. */
  380. static inline pmd_t ptfn_pmd(unsigned long ptfn, pgprot_t prot)
  381. {
  382. return pte_pmd(hv_pte_set_ptfn(prot, ptfn));
  383. }
  384. /* Return the page-table frame number (ptfn) that a pmd_t points at. */
  385. #define pmd_ptfn(pmd) hv_pte_get_ptfn(pmd_pte(pmd))
  386. /*
  387. * A given kernel pmd_t maps to a specific virtual address (either a
  388. * kernel huge page or a kernel pte_t table). Since kernel pte_t
  389. * tables can be aligned at sub-page granularity, this function can
  390. * return non-page-aligned pointers, despite its name.
  391. */
  392. static inline unsigned long pmd_page_vaddr(pmd_t pmd)
  393. {
  394. phys_addr_t pa =
  395. (phys_addr_t)pmd_ptfn(pmd) << HV_LOG2_PAGE_TABLE_ALIGN;
  396. return (unsigned long)__va(pa);
  397. }
  398. /*
  399. * A pmd_t points to the base of a huge page or to a pte_t array.
  400. * If a pte_t array, since we can have multiple per page, we don't
  401. * have a one-to-one mapping of pmd_t's to pages. However, this is
  402. * OK for pte_lockptr(), since we just end up with potentially one
  403. * lock being used for several pte_t arrays.
  404. */
  405. #define pmd_page(pmd) pfn_to_page(HV_PTFN_TO_PFN(pmd_ptfn(pmd)))
  406. static inline void pmd_clear(pmd_t *pmdp)
  407. {
  408. __pte_clear(pmdp_ptep(pmdp));
  409. }
  410. #define pmd_mknotpresent(pmd) pte_pmd(pte_mknotpresent(pmd_pte(pmd)))
  411. #define pmd_young(pmd) pte_young(pmd_pte(pmd))
  412. #define pmd_mkyoung(pmd) pte_pmd(pte_mkyoung(pmd_pte(pmd)))
  413. #define pmd_mkold(pmd) pte_pmd(pte_mkold(pmd_pte(pmd)))
  414. #define pmd_mkwrite(pmd) pte_pmd(pte_mkwrite(pmd_pte(pmd)))
  415. #define pmd_write(pmd) pte_write(pmd_pte(pmd))
  416. #define pmd_wrprotect(pmd) pte_pmd(pte_wrprotect(pmd_pte(pmd)))
  417. #define pmd_mkdirty(pmd) pte_pmd(pte_mkdirty(pmd_pte(pmd)))
  418. #define pmd_huge_page(pmd) pte_huge(pmd_pte(pmd))
  419. #define pmd_mkhuge(pmd) pte_pmd(pte_mkhuge(pmd_pte(pmd)))
  420. #define __HAVE_ARCH_PMD_WRITE
  421. #define pfn_pmd(pfn, pgprot) pte_pmd(pfn_pte((pfn), (pgprot)))
  422. #define pmd_pfn(pmd) pte_pfn(pmd_pte(pmd))
  423. #define mk_pmd(page, pgprot) pfn_pmd(page_to_pfn(page), (pgprot))
  424. static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot)
  425. {
  426. return pfn_pmd(pmd_pfn(pmd), newprot);
  427. }
  428. #ifdef CONFIG_TRANSPARENT_HUGEPAGE
  429. #define has_transparent_hugepage() 1
  430. #define pmd_trans_huge pmd_huge_page
  431. static inline pmd_t pmd_mksplitting(pmd_t pmd)
  432. {
  433. return pte_pmd(hv_pte_set_client2(pmd_pte(pmd)));
  434. }
  435. static inline int pmd_trans_splitting(pmd_t pmd)
  436. {
  437. return hv_pte_get_client2(pmd_pte(pmd));
  438. }
  439. #endif /* CONFIG_TRANSPARENT_HUGEPAGE */
  440. /*
  441. * The pte page can be thought of an array like this: pte_t[PTRS_PER_PTE]
  442. *
  443. * This macro returns the index of the entry in the pte page which would
  444. * control the given virtual address.
  445. */
  446. static inline unsigned long pte_index(unsigned long address)
  447. {
  448. return (address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1);
  449. }
  450. static inline pte_t *pte_offset_kernel(pmd_t *pmd, unsigned long address)
  451. {
  452. return (pte_t *)pmd_page_vaddr(*pmd) + pte_index(address);
  453. }
  454. #include <asm-generic/pgtable.h>
  455. /* Support /proc/NN/pgtable API. */
  456. struct seq_file;
  457. int arch_proc_pgtable_show(struct seq_file *m, struct mm_struct *mm,
  458. unsigned long vaddr, pte_t *ptep, void **datap);
  459. #endif /* !__ASSEMBLY__ */
  460. #endif /* _ASM_TILE_PGTABLE_H */