Lines Matching +full:top +full:- +full:level
1 // SPDX-License-Identifier: GPL-2.0
9 * For accesses by Xen a three-level tree linked via mfns only is set up to
22 * The p2m_top_mfn level is limited to 1 page, so the maximum representable
23 * pseudo-physical address space is:
27 * unsigned long (8 bytes on 64-bit, 4 bytes on 32), leading to
33 * leaf entries, or for the top root, or middle one, for which there is a void
40 * We also have the possibility of setting 1-1 mappings on certain regions, so
44 * The benefit of this is, that we can assume for non-RAM regions (think
60 * non-identity pfn. To protect ourselves against we elect to set (and get) the
85 #include "xen-ops.h"
120 * Used to set HYPERVISOR_shared_info->arch.max_pfn so the toolstack
142 static void p2m_top_mfn_init(unsigned long *top) in p2m_top_mfn_init() argument
147 top[i] = virt_to_mfn(p2m_mid_missing_mfn); in p2m_top_mfn_init()
150 static void p2m_top_mfn_p_init(unsigned long **top) in p2m_top_mfn_p_init() argument
155 top[i] = p2m_mid_missing_mfn; in p2m_top_mfn_p_init()
211 * - At boot time we're called rather early, and must use alloc_bootmem*()
214 * - After resume we're called from within stop_machine, but the mfn
221 unsigned int level, topidx, mididx; in xen_build_mfn_list_list() local
224 if (xen_start_info->flags & SIF_VIRT_P2M_4TOOLS) in xen_build_mfn_list_list()
227 /* Pre-initialize p2m_top_mfn to be completely missing */ in xen_build_mfn_list_list()
249 &level); in xen_build_mfn_list_list()
250 BUG_ON(!ptep || level != PG_LEVEL_4K); in xen_build_mfn_list_list()
252 ptep = (pte_t *)((unsigned long)ptep & ~(PAGE_SIZE - 1)); in xen_build_mfn_list_list()
262 pfn += (P2M_MID_PER_PAGE - 1) * P2M_PER_PAGE; in xen_build_mfn_list_list()
282 if (xen_start_info->flags & SIF_VIRT_P2M_4TOOLS) in xen_setup_mfn_list_list()
283 HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list = ~0UL; in xen_setup_mfn_list_list()
285 HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list = in xen_setup_mfn_list_list()
287 HYPERVISOR_shared_info->arch.max_pfn = xen_p2m_last_pfn; in xen_setup_mfn_list_list()
288 HYPERVISOR_shared_info->arch.p2m_generation = 0; in xen_setup_mfn_list_list()
289 HYPERVISOR_shared_info->arch.p2m_vaddr = (unsigned long)xen_p2m_addr; in xen_setup_mfn_list_list()
290 HYPERVISOR_shared_info->arch.p2m_cr3 = in xen_setup_mfn_list_list()
294 /* Set up p2m_top to point to the domain-builder provided p2m pages */
299 xen_p2m_addr = (unsigned long *)xen_start_info->mfn_list; in xen_build_dynamic_phys_to_machine()
300 xen_p2m_size = ALIGN(xen_start_info->nr_pages, P2M_PER_PAGE); in xen_build_dynamic_phys_to_machine()
302 for (pfn = xen_start_info->nr_pages; pfn < xen_p2m_size; pfn++) in xen_build_dynamic_phys_to_machine()
358 * Try to map missing/identity PMDs or p2m-pages if possible. in xen_rebuild_p2m_list()
367 chunk = (pfn & (P2M_PER_PAGE * P2M_MID_PER_PAGE - 1)) ? in xen_rebuild_p2m_list()
391 /* Map complete missing or identity p2m-page. */ in xen_rebuild_p2m_list()
438 unsigned int level; in get_phys_to_machine() local
447 ptep = lookup_address((unsigned long)(xen_p2m_addr + pfn), &level); in get_phys_to_machine()
448 BUG_ON(!ptep || level != PG_LEVEL_4K); in get_phys_to_machine()
473 unsigned int level; in alloc_p2m_pmd() local
482 for (i--; i >= 0; i--) in alloc_p2m_pmd()
489 vaddr = addr & ~(PMD_SIZE * PMDS_PER_MID_PAGE - 1); in alloc_p2m_pmd()
500 ptechk = lookup_address(vaddr, &level); in alloc_p2m_pmd()
502 HYPERVISOR_shared_info->arch.p2m_generation++; in alloc_p2m_pmd()
507 HYPERVISOR_shared_info->arch.p2m_generation++; in alloc_p2m_pmd()
521 return lookup_address(addr, &level); in alloc_p2m_pmd()
526 * that both the top and mid levels are allocated, and make sure the
536 unsigned int level; in xen_alloc_p2m_entry() local
541 ptep = lookup_address(addr, &level); in xen_alloc_p2m_entry()
542 BUG_ON(!ptep || level != PG_LEVEL_4K); in xen_alloc_p2m_entry()
543 pte_pg = (pte_t *)((unsigned long)ptep & ~(PAGE_SIZE - 1)); in xen_alloc_p2m_entry()
546 /* PMD level is missing, allocate a new one */ in xen_alloc_p2m_entry()
549 return -ENOMEM; in xen_alloc_p2m_entry()
560 /* Separately check the mid mfn level */ in xen_alloc_p2m_entry()
567 return -ENOMEM; in xen_alloc_p2m_entry()
593 return -ENOMEM; in xen_alloc_p2m_entry()
598 p2m_init_identity(p2m, pfn & ~(P2M_PER_PAGE - 1)); in xen_alloc_p2m_entry()
603 HYPERVISOR_shared_info->arch.p2m_generation++; in xen_alloc_p2m_entry()
608 HYPERVISOR_shared_info->arch.p2m_generation++; in xen_alloc_p2m_entry()
623 HYPERVISOR_shared_info->arch.max_pfn = xen_p2m_last_pfn; in xen_alloc_p2m_entry()
647 return pfn - pfn_s; in set_phys_range_identity()
653 unsigned int level; in __set_phys_to_machine() local
667 ptep = lookup_address((unsigned long)(xen_p2m_addr + pfn), &level); in __set_phys_to_machine()
668 BUG_ON(!ptep || level != PG_LEVEL_4K); in __set_phys_to_machine()
730 ret = -ENOMEM; in set_foreign_p2m_mapping()
754 ret = -EINVAL; in clear_foreign_p2m_mapping()
787 seq_printf(m, " [0x%lx->0x%lx] %s\n", first_pfn, pfn, in p2m_dump_show()
793 seq_printf(m, " [0x%lx->0x%lx] %s\n", first_pfn, pfn, in p2m_dump_show()