xref: /linux/arch/riscv/include/asm/pgtable-bits.h (revision ec63e2a4897075e427c121d863bd89c44578094f)
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 /*
39  * _PAGE_PROT_NONE is set on not-present pages (and ignored by the hardware) to
40  * distinguish them from swapped out pages
41  */
42 #define _PAGE_PROT_NONE _PAGE_READ
43 
44 #define _PAGE_PFN_SHIFT 10
45 
46 /* Set of bits to preserve across pte_modify() */
47 #define _PAGE_CHG_MASK  (~(unsigned long)(_PAGE_PRESENT | _PAGE_READ |	\
48 					  _PAGE_WRITE | _PAGE_EXEC |	\
49 					  _PAGE_USER | _PAGE_GLOBAL))
50 
51 #endif /* _ASM_RISCV_PGTABLE_BITS_H */
52