xref: /openbmc/linux/arch/x86/include/asm/page_64.h (revision 4da722ca)
1 #ifndef _ASM_X86_PAGE_64_H
2 #define _ASM_X86_PAGE_64_H
3 
4 #include <asm/page_64_types.h>
5 
6 #ifndef __ASSEMBLY__
7 #include <asm/alternative.h>
8 
9 /* duplicated to the one in bootmem.h */
10 extern unsigned long max_pfn;
11 extern unsigned long phys_base;
12 
13 static inline unsigned long __phys_addr_nodebug(unsigned long x)
14 {
15 	unsigned long y = x - __START_KERNEL_map;
16 
17 	/* use the carry flag to determine if x was < __START_KERNEL_map */
18 	x = y + ((x > y) ? phys_base : (__START_KERNEL_map - PAGE_OFFSET));
19 
20 	return x;
21 }
22 
23 #ifdef CONFIG_DEBUG_VIRTUAL
24 extern unsigned long __phys_addr(unsigned long);
25 extern unsigned long __phys_addr_symbol(unsigned long);
26 #else
27 #define __phys_addr(x)		__phys_addr_nodebug(x)
28 #define __phys_addr_symbol(x) \
29 	((unsigned long)(x) - __START_KERNEL_map + phys_base)
30 #endif
31 
32 #define __phys_reloc_hide(x)	(x)
33 
34 #ifdef CONFIG_FLATMEM
35 #define pfn_valid(pfn)          ((pfn) < max_pfn)
36 #endif
37 
38 void clear_page_orig(void *page);
39 void clear_page_rep(void *page);
40 void clear_page_erms(void *page);
41 
42 static inline void clear_page(void *page)
43 {
44 	alternative_call_2(clear_page_orig,
45 			   clear_page_rep, X86_FEATURE_REP_GOOD,
46 			   clear_page_erms, X86_FEATURE_ERMS,
47 			   "=D" (page),
48 			   "0" (page)
49 			   : "memory", "rax", "rcx");
50 }
51 
52 void copy_page(void *to, void *from);
53 
54 #endif	/* !__ASSEMBLY__ */
55 
56 #ifdef CONFIG_X86_VSYSCALL_EMULATION
57 # define __HAVE_ARCH_GATE_AREA 1
58 #endif
59 
60 #endif /* _ASM_X86_PAGE_64_H */
61