xref: /linux/arch/riscv/include/asm/pgtable-bits.h (revision 9a379e77033f02c4a071891afdf0f0a01eff8ccb)
1 /*
2  * Copyright (C) 2012 Regents of the University of California
3  *
4  *   This program is free software; you can redistribute it and/or
5  *   modify it under the terms of the GNU General Public License
6  *   as published by the Free Software Foundation, version 2.
7  *
8  *   This program is distributed in the hope that it will be useful,
9  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
10  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  *   GNU General Public License for more details.
12  */
13 
14 #ifndef _ASM_RISCV_PGTABLE_BITS_H
15 #define _ASM_RISCV_PGTABLE_BITS_H
16 
17 /*
18  * PTE format:
19  * | XLEN-1  10 | 9             8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
20  *       PFN      reserved for SW   D   A   G   U   X   W   R   V
21  */
22 
23 #define _PAGE_ACCESSED_OFFSET 6
24 
25 #define _PAGE_PRESENT   (1 << 0)
26 #define _PAGE_READ      (1 << 1)    /* Readable */
27 #define _PAGE_WRITE     (1 << 2)    /* Writable */
28 #define _PAGE_EXEC      (1 << 3)    /* Executable */
29 #define _PAGE_USER      (1 << 4)    /* User */
30 #define _PAGE_GLOBAL    (1 << 5)    /* Global */
31 #define _PAGE_ACCESSED  (1 << 6)    /* Set by hardware on any access */
32 #define _PAGE_DIRTY     (1 << 7)    /* Set by hardware on any write */
33 #define _PAGE_SOFT      (1 << 8)    /* Reserved for software */
34 
35 #define _PAGE_SPECIAL   _PAGE_SOFT
36 #define _PAGE_TABLE     _PAGE_PRESENT
37 
38 #define _PAGE_PFN_SHIFT 10
39 
40 /* Set of bits to preserve across pte_modify() */
41 #define _PAGE_CHG_MASK  (~(unsigned long)(_PAGE_PRESENT | _PAGE_READ |	\
42 					  _PAGE_WRITE | _PAGE_EXEC |	\
43 					  _PAGE_USER | _PAGE_GLOBAL))
44 
45 /* Advertise support for _PAGE_SPECIAL */
46 #define __HAVE_ARCH_PTE_SPECIAL
47 
48 #endif /* _ASM_RISCV_PGTABLE_BITS_H */
49