mmu.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_X86_MMU_H
  3. #define _ASM_X86_MMU_H
  4. #include <linux/spinlock.h>
  5. #include <linux/rwsem.h>
  6. #include <linux/mutex.h>
  7. #include <linux/atomic.h>
  8. #include <linux/bits.h>
  9. /* Uprobes on this MM assume 32-bit code */
  10. #define MM_CONTEXT_UPROBE_IA32 BIT(0)
  11. /* vsyscall page is accessible on this MM */
  12. #define MM_CONTEXT_HAS_VSYSCALL BIT(1)
  13. /*
  14. * x86 has arch-specific MMU state beyond what lives in mm_struct.
  15. */
  16. typedef struct {
  17. /*
  18. * ctx_id uniquely identifies this mm_struct. A ctx_id will never
  19. * be reused, and zero is not a valid ctx_id.
  20. */
  21. u64 ctx_id;
  22. /*
  23. * Any code that needs to do any sort of TLB flushing for this
  24. * mm will first make its changes to the page tables, then
  25. * increment tlb_gen, then flush. This lets the low-level
  26. * flushing code keep track of what needs flushing.
  27. *
  28. * This is not used on Xen PV.
  29. */
  30. atomic64_t tlb_gen;
  31. #ifdef CONFIG_MODIFY_LDT_SYSCALL
  32. struct rw_semaphore ldt_usr_sem;
  33. struct ldt_struct *ldt;
  34. #endif
  35. #ifdef CONFIG_X86_64
  36. unsigned short flags;
  37. #endif
  38. struct mutex lock;
  39. void __user *vdso; /* vdso base address */
  40. const struct vdso_image *vdso_image; /* vdso image in use */
  41. atomic_t perf_rdpmc_allowed; /* nonzero if rdpmc is allowed */
  42. #ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS
  43. /*
  44. * One bit per protection key says whether userspace can
  45. * use it or not. protected by mmap_lock.
  46. */
  47. u16 pkey_allocation_map;
  48. s16 execute_only_pkey;
  49. #endif
  50. } mm_context_t;
  51. #define INIT_MM_CONTEXT(mm) \
  52. .context = { \
  53. .ctx_id = 1, \
  54. .lock = __MUTEX_INITIALIZER(mm.context.lock), \
  55. }
  56. void leave_mm(int cpu);
  57. #define leave_mm leave_mm
  58. #endif /* _ASM_X86_MMU_H */