18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef _ASM_X86_PAGE_64_H
38c2ecf20Sopenharmony_ci#define _ASM_X86_PAGE_64_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#include <asm/page_64_types.h>
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__
88c2ecf20Sopenharmony_ci#include <asm/alternative.h>
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci/* duplicated to the one in bootmem.h */
118c2ecf20Sopenharmony_ciextern unsigned long max_pfn;
128c2ecf20Sopenharmony_ciextern unsigned long phys_base;
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ciextern unsigned long page_offset_base;
158c2ecf20Sopenharmony_ciextern unsigned long vmalloc_base;
168c2ecf20Sopenharmony_ciextern unsigned long vmemmap_base;
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_cistatic inline unsigned long __phys_addr_nodebug(unsigned long x)
198c2ecf20Sopenharmony_ci{
208c2ecf20Sopenharmony_ci	unsigned long y = x - __START_KERNEL_map;
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci	/* use the carry flag to determine if x was < __START_KERNEL_map */
238c2ecf20Sopenharmony_ci	x = y + ((x > y) ? phys_base : (__START_KERNEL_map - PAGE_OFFSET));
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci	return x;
268c2ecf20Sopenharmony_ci}
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#ifdef CONFIG_DEBUG_VIRTUAL
298c2ecf20Sopenharmony_ciextern unsigned long __phys_addr(unsigned long);
308c2ecf20Sopenharmony_ciextern unsigned long __phys_addr_symbol(unsigned long);
318c2ecf20Sopenharmony_ci#else
328c2ecf20Sopenharmony_ci#define __phys_addr(x)		__phys_addr_nodebug(x)
338c2ecf20Sopenharmony_ci#define __phys_addr_symbol(x) \
348c2ecf20Sopenharmony_ci	((unsigned long)(x) - __START_KERNEL_map + phys_base)
358c2ecf20Sopenharmony_ci#endif
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci#define __phys_reloc_hide(x)	(x)
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci#ifdef CONFIG_FLATMEM
408c2ecf20Sopenharmony_ci#define pfn_valid(pfn)          ((pfn) < max_pfn)
418c2ecf20Sopenharmony_ci#endif
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_civoid clear_page_orig(void *page);
448c2ecf20Sopenharmony_civoid clear_page_rep(void *page);
458c2ecf20Sopenharmony_civoid clear_page_erms(void *page);
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_cistatic inline void clear_page(void *page)
488c2ecf20Sopenharmony_ci{
498c2ecf20Sopenharmony_ci	alternative_call_2(clear_page_orig,
508c2ecf20Sopenharmony_ci			   clear_page_rep, X86_FEATURE_REP_GOOD,
518c2ecf20Sopenharmony_ci			   clear_page_erms, X86_FEATURE_ERMS,
528c2ecf20Sopenharmony_ci			   "=D" (page),
538c2ecf20Sopenharmony_ci			   "0" (page)
548c2ecf20Sopenharmony_ci			   : "cc", "memory", "rax", "rcx");
558c2ecf20Sopenharmony_ci}
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_civoid copy_page(void *to, void *from);
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci#endif	/* !__ASSEMBLY__ */
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci#ifdef CONFIG_X86_VSYSCALL_EMULATION
628c2ecf20Sopenharmony_ci# define __HAVE_ARCH_GATE_AREA 1
638c2ecf20Sopenharmony_ci#endif
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci#endif /* _ASM_X86_PAGE_64_H */
66