mmu.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __MMU_H
  3. #define __MMU_H
  4. #include <linux/cpumask.h>
  5. #include <linux/errno.h>
  6. typedef struct {
  7. spinlock_t lock;
  8. cpumask_t cpu_attach_mask;
  9. atomic_t flush_count;
  10. unsigned int flush_mm;
  11. struct list_head pgtable_list;
  12. struct list_head gmap_list;
  13. unsigned long gmap_asce;
  14. unsigned long asce;
  15. unsigned long asce_limit;
  16. unsigned long vdso_base;
  17. /*
  18. * The following bitfields need a down_write on the mm
  19. * semaphore when they are written to. As they are only
  20. * written once, they can be read without a lock.
  21. *
  22. * The mmu context allocates 4K page tables.
  23. */
  24. unsigned int alloc_pgste:1;
  25. /* The mmu context uses extended page tables. */
  26. unsigned int has_pgste:1;
  27. /* The mmu context uses storage keys. */
  28. unsigned int uses_skeys:1;
  29. /* The mmu context uses CMM. */
  30. unsigned int uses_cmm:1;
  31. /* The gmaps associated with this context are allowed to use huge pages. */
  32. unsigned int allow_gmap_hpage_1m:1;
  33. } mm_context_t;
  34. #define INIT_MM_CONTEXT(name) \
  35. .context.lock = __SPIN_LOCK_UNLOCKED(name.context.lock), \
  36. .context.pgtable_list = LIST_HEAD_INIT(name.context.pgtable_list), \
  37. .context.gmap_list = LIST_HEAD_INIT(name.context.gmap_list),
  38. static inline int tprot(unsigned long addr)
  39. {
  40. int rc = -EFAULT;
  41. asm volatile(
  42. " tprot 0(%1),0\n"
  43. "0: ipm %0\n"
  44. " srl %0,28\n"
  45. "1:\n"
  46. EX_TABLE(0b,1b)
  47. : "+d" (rc) : "a" (addr) : "cc");
  48. return rc;
  49. }
  50. #endif