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