vmalloc.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #ifndef _ASM_ARM64_VMALLOC_H
  2. #define _ASM_ARM64_VMALLOC_H
  3. #include <asm/page.h>
  4. #include <asm/pgtable.h>
  5. #ifdef CONFIG_HAVE_ARCH_HUGE_VMAP
  6. #define arch_vmap_pud_supported arch_vmap_pud_supported
  7. static inline bool arch_vmap_pud_supported(pgprot_t prot)
  8. {
  9. return pud_sect_supported();
  10. }
  11. #define arch_vmap_pmd_supported arch_vmap_pmd_supported
  12. static inline bool arch_vmap_pmd_supported(pgprot_t prot)
  13. {
  14. return true;
  15. }
  16. #define arch_vmap_pte_range_map_size arch_vmap_pte_range_map_size
  17. static inline unsigned long arch_vmap_pte_range_map_size(unsigned long addr,
  18. unsigned long end, u64 pfn,
  19. unsigned int max_page_shift)
  20. {
  21. /*
  22. * If the block is at least CONT_PTE_SIZE in size, and is naturally
  23. * aligned in both virtual and physical space, then we can pte-map the
  24. * block using the PTE_CONT bit for more efficient use of the TLB.
  25. */
  26. if (max_page_shift < CONT_PTE_SHIFT)
  27. return PAGE_SIZE;
  28. if (end - addr < CONT_PTE_SIZE)
  29. return PAGE_SIZE;
  30. if (!IS_ALIGNED(addr, CONT_PTE_SIZE))
  31. return PAGE_SIZE;
  32. if (!IS_ALIGNED(PFN_PHYS(pfn), CONT_PTE_SIZE))
  33. return PAGE_SIZE;
  34. return CONT_PTE_SIZE;
  35. }
  36. #define arch_vmap_pte_range_unmap_size arch_vmap_pte_range_unmap_size
  37. static inline unsigned long arch_vmap_pte_range_unmap_size(unsigned long addr,
  38. pte_t *ptep)
  39. {
  40. /*
  41. * The caller handles alignment so it's sufficient just to check
  42. * PTE_CONT.
  43. */
  44. return pte_valid_cont(__ptep_get(ptep)) ? CONT_PTE_SIZE : PAGE_SIZE;
  45. }
  46. #define arch_vmap_pte_supported_shift arch_vmap_pte_supported_shift
  47. static inline int arch_vmap_pte_supported_shift(unsigned long size)
  48. {
  49. if (size >= CONT_PTE_SIZE)
  50. return CONT_PTE_SHIFT;
  51. return PAGE_SHIFT;
  52. }
  53. #endif
  54. #define arch_vmap_pgprot_tagged arch_vmap_pgprot_tagged
  55. static inline pgprot_t arch_vmap_pgprot_tagged(pgprot_t prot)
  56. {
  57. return pgprot_tagged(prot);
  58. }
  59. #endif /* _ASM_ARM64_VMALLOC_H */