18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef _XEN_PAGE_H 38c2ecf20Sopenharmony_ci#define _XEN_PAGE_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#include <asm/page.h> 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci/* The hypercall interface supports only 4KB page */ 88c2ecf20Sopenharmony_ci#define XEN_PAGE_SHIFT 12 98c2ecf20Sopenharmony_ci#define XEN_PAGE_SIZE (_AC(1, UL) << XEN_PAGE_SHIFT) 108c2ecf20Sopenharmony_ci#define XEN_PAGE_MASK (~(XEN_PAGE_SIZE-1)) 118c2ecf20Sopenharmony_ci#define xen_offset_in_page(p) ((unsigned long)(p) & ~XEN_PAGE_MASK) 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci/* 148c2ecf20Sopenharmony_ci * We assume that PAGE_SIZE is a multiple of XEN_PAGE_SIZE 158c2ecf20Sopenharmony_ci * XXX: Add a BUILD_BUG_ON? 168c2ecf20Sopenharmony_ci */ 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#define xen_pfn_to_page(xen_pfn) \ 198c2ecf20Sopenharmony_ci (pfn_to_page((unsigned long)(xen_pfn) >> (PAGE_SHIFT - XEN_PAGE_SHIFT))) 208c2ecf20Sopenharmony_ci#define page_to_xen_pfn(page) \ 218c2ecf20Sopenharmony_ci ((page_to_pfn(page)) << (PAGE_SHIFT - XEN_PAGE_SHIFT)) 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci#define XEN_PFN_PER_PAGE (PAGE_SIZE / XEN_PAGE_SIZE) 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci#define XEN_PFN_DOWN(x) ((x) >> XEN_PAGE_SHIFT) 268c2ecf20Sopenharmony_ci#define XEN_PFN_UP(x) (((x) + XEN_PAGE_SIZE-1) >> XEN_PAGE_SHIFT) 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#include <asm/xen/page.h> 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci/* Return the GFN associated to the first 4KB of the page */ 318c2ecf20Sopenharmony_cistatic inline unsigned long xen_page_to_gfn(struct page *page) 328c2ecf20Sopenharmony_ci{ 338c2ecf20Sopenharmony_ci return pfn_to_gfn(page_to_xen_pfn(page)); 348c2ecf20Sopenharmony_ci} 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_cistruct xen_memory_region { 378c2ecf20Sopenharmony_ci unsigned long start_pfn; 388c2ecf20Sopenharmony_ci unsigned long n_pfns; 398c2ecf20Sopenharmony_ci}; 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci#define XEN_EXTRA_MEM_MAX_REGIONS 128 /* == E820_MAX_ENTRIES_ZEROPAGE */ 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ciextern __initdata 448c2ecf20Sopenharmony_cistruct xen_memory_region xen_extra_mem[XEN_EXTRA_MEM_MAX_REGIONS]; 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ciextern unsigned long xen_released_pages; 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci#endif /* _XEN_PAGE_H */ 49