xref: /kvm-unit-tests/lib/ppc64/asm/pgtable-hwdef.h (revision d4c8e725478d05179b23be44fc61357a92da4912)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 #ifndef _ASMPPC64_PGTABLE_HWDEF_H_
3 #define _ASMPPC64_PGTABLE_HWDEF_H_
4 /*
5  * Copyright (C) 2024, IBM Inc, Nicholas Piggin <npiggin@gmail.com>
6  *
7  * Derived from Linux kernel MMU code.
8  */
9 
10 #include <asm/page.h>
11 
12 #define UL(x) _AC(x, UL)
13 
14 /*
15  * Book3S-64 Radix page table
16  */
17 #define PGDIR_SHIFT		39
18 #define PUD_SHIFT		30
19 #define PMD_SHIFT		21
20 
21 #define PTRS_PER_PGD		(SZ_64K / 8)
22 #define PTRS_PER_PUD		(SZ_4K / 8)
23 #define PTRS_PER_PMD		(SZ_4K / 8)
24 #if PAGE_SIZE == SZ_4K
25 #define PTRS_PER_PTE		(SZ_4K / 8)
26 #else /* 64K */
27 #define PTRS_PER_PTE		(256 / 8)
28 #endif
29 
30 #define PGDIR_SIZE		(UL(1) << PGDIR_SHIFT)
31 #define PGDIR_MASK		(~(PGDIR_SIZE-1))
32 
33 #define PUD_SIZE		(UL(1) << PUD_SHIFT)
34 #define PUD_MASK		(~(PUD_SIZE-1))
35 
36 #define PMD_SIZE		(UL(1) << PMD_SHIFT)
37 #define PMD_MASK		(~(PMD_SIZE-1))
38 
39 #define _PAGE_VALID		0x8000000000000000UL
40 #define _PAGE_PTE		0x4000000000000000UL
41 
42 #define _PAGE_EXEC		0x00001 /* execute permission */
43 #define _PAGE_WRITE		0x00002 /* write access allowed */
44 #define _PAGE_READ		0x00004 /* read access allowed */
45 #define _PAGE_PRIVILEGED	0x00008 /* kernel access only */
46 #define _PAGE_SAO		0x00010 /* Strong access order */
47 #define _PAGE_NON_IDEMPOTENT	0x00020 /* non idempotent memory */
48 #define _PAGE_TOLERANT		0x00030 /* tolerant memory, cache inhibited */
49 #define _PAGE_DIRTY		0x00080 /* C: page changed */
50 #define _PAGE_ACCESSED		0x00100 /* R: page referenced */
51 
52 /*
53  * Software bits
54  */
55 #define _PAGE_SW0		0x2000000000000000UL
56 #define _PAGE_SW1		0x00800UL
57 #define _PAGE_SW2		0x00400UL
58 #define _PAGE_SW3		0x00200UL
59 
60 /*
61  * Highest possible physical address.
62  */
63 #define PHYS_MASK_SHIFT		(48)
64 #define PHYS_MASK		((UL(1) << PHYS_MASK_SHIFT) - 1)
65 
66 #endif /* _ASMPPC64_PGTABLE_HWDEF_H_ */
67