vm_mmu.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Hexagon VM page table entry definitions
  4. *
  5. * Copyright (c) 2010-2011,2013 The Linux Foundation. All rights reserved.
  6. */
  7. #ifndef _ASM_VM_MMU_H
  8. #define _ASM_VM_MMU_H
  9. /*
  10. * Shift, mask, and other constants for the Hexagon Virtual Machine
  11. * page tables.
  12. *
  13. * Virtual machine MMU allows first-level entries to either be
  14. * single-level lookup PTEs for very large pages, or PDEs pointing
  15. * to second-level PTEs for smaller pages. If PTE is single-level,
  16. * the least significant bits cannot be used as software bits to encode
  17. * virtual memory subsystem information about the page, and that state
  18. * must be maintained in some parallel data structure.
  19. */
  20. /* S or Page Size field in PDE */
  21. #define __HVM_PDE_S (0x7 << 0)
  22. #define __HVM_PDE_S_4KB 0
  23. #define __HVM_PDE_S_16KB 1
  24. #define __HVM_PDE_S_64KB 2
  25. #define __HVM_PDE_S_256KB 3
  26. #define __HVM_PDE_S_1MB 4
  27. #define __HVM_PDE_S_4MB 5
  28. #define __HVM_PDE_S_16MB 6
  29. #define __HVM_PDE_S_INVALID 7
  30. /* Masks for L2 page table pointer, as function of page size */
  31. #define __HVM_PDE_PTMASK_4KB 0xfffff000
  32. #define __HVM_PDE_PTMASK_16KB 0xfffffc00
  33. #define __HVM_PDE_PTMASK_64KB 0xffffff00
  34. #define __HVM_PDE_PTMASK_256KB 0xffffffc0
  35. #define __HVM_PDE_PTMASK_1MB 0xfffffff0
  36. /*
  37. * Virtual Machine PTE Bits/Fields
  38. */
  39. #define __HVM_PTE_T (1<<4)
  40. #define __HVM_PTE_U (1<<5)
  41. #define __HVM_PTE_C (0x7<<6)
  42. #define __HVM_PTE_CVAL(pte) (((pte) & __HVM_PTE_C) >> 6)
  43. #define __HVM_PTE_R (1<<9)
  44. #define __HVM_PTE_W (1<<10)
  45. #define __HVM_PTE_X (1<<11)
  46. /*
  47. * Cache Attributes, to be shifted as necessary for virtual/physical PTEs
  48. */
  49. #define __HEXAGON_C_WB 0x0 /* Write-back, no L2 */
  50. #define __HEXAGON_C_WT 0x1 /* Write-through, no L2 */
  51. #define __HEXAGON_C_UNC 0x6 /* Uncached memory */
  52. #if CONFIG_HEXAGON_ARCH_VERSION >= 2
  53. #define __HEXAGON_C_DEV 0x4 /* Device register space */
  54. #else
  55. #define __HEXAGON_C_DEV __HEXAGON_C_UNC
  56. #endif
  57. #define __HEXAGON_C_WT_L2 0x5 /* Write-through, with L2 */
  58. #define __HEXAGON_C_WB_L2 0x7 /* Write-back, with L2 */
  59. /*
  60. * This can be overridden, but we're defaulting to the most aggressive
  61. * cache policy, the better to find bugs sooner.
  62. */
  63. #define CACHE_DEFAULT __HEXAGON_C_WB_L2
  64. /* Masks for physical page address, as a function of page size */
  65. #define __HVM_PTE_PGMASK_4KB 0xfffff000
  66. #define __HVM_PTE_PGMASK_16KB 0xffffc000
  67. #define __HVM_PTE_PGMASK_64KB 0xffff0000
  68. #define __HVM_PTE_PGMASK_256KB 0xfffc0000
  69. #define __HVM_PTE_PGMASK_1MB 0xfff00000
  70. /* Masks for single-level large page lookups */
  71. #define __HVM_PTE_PGMASK_4MB 0xffc00000
  72. #define __HVM_PTE_PGMASK_16MB 0xff000000
  73. /*
  74. * "Big kernel page mappings" (see vm_init_segtable.S)
  75. * are currently 16MB
  76. */
  77. #define BIG_KERNEL_PAGE_SHIFT 24
  78. #define BIG_KERNEL_PAGE_SIZE (1 << BIG_KERNEL_PAGE_SHIFT)
  79. #endif /* _ASM_VM_MMU_H */