^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef _ASM_X86_PAGE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define _ASM_X86_PAGE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #ifdef __KERNEL__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <asm/page_types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #ifdef CONFIG_X86_64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <asm/page_64.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <asm/page_32.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #endif /* CONFIG_X86_64 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #ifndef __ASSEMBLY__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) struct page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/range.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) extern struct range pfn_mapped[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) extern int nr_pfn_mapped;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) static inline void clear_user_page(void *page, unsigned long vaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) struct page *pg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) clear_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) struct page *topage)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) copy_page(to, from);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #define alloc_zeroed_user_highpage_movable(vma, vaddr) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) alloc_page_vma(GFP_HIGHUSER_MOVABLE | __GFP_ZERO | __GFP_CMA, vma, vaddr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE_MOVABLE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #ifndef __pa
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #define __pa(x) __phys_addr((unsigned long)(x))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #define __pa_nodebug(x) __phys_addr_nodebug((unsigned long)(x))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) /* __pa_symbol should be used for C visible symbols.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) This seems to be the official gcc blessed way to do such arithmetic. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * We need __phys_reloc_hide() here because gcc may assume that there is no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) * overflow during __pa() calculation and can optimize it unexpectedly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * Newer versions of gcc provide -fno-strict-overflow switch to handle this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * case properly. Once all supported versions of gcc understand it, we can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) * remove this Voodoo magic stuff. (i.e. once gcc3.x is deprecated)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #define __pa_symbol(x) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) __phys_addr_symbol(__phys_reloc_hide((unsigned long)(x)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) #ifndef __va
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) #define __boot_va(x) __va(x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) #define __boot_pa(x) __pa(x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) * virt_to_page(kaddr) returns a valid pointer if and only if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) * virt_addr_valid(kaddr) returns true.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) extern bool __virt_addr_valid(unsigned long kaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) #define virt_addr_valid(kaddr) __virt_addr_valid((unsigned long) (kaddr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) #endif /* __ASSEMBLY__ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) #include <asm-generic/memory_model.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) #include <asm-generic/getorder.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) #define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) #endif /* __KERNEL__ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) #endif /* _ASM_X86_PAGE_H */