pgtable.h 16 KB

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