hugepage.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Copyright (C) 2013-15 Synopsys, Inc. (www.synopsys.com)
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #ifndef _ASM_ARC_HUGEPAGE_H
  9. #define _ASM_ARC_HUGEPAGE_H
  10. #include <linux/types.h>
  11. #include <asm-generic/pgtable-nopmd.h>
  12. static inline pte_t pmd_pte(pmd_t pmd)
  13. {
  14. return __pte(pmd_val(pmd));
  15. }
  16. static inline pmd_t pte_pmd(pte_t pte)
  17. {
  18. return __pmd(pte_val(pte));
  19. }
  20. #define pmd_wrprotect(pmd) pte_pmd(pte_wrprotect(pmd_pte(pmd)))
  21. #define pmd_mkwrite(pmd) pte_pmd(pte_mkwrite(pmd_pte(pmd)))
  22. #define pmd_mkdirty(pmd) pte_pmd(pte_mkdirty(pmd_pte(pmd)))
  23. #define pmd_mkold(pmd) pte_pmd(pte_mkold(pmd_pte(pmd)))
  24. #define pmd_mkyoung(pmd) pte_pmd(pte_mkyoung(pmd_pte(pmd)))
  25. #define pmd_mkhuge(pmd) pte_pmd(pte_mkhuge(pmd_pte(pmd)))
  26. #define pmd_mknotpresent(pmd) pte_pmd(pte_mknotpresent(pmd_pte(pmd)))
  27. #define pmd_mksplitting(pmd) pte_pmd(pte_mkspecial(pmd_pte(pmd)))
  28. #define pmd_mkclean(pmd) pte_pmd(pte_mkclean(pmd_pte(pmd)))
  29. #define pmd_write(pmd) pte_write(pmd_pte(pmd))
  30. #define pmd_young(pmd) pte_young(pmd_pte(pmd))
  31. #define pmd_pfn(pmd) pte_pfn(pmd_pte(pmd))
  32. #define pmd_dirty(pmd) pte_dirty(pmd_pte(pmd))
  33. #define pmd_special(pmd) pte_special(pmd_pte(pmd))
  34. #define mk_pmd(page, prot) pte_pmd(mk_pte(page, prot))
  35. #define pmd_trans_huge(pmd) (pmd_val(pmd) & _PAGE_HW_SZ)
  36. #define pmd_trans_splitting(pmd) (pmd_trans_huge(pmd) && pmd_special(pmd))
  37. #define pfn_pmd(pfn, prot) (__pmd(((pfn) << PAGE_SHIFT) | pgprot_val(prot)))
  38. static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot)
  39. {
  40. /*
  41. * open-coded pte_modify() with additional retaining of HW_SZ bit
  42. * so that pmd_trans_huge() remains true for this PMD
  43. */
  44. return __pmd((pmd_val(pmd) & (_PAGE_CHG_MASK | _PAGE_HW_SZ)) | pgprot_val(newprot));
  45. }
  46. static inline void set_pmd_at(struct mm_struct *mm, unsigned long addr,
  47. pmd_t *pmdp, pmd_t pmd)
  48. {
  49. *pmdp = pmd;
  50. }
  51. extern void update_mmu_cache_pmd(struct vm_area_struct *vma, unsigned long addr,
  52. pmd_t *pmd);
  53. #define has_transparent_hugepage() 1
  54. /* Generic variants assume pgtable_t is struct page *, hence need for these */
  55. #define __HAVE_ARCH_PGTABLE_DEPOSIT
  56. extern void pgtable_trans_huge_deposit(struct mm_struct *mm, pmd_t *pmdp,
  57. pgtable_t pgtable);
  58. #define __HAVE_ARCH_PGTABLE_WITHDRAW
  59. extern pgtable_t pgtable_trans_huge_withdraw(struct mm_struct *mm, pmd_t *pmdp);
  60. #define __HAVE_ARCH_FLUSH_PMD_TLB_RANGE
  61. extern void flush_pmd_tlb_range(struct vm_area_struct *vma, unsigned long start,
  62. unsigned long end);
  63. #endif