mmu_64.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #ifndef __MMU_H
  2. #define __MMU_H
  3. #include <linux/const.h>
  4. #include <asm/page.h>
  5. #include <asm/hypervisor.h>
  6. #define CTX_NR_BITS 13
  7. #define TAG_CONTEXT_BITS ((_AC(1,UL) << CTX_NR_BITS) - _AC(1,UL))
  8. /* UltraSPARC-III+ and later have a feature whereby you can
  9. * select what page size the various Data-TLB instances in the
  10. * chip. In order to gracefully support this, we put the version
  11. * field in a spot outside of the areas of the context register
  12. * where this parameter is specified.
  13. */
  14. #define CTX_VERSION_SHIFT 22
  15. #define CTX_VERSION_MASK ((~0UL) << CTX_VERSION_SHIFT)
  16. #define CTX_PGSZ_8KB _AC(0x0,UL)
  17. #define CTX_PGSZ_64KB _AC(0x1,UL)
  18. #define CTX_PGSZ_512KB _AC(0x2,UL)
  19. #define CTX_PGSZ_4MB _AC(0x3,UL)
  20. #define CTX_PGSZ_BITS _AC(0x7,UL)
  21. #define CTX_PGSZ0_NUC_SHIFT 61
  22. #define CTX_PGSZ1_NUC_SHIFT 58
  23. #define CTX_PGSZ0_SHIFT 16
  24. #define CTX_PGSZ1_SHIFT 19
  25. #define CTX_PGSZ_MASK ((CTX_PGSZ_BITS << CTX_PGSZ0_SHIFT) | \
  26. (CTX_PGSZ_BITS << CTX_PGSZ1_SHIFT))
  27. #define CTX_PGSZ_BASE CTX_PGSZ_8KB
  28. #define CTX_PGSZ_HUGE CTX_PGSZ_4MB
  29. #define CTX_PGSZ_KERN CTX_PGSZ_4MB
  30. /* Thus, when running on UltraSPARC-III+ and later, we use the following
  31. * PRIMARY_CONTEXT register values for the kernel context.
  32. */
  33. #define CTX_CHEETAH_PLUS_NUC \
  34. ((CTX_PGSZ_KERN << CTX_PGSZ0_NUC_SHIFT) | \
  35. (CTX_PGSZ_BASE << CTX_PGSZ1_NUC_SHIFT))
  36. #define CTX_CHEETAH_PLUS_CTX0 \
  37. ((CTX_PGSZ_KERN << CTX_PGSZ0_SHIFT) | \
  38. (CTX_PGSZ_BASE << CTX_PGSZ1_SHIFT))
  39. /* If you want "the TLB context number" use CTX_NR_MASK. If you
  40. * want "the bits I program into the context registers" use
  41. * CTX_HW_MASK.
  42. */
  43. #define CTX_NR_MASK TAG_CONTEXT_BITS
  44. #define CTX_HW_MASK (CTX_NR_MASK | CTX_PGSZ_MASK)
  45. #define CTX_FIRST_VERSION BIT(CTX_VERSION_SHIFT)
  46. #define CTX_VALID(__ctx) \
  47. (!(((__ctx.sparc64_ctx_val) ^ tlb_context_cache) & CTX_VERSION_MASK))
  48. #define CTX_HWBITS(__ctx) ((__ctx.sparc64_ctx_val) & CTX_HW_MASK)
  49. #define CTX_NRBITS(__ctx) ((__ctx.sparc64_ctx_val) & CTX_NR_MASK)
  50. #ifndef __ASSEMBLY__
  51. #define TSB_ENTRY_ALIGNMENT 16
  52. struct tsb {
  53. unsigned long tag;
  54. unsigned long pte;
  55. } __attribute__((aligned(TSB_ENTRY_ALIGNMENT)));
  56. void __tsb_insert(unsigned long ent, unsigned long tag, unsigned long pte);
  57. void tsb_flush(unsigned long ent, unsigned long tag);
  58. void tsb_init(struct tsb *tsb, unsigned long size);
  59. struct tsb_config {
  60. struct tsb *tsb;
  61. unsigned long tsb_rss_limit;
  62. unsigned long tsb_nentries;
  63. unsigned long tsb_reg_val;
  64. unsigned long tsb_map_vaddr;
  65. unsigned long tsb_map_pte;
  66. };
  67. #define MM_TSB_BASE 0
  68. #if defined(CONFIG_HUGETLB_PAGE) || defined(CONFIG_TRANSPARENT_HUGEPAGE)
  69. #define MM_TSB_HUGE 1
  70. #define MM_NUM_TSBS 2
  71. #else
  72. #define MM_NUM_TSBS 1
  73. #endif
  74. typedef struct {
  75. spinlock_t lock;
  76. unsigned long sparc64_ctx_val;
  77. unsigned long hugetlb_pte_count;
  78. unsigned long thp_pte_count;
  79. struct tsb_config tsb_block[MM_NUM_TSBS];
  80. struct hv_tsb_descr tsb_descr[MM_NUM_TSBS];
  81. } mm_context_t;
  82. #endif /* !__ASSEMBLY__ */
  83. #define TSB_CONFIG_TSB 0x00
  84. #define TSB_CONFIG_RSS_LIMIT 0x08
  85. #define TSB_CONFIG_NENTRIES 0x10
  86. #define TSB_CONFIG_REG_VAL 0x18
  87. #define TSB_CONFIG_MAP_VADDR 0x20
  88. #define TSB_CONFIG_MAP_PTE 0x28
  89. #endif /* __MMU_H */