mmu.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #ifndef __MMU_H
  2. #define __MMU_H
  3. #include <linux/config.h>
  4. #include <asm/page.h>
  5. #include <asm/const.h>
  6. #include <asm/hypervisor.h>
  7. /*
  8. * For the 8k pagesize kernel, use only 10 hw context bits to optimize some
  9. * shifts in the fast tlbmiss handlers, instead of all 13 bits (specifically
  10. * for vpte offset calculation). For other pagesizes, this optimization in
  11. * the tlbhandlers can not be done; but still, all 13 bits can not be used
  12. * because the tlb handlers use "andcc" instruction which sign extends 13
  13. * bit arguments.
  14. */
  15. #if PAGE_SHIFT == 13
  16. #define CTX_NR_BITS 10
  17. #else
  18. #define CTX_NR_BITS 12
  19. #endif
  20. #define TAG_CONTEXT_BITS ((_AC(1,UL) << CTX_NR_BITS) - _AC(1,UL))
  21. /* UltraSPARC-III+ and later have a feature whereby you can
  22. * select what page size the various Data-TLB instances in the
  23. * chip. In order to gracefully support this, we put the version
  24. * field in a spot outside of the areas of the context register
  25. * where this parameter is specified.
  26. */
  27. #define CTX_VERSION_SHIFT 22
  28. #define CTX_VERSION_MASK ((~0UL) << CTX_VERSION_SHIFT)
  29. #define CTX_PGSZ_8KB _AC(0x0,UL)
  30. #define CTX_PGSZ_64KB _AC(0x1,UL)
  31. #define CTX_PGSZ_512KB _AC(0x2,UL)
  32. #define CTX_PGSZ_4MB _AC(0x3,UL)
  33. #define CTX_PGSZ_BITS _AC(0x7,UL)
  34. #define CTX_PGSZ0_NUC_SHIFT 61
  35. #define CTX_PGSZ1_NUC_SHIFT 58
  36. #define CTX_PGSZ0_SHIFT 16
  37. #define CTX_PGSZ1_SHIFT 19
  38. #define CTX_PGSZ_MASK ((CTX_PGSZ_BITS << CTX_PGSZ0_SHIFT) | \
  39. (CTX_PGSZ_BITS << CTX_PGSZ1_SHIFT))
  40. #if defined(CONFIG_SPARC64_PAGE_SIZE_8KB)
  41. #define CTX_PGSZ_BASE CTX_PGSZ_8KB
  42. #elif defined(CONFIG_SPARC64_PAGE_SIZE_64KB)
  43. #define CTX_PGSZ_BASE CTX_PGSZ_64KB
  44. #elif defined(CONFIG_SPARC64_PAGE_SIZE_512KB)
  45. #define CTX_PGSZ_BASE CTX_PGSZ_512KB
  46. #elif defined(CONFIG_SPARC64_PAGE_SIZE_4MB)
  47. #define CTX_PGSZ_BASE CTX_PGSZ_4MB
  48. #else
  49. #error No page size specified in kernel configuration
  50. #endif
  51. #if defined(CONFIG_HUGETLB_PAGE_SIZE_4MB)
  52. #define CTX_PGSZ_HUGE CTX_PGSZ_4MB
  53. #elif defined(CONFIG_HUGETLB_PAGE_SIZE_512K)
  54. #define CTX_PGSZ_HUGE CTX_PGSZ_512KB
  55. #elif defined(CONFIG_HUGETLB_PAGE_SIZE_64K)
  56. #define CTX_PGSZ_HUGE CTX_PGSZ_64KB
  57. #endif
  58. #define CTX_PGSZ_KERN CTX_PGSZ_4MB
  59. /* Thus, when running on UltraSPARC-III+ and later, we use the following
  60. * PRIMARY_CONTEXT register values for the kernel context.
  61. */
  62. #define CTX_CHEETAH_PLUS_NUC \
  63. ((CTX_PGSZ_KERN << CTX_PGSZ0_NUC_SHIFT) | \
  64. (CTX_PGSZ_BASE << CTX_PGSZ1_NUC_SHIFT))
  65. #define CTX_CHEETAH_PLUS_CTX0 \
  66. ((CTX_PGSZ_KERN << CTX_PGSZ0_SHIFT) | \
  67. (CTX_PGSZ_BASE << CTX_PGSZ1_SHIFT))
  68. /* If you want "the TLB context number" use CTX_NR_MASK. If you
  69. * want "the bits I program into the context registers" use
  70. * CTX_HW_MASK.
  71. */
  72. #define CTX_NR_MASK TAG_CONTEXT_BITS
  73. #define CTX_HW_MASK (CTX_NR_MASK | CTX_PGSZ_MASK)
  74. #define CTX_FIRST_VERSION ((_AC(1,UL) << CTX_VERSION_SHIFT) + _AC(1,UL))
  75. #define CTX_VALID(__ctx) \
  76. (!(((__ctx.sparc64_ctx_val) ^ tlb_context_cache) & CTX_VERSION_MASK))
  77. #define CTX_HWBITS(__ctx) ((__ctx.sparc64_ctx_val) & CTX_HW_MASK)
  78. #define CTX_NRBITS(__ctx) ((__ctx.sparc64_ctx_val) & CTX_NR_MASK)
  79. #ifndef __ASSEMBLY__
  80. #define TSB_ENTRY_ALIGNMENT 16
  81. struct tsb {
  82. unsigned long tag;
  83. unsigned long pte;
  84. } __attribute__((aligned(TSB_ENTRY_ALIGNMENT)));
  85. extern void __tsb_insert(unsigned long ent, unsigned long tag, unsigned long pte);
  86. extern void tsb_flush(unsigned long ent, unsigned long tag);
  87. typedef struct {
  88. unsigned long sparc64_ctx_val;
  89. struct tsb *tsb;
  90. unsigned long tsb_rss_limit;
  91. unsigned long tsb_nentries;
  92. unsigned long tsb_reg_val;
  93. unsigned long tsb_map_vaddr;
  94. unsigned long tsb_map_pte;
  95. struct hv_tsb_descr tsb_descr;
  96. } mm_context_t;
  97. #endif /* !__ASSEMBLY__ */
  98. #endif /* __MMU_H */