File Index
Files and directories
Sign in
FILE

pgtable-bits.h

File preview with syntax highlighting.

linux-6.19.14/arch/riscv/include/asm/pgtable-bits.h C
 1/* SPDX-License-Identifier: GPL-2.0-only */
 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)    /* Readable */
13#define _PAGE_WRITE     (1 << 2)    /* Writable */
14#define _PAGE_EXEC      (1 << 3)    /* Executable */
15#define _PAGE_USER      (1 << 4)    /* User */
16#define _PAGE_GLOBAL    (1 << 5)    /* Global */
17#define _PAGE_ACCESSED  (1 << 6)    /* Set by hardware on any access */
18#define _PAGE_DIRTY     (1 << 7)    /* Set by hardware on any write */
19#define _PAGE_SOFT      (3 << 8)    /* Reserved for software */
20
21#define _PAGE_SPECIAL   (1 << 8)    /* RSW: 0x1 */
22
23#ifdef CONFIG_MEM_SOFT_DIRTY
24
25/* ext_svrsw60t59b: bit 59 for soft-dirty tracking */
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 /* CONFIG_MEM_SOFT_DIRTY */
40
41#ifdef CONFIG_HAVE_ARCH_USERFAULTFD_WP
42
43/* ext_svrsw60t59b: Bit(60) for uffd-wp tracking */
44#define _PAGE_UFFD_WP							\
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 uffd-wp tracking.
50 */
51#define _PAGE_SWP_UFFD_WP						\
52	((riscv_has_extension_unlikely(RISCV_ISA_EXT_SVRSW60T59B)) ?	\
53	 _PAGE_USER : 0)
54#else
55#define _PAGE_UFFD_WP		0
56#define _PAGE_SWP_UFFD_WP	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/* Used for swap PTEs only. */
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 /* _ASM_RISCV_PGTABLE_BITS_H */
~/ Read-only file preview.