1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _ASM_X86_PAGE_DEFS_H
3#define _ASM_X86_PAGE_DEFS_H
4
5#include <linux/const.h>
6#include <linux/types.h>
7#include <linux/mem_encrypt.h>
8
9/* PAGE_SHIFT determines the page size */
10#define PAGE_SHIFT CONFIG_PAGE_SHIFT
11#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
12#define PAGE_MASK (~(PAGE_SIZE-1))
13
14#define __VIRTUAL_MASK ((1UL << __VIRTUAL_MASK_SHIFT) - 1)
15
16/* Cast P*D_MASK to a signed type so that it is sign-extended if
17 virtual addresses are 32-bits but physical addresses are larger
18 (ie, 32-bit PAE). */
19#define PHYSICAL_PAGE_MASK (((signed long)PAGE_MASK) & __PHYSICAL_MASK)
20#define PHYSICAL_PMD_PAGE_MASK (((signed long)PMD_MASK) & __PHYSICAL_MASK)
21#define PHYSICAL_PUD_PAGE_MASK (((signed long)PUD_MASK) & __PHYSICAL_MASK)
22
23#define HPAGE_SHIFT PMD_SHIFT
24#define HPAGE_SIZE (_AC(1,UL) << HPAGE_SHIFT)
25#define HPAGE_MASK (~(HPAGE_SIZE - 1))
26#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
27
28#define HUGE_MAX_HSTATE 2
29
30#define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET)
31
32#define VM_DATA_DEFAULT_FLAGS VM_DATA_FLAGS_TSK_EXEC
33
34#define __PHYSICAL_START ALIGN(CONFIG_PHYSICAL_START, \
35 CONFIG_PHYSICAL_ALIGN)
36
37#define __START_KERNEL (__START_KERNEL_map + __PHYSICAL_START)
38
39#ifdef CONFIG_X86_64
40#include <asm/page_64_types.h>
41#define IOREMAP_MAX_ORDER (PUD_SHIFT)
42#else
43#include <asm/page_32_types.h>
44#define IOREMAP_MAX_ORDER (PMD_SHIFT)
45#endif /* CONFIG_X86_64 */
46
47#ifndef __ASSEMBLY__
48
49#ifdef CONFIG_DYNAMIC_PHYSICAL_MASK
50extern phys_addr_t physical_mask;
51#define __PHYSICAL_MASK physical_mask
52#else
53#define __PHYSICAL_MASK ((phys_addr_t)((1ULL << __PHYSICAL_MASK_SHIFT) - 1))
54#endif
55
56extern int devmem_is_allowed(unsigned long pagenr);
57
58extern unsigned long max_low_pfn_mapped;
59extern unsigned long max_pfn_mapped;
60
61static inline phys_addr_t get_max_mapped(void)
62{
63 return (phys_addr_t)max_pfn_mapped << PAGE_SHIFT;
64}
65
66bool pfn_range_is_mapped(unsigned long start_pfn, unsigned long end_pfn);
67
68extern void initmem_init(void);
69
70#endif /* !__ASSEMBLY__ */
71
72#endif /* _ASM_X86_PAGE_DEFS_H */
73

source code of linux/arch/x86/include/asm/page_types.h