pgtable-bits.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2012 Regents of the University of California
  4. */
  5. #ifndef _ASM_RISCV_PGTABLE_BITS_H
  6. #define _ASM_RISCV_PGTABLE_BITS_H
  7. /*
  8. * PTE format:
  9. * | XLEN-1 10 | 9 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
  10. * PFN reserved for SW D A G U X W R V
  11. */
  12. #define _PAGE_ACCESSED_OFFSET 6
  13. #define _PAGE_PRESENT (1 << 0)
  14. #define _PAGE_READ (1 << 1) /* Readable */
  15. #define _PAGE_WRITE (1 << 2) /* Writable */
  16. #define _PAGE_EXEC (1 << 3) /* Executable */
  17. #define _PAGE_USER (1 << 4) /* User */
  18. #define _PAGE_GLOBAL (1 << 5) /* Global */
  19. #define _PAGE_ACCESSED (1 << 6) /* Set by hardware on any access */
  20. #define _PAGE_DIRTY (1 << 7) /* Set by hardware on any write */
  21. #define _PAGE_SOFT (1 << 8) /* Reserved for software */
  22. /* T-HEAD C9xx extend */
  23. #define _PAGE_SEC (1UL << 59) /* Security */
  24. #define _PAGE_SHARE (1UL << 60) /* Shareable */
  25. #define _PAGE_BUF (1UL << 61) /* Bufferable */
  26. #define _PAGE_CACHE (1UL << 62) /* Cacheable */
  27. #define _PAGE_SO (1UL << 63) /* Strong Order */
  28. #define _PAGE_SPECIAL _PAGE_SOFT
  29. #define _PAGE_TABLE _PAGE_PRESENT
  30. /*
  31. * _PAGE_PROT_NONE is set on not-present pages (and ignored by the hardware) to
  32. * distinguish them from swapped out pages
  33. */
  34. #define _PAGE_PROT_NONE _PAGE_READ
  35. #define _PAGE_PFN_SHIFT 10
  36. /* Set of bits to preserve across pte_modify() */
  37. #define _PAGE_CHG_MASK (~(unsigned long)(_PAGE_PRESENT | _PAGE_READ | \
  38. _PAGE_WRITE | _PAGE_EXEC | \
  39. _PAGE_USER | _PAGE_GLOBAL | \
  40. _PAGE_SEC | _PAGE_SHARE | \
  41. _PAGE_BUF | _PAGE_CACHE | \
  42. _PAGE_SO ))
  43. #endif /* _ASM_RISCV_PGTABLE_BITS_H */