xref: /linux/arch/riscv/include/asm/pgtable-bits.h (revision f5397c3ee0a3e2ca0a6d66d079ffcd5386b45b81)
150acfb2bSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
207037db5SPalmer Dabbelt /*
307037db5SPalmer Dabbelt  * Copyright (C) 2012 Regents of the University of California
407037db5SPalmer Dabbelt  */
507037db5SPalmer Dabbelt 
607037db5SPalmer Dabbelt #ifndef _ASM_RISCV_PGTABLE_BITS_H
707037db5SPalmer Dabbelt #define _ASM_RISCV_PGTABLE_BITS_H
807037db5SPalmer Dabbelt 
907037db5SPalmer Dabbelt /*
1007037db5SPalmer Dabbelt  * PTE format:
1107037db5SPalmer Dabbelt  * | XLEN-1  10 | 9             8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
1207037db5SPalmer Dabbelt  *       PFN      reserved for SW   D   A   G   U   X   W   R   V
1307037db5SPalmer Dabbelt  */
1407037db5SPalmer Dabbelt 
1507037db5SPalmer Dabbelt #define _PAGE_ACCESSED_OFFSET 6
1607037db5SPalmer Dabbelt 
1707037db5SPalmer Dabbelt #define _PAGE_PRESENT   (1 << 0)
1807037db5SPalmer Dabbelt #define _PAGE_READ      (1 << 1)    /* Readable */
1907037db5SPalmer Dabbelt #define _PAGE_WRITE     (1 << 2)    /* Writable */
2007037db5SPalmer Dabbelt #define _PAGE_EXEC      (1 << 3)    /* Executable */
2107037db5SPalmer Dabbelt #define _PAGE_USER      (1 << 4)    /* User */
2207037db5SPalmer Dabbelt #define _PAGE_GLOBAL    (1 << 5)    /* Global */
2307037db5SPalmer Dabbelt #define _PAGE_ACCESSED  (1 << 6)    /* Set by hardware on any access */
2407037db5SPalmer Dabbelt #define _PAGE_DIRTY     (1 << 7)    /* Set by hardware on any write */
2507037db5SPalmer Dabbelt #define _PAGE_SOFT      (1 << 8)    /* Reserved for software */
2607037db5SPalmer Dabbelt 
2707037db5SPalmer Dabbelt #define _PAGE_SPECIAL   _PAGE_SOFT
2807037db5SPalmer Dabbelt #define _PAGE_TABLE     _PAGE_PRESENT
2907037db5SPalmer Dabbelt 
30e3613bb8SStefan O'Rear /*
31e3613bb8SStefan O'Rear  * _PAGE_PROT_NONE is set on not-present pages (and ignored by the hardware) to
32e3613bb8SStefan O'Rear  * distinguish them from swapped out pages
33e3613bb8SStefan O'Rear  */
34e3613bb8SStefan O'Rear #define _PAGE_PROT_NONE _PAGE_READ
35e3613bb8SStefan O'Rear 
3607037db5SPalmer Dabbelt #define _PAGE_PFN_SHIFT 10
3707037db5SPalmer Dabbelt 
3807037db5SPalmer Dabbelt /* Set of bits to preserve across pte_modify() */
3907037db5SPalmer Dabbelt #define _PAGE_CHG_MASK  (~(unsigned long)(_PAGE_PRESENT | _PAGE_READ |	\
4007037db5SPalmer Dabbelt 					  _PAGE_WRITE | _PAGE_EXEC |	\
4107037db5SPalmer Dabbelt 					  _PAGE_USER | _PAGE_GLOBAL))
42*f5397c3eSNanyong Sun /*
43*f5397c3eSNanyong Sun  * when all of R/W/X are zero, the PTE is a pointer to the next level
44*f5397c3eSNanyong Sun  * of the page table; otherwise, it is a leaf PTE.
45*f5397c3eSNanyong Sun  */
46*f5397c3eSNanyong Sun #define _PAGE_LEAF (_PAGE_READ | _PAGE_WRITE | _PAGE_EXEC)
4707037db5SPalmer Dabbelt 
4807037db5SPalmer Dabbelt #endif /* _ASM_RISCV_PGTABLE_BITS_H */
49