| 1 |
|
| 2 | |
| 3 | * Copyright (C) 2012 Regents of the University of California
|
| 4 |
|
| 5 |
|
| 6 | #ifndef _ASM_RISCV_PGTABLE_BITS_H
|
| 7 | #define _ASM_RISCV_PGTABLE_BITS_H
|
| 8 |
|
| 9 | #define _PAGE_ACCESSED_OFFSET 6
|
| 10 |
|
| 11 | #define _PAGE_PRESENT (1 << 0)
|
| 12 | #define _PAGE_READ (1 << 1)
|
| 13 | #define _PAGE_WRITE (1 << 2)
|
| 14 | #define _PAGE_EXEC (1 << 3)
|
| 15 | #define _PAGE_USER (1 << 4)
|
| 16 | #define _PAGE_GLOBAL (1 << 5)
|
| 17 | #define _PAGE_ACCESSED (1 << 6)
|
| 18 | #define _PAGE_DIRTY (1 << 7)
|
| 19 | #define _PAGE_SOFT (3 << 8)
|
| 20 |
|
| 21 | #define _PAGE_SPECIAL (1 << 8)
|
| 22 |
|
| 23 | #ifdef CONFIG_MEM_SOFT_DIRTY
|
| 24 |
|
| 25 |
|
| 26 | #define _PAGE_SOFT_DIRTY \
|
| 27 | ((riscv_has_extension_unlikely(RISCV_ISA_EXT_SVRSW60T59B)) ? \
|
| 28 | (1UL << 59) : 0)
|
| 29 | |
| 30 | * Bit 3 is always zero for swap entry computation, so we
|
| 31 | * can borrow it for swap page soft-dirty tracking.
|
| 32 |
|
| 33 | #define _PAGE_SWP_SOFT_DIRTY \
|
| 34 | ((riscv_has_extension_unlikely(RISCV_ISA_EXT_SVRSW60T59B)) ? \
|
| 35 | _PAGE_EXEC : 0)
|
| 36 | #else
|
| 37 | #define _PAGE_SOFT_DIRTY 0
|
| 38 | #define _PAGE_SWP_SOFT_DIRTY 0
|
| 39 | #endif
|
| 40 |
|
| 41 | #ifdef CONFIG_HAVE_ARCH_USERFAULTFD_WP
|
| 42 |
|
| 43 |
|
| 44 | #define _PAGE_UFFD \
|
| 45 | ((riscv_has_extension_unlikely(RISCV_ISA_EXT_SVRSW60T59B)) ? \
|
| 46 | (1UL << 60) : 0)
|
| 47 | |
| 48 | * Bit 4 is not involved into swap entry computation, so we
|
| 49 | * can borrow it for swap page userfaultfd tracking.
|
| 50 |
|
| 51 | #define _PAGE_SWP_UFFD \
|
| 52 | ((riscv_has_extension_unlikely(RISCV_ISA_EXT_SVRSW60T59B)) ? \
|
| 53 | _PAGE_USER : 0)
|
| 54 | #else
|
| 55 | #define _PAGE_UFFD 0
|
| 56 | #define _PAGE_SWP_UFFD 0
|
| 57 | #endif
|
| 58 |
|
| 59 | #define _PAGE_TABLE _PAGE_PRESENT
|
| 60 |
|
| 61 | |
| 62 | * _PAGE_PROT_NONE is set on not-present pages (and ignored by the hardware) to
|
| 63 | * distinguish them from swapped out pages
|
| 64 |
|
| 65 | #define _PAGE_PROT_NONE _PAGE_GLOBAL
|
| 66 |
|
| 67 |
|
| 68 | #define _PAGE_SWP_EXCLUSIVE _PAGE_ACCESSED
|
| 69 |
|
| 70 | #define _PAGE_PFN_SHIFT 10
|
| 71 |
|
| 72 | |
| 73 | * when all of R/W/X are zero, the PTE is a pointer to the next level
|
| 74 | * of the page table; otherwise, it is a leaf PTE.
|
| 75 |
|
| 76 | #define _PAGE_LEAF (_PAGE_READ | _PAGE_WRITE | _PAGE_EXEC)
|
| 77 |
|
| 78 | #endif
|