[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v3 02/32] libxc: unify xc_dom_p2m_{host/guest}
Unify both functions into xc_dom_p2m. Should not introduce any functional change. Signed-off-by: Roger Pau Monnà <roger.pau@xxxxxxxxxx> Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> Cc: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx> Cc: Ian Campbell <ian.campbell@xxxxxxxxxx> Cc: Wei Liu <wei.liu2@xxxxxxxxxx> Cc: Samuel Thibault <samuel.thibault@xxxxxxxxxxxx> --- stubdom/grub/kexec.c | 4 ++-- tools/libxc/include/xc_dom.h | 14 ++------------ tools/libxc/xc_dom_boot.c | 10 +++++----- tools/libxc/xc_dom_compat_linux.c | 4 ++-- tools/libxc/xc_dom_x86.c | 32 ++++++++++++++++---------------- tools/libxl/libxl_dom.c | 4 ++-- 6 files changed, 29 insertions(+), 39 deletions(-) diff --git a/stubdom/grub/kexec.c b/stubdom/grub/kexec.c index 4c33b25..0b2f4f3 100644 --- a/stubdom/grub/kexec.c +++ b/stubdom/grub/kexec.c @@ -358,9 +358,9 @@ void kexec(void *kernel, long kernel_size, void *module, long module_size, char #ifdef __x86_64__ MMUEXT_PIN_L4_TABLE, #endif - xc_dom_p2m_host(dom, dom->pgtables_seg.pfn), + xc_dom_p2m(dom, dom->pgtables_seg.pfn), dom->guest_domid)) != 0 ) { - grub_printf("pin_table(%lx) returned %d\n", xc_dom_p2m_host(dom, + grub_printf("pin_table(%lx) returned %d\n", xc_dom_p2m(dom, dom->pgtables_seg.pfn), rc); errnum = ERR_BOOT_FAILURE; goto out_remap; diff --git a/tools/libxc/include/xc_dom.h b/tools/libxc/include/xc_dom.h index a7d059a..ec9e293 100644 --- a/tools/libxc/include/xc_dom.h +++ b/tools/libxc/include/xc_dom.h @@ -376,19 +376,9 @@ static inline void *xc_dom_vaddr_to_ptr(struct xc_dom_image *dom, return ptr + offset; } -static inline xen_pfn_t xc_dom_p2m_host(struct xc_dom_image *dom, xen_pfn_t pfn) +static inline xen_pfn_t xc_dom_p2m(struct xc_dom_image *dom, xen_pfn_t pfn) { - if (dom->shadow_enabled) - return pfn; - if (pfn < dom->rambase_pfn || pfn >= dom->rambase_pfn + dom->total_pages) - return INVALID_MFN; - return dom->p2m_host[pfn - dom->rambase_pfn]; -} - -static inline xen_pfn_t xc_dom_p2m_guest(struct xc_dom_image *dom, - xen_pfn_t pfn) -{ - if (xc_dom_feature_translated(dom)) + if ( dom->shadow_enabled || xc_dom_feature_translated(dom) ) return pfn; if (pfn < dom->rambase_pfn || pfn >= dom->rambase_pfn + dom->total_pages) return INVALID_MFN; diff --git a/tools/libxc/xc_dom_boot.c b/tools/libxc/xc_dom_boot.c index f82db2d..fda9e52 100644 --- a/tools/libxc/xc_dom_boot.c +++ b/tools/libxc/xc_dom_boot.c @@ -54,7 +54,7 @@ static int setup_hypercall_page(struct xc_dom_image *dom) dom->parms.virt_hypercall, pfn); domctl.cmd = XEN_DOMCTL_hypercall_init; domctl.domain = dom->guest_domid; - domctl.u.hypercall_init.gmfn = xc_dom_p2m_guest(dom, pfn); + domctl.u.hypercall_init.gmfn = xc_dom_p2m(dom, pfn); rc = do_domctl(dom->xch, &domctl); if ( rc != 0 ) xc_dom_panic(dom->xch, XC_INTERNAL_ERROR, @@ -84,7 +84,7 @@ static int clear_page(struct xc_dom_image *dom, xen_pfn_t pfn) if ( pfn == 0 ) return 0; - dst = xc_dom_p2m_host(dom, pfn); + dst = xc_dom_p2m(dom, pfn); DOMPRINTF("%s: pfn 0x%" PRIpfn ", mfn 0x%" PRIpfn "", __FUNCTION__, pfn, dst); rc = xc_clear_domain_page(dom->xch, dom->guest_domid, dst); @@ -178,7 +178,7 @@ void *xc_dom_boot_domU_map(struct xc_dom_image *dom, xen_pfn_t pfn, } for ( i = 0; i < count; i++ ) - entries[i].mfn = xc_dom_p2m_host(dom, pfn + i); + entries[i].mfn = xc_dom_p2m(dom, pfn + i); ptr = xc_map_foreign_ranges(dom->xch, dom->guest_domid, count << page_shift, PROT_READ | PROT_WRITE, 1 << page_shift, @@ -435,8 +435,8 @@ int xc_dom_gnttab_init(struct xc_dom_image *dom) dom->console_domid, dom->xenstore_domid); } else { return xc_dom_gnttab_seed(dom->xch, dom->guest_domid, - xc_dom_p2m_host(dom, dom->console_pfn), - xc_dom_p2m_host(dom, dom->xenstore_pfn), + xc_dom_p2m(dom, dom->console_pfn), + xc_dom_p2m(dom, dom->xenstore_pfn), dom->console_domid, dom->xenstore_domid); } } diff --git a/tools/libxc/xc_dom_compat_linux.c b/tools/libxc/xc_dom_compat_linux.c index 2c14a0f..acccde9 100644 --- a/tools/libxc/xc_dom_compat_linux.c +++ b/tools/libxc/xc_dom_compat_linux.c @@ -65,8 +65,8 @@ static int xc_linux_build_internal(struct xc_dom_image *dom, if ( (rc = xc_dom_gnttab_init(dom)) != 0) goto out; - *console_mfn = xc_dom_p2m_host(dom, dom->console_pfn); - *store_mfn = xc_dom_p2m_host(dom, dom->xenstore_pfn); + *console_mfn = xc_dom_p2m(dom, dom->console_pfn); + *store_mfn = xc_dom_p2m(dom, dom->xenstore_pfn); out: return rc; diff --git a/tools/libxc/xc_dom_x86.c b/tools/libxc/xc_dom_x86.c index 920fe42..0d80c18 100644 --- a/tools/libxc/xc_dom_x86.c +++ b/tools/libxc/xc_dom_x86.c @@ -248,7 +248,7 @@ static int setup_pgtables_x86_32_pae(struct xc_dom_image *dom) unsigned long l3off, l2off = 0, l1off; xen_vaddr_t addr; xen_pfn_t pgpfn; - xen_pfn_t l3mfn = xc_dom_p2m_guest(dom, l3pfn); + xen_pfn_t l3mfn = xc_dom_p2m(dom, l3pfn); if ( dom->parms.pae == 1 ) { @@ -280,7 +280,7 @@ static int setup_pgtables_x86_32_pae(struct xc_dom_image *dom) goto pfn_error; l3off = l3_table_offset_pae(addr); l3tab[l3off] = - pfn_to_paddr(xc_dom_p2m_guest(dom, l2pfn)) | L3_PROT; + pfn_to_paddr(xc_dom_p2m(dom, l2pfn)) | L3_PROT; l2pfn++; } @@ -292,7 +292,7 @@ static int setup_pgtables_x86_32_pae(struct xc_dom_image *dom) goto pfn_error; l2off = l2_table_offset_pae(addr); l2tab[l2off] = - pfn_to_paddr(xc_dom_p2m_guest(dom, l1pfn)) | L2_PROT; + pfn_to_paddr(xc_dom_p2m(dom, l1pfn)) | L2_PROT; l1pfn++; } @@ -300,7 +300,7 @@ static int setup_pgtables_x86_32_pae(struct xc_dom_image *dom) l1off = l1_table_offset_pae(addr); pgpfn = (addr - dom->parms.virt_base) >> PAGE_SHIFT_X86; l1tab[l1off] = - pfn_to_paddr(xc_dom_p2m_guest(dom, pgpfn)) | L1_PROT; + pfn_to_paddr(xc_dom_p2m(dom, pgpfn)) | L1_PROT; if ( (addr >= dom->pgtables_seg.vstart) && (addr < dom->pgtables_seg.vend) ) l1tab[l1off] &= ~_PAGE_RW; /* page tables are r/o */ @@ -316,7 +316,7 @@ static int setup_pgtables_x86_32_pae(struct xc_dom_image *dom) if ( dom->virt_pgtab_end <= 0xc0000000 ) { DOMPRINTF("%s: PAE: extra l2 page table for l3#3", __FUNCTION__); - l3tab[3] = pfn_to_paddr(xc_dom_p2m_guest(dom, l2pfn)) | L3_PROT; + l3tab[3] = pfn_to_paddr(xc_dom_p2m(dom, l2pfn)) | L3_PROT; } return 0; @@ -375,7 +375,7 @@ static int setup_pgtables_x86_64(struct xc_dom_image *dom) goto pfn_error; l4off = l4_table_offset_x86_64(addr); l4tab[l4off] = - pfn_to_paddr(xc_dom_p2m_guest(dom, l3pfn)) | L4_PROT; + pfn_to_paddr(xc_dom_p2m(dom, l3pfn)) | L4_PROT; l3pfn++; } @@ -387,7 +387,7 @@ static int setup_pgtables_x86_64(struct xc_dom_image *dom) goto pfn_error; l3off = l3_table_offset_x86_64(addr); l3tab[l3off] = - pfn_to_paddr(xc_dom_p2m_guest(dom, l2pfn)) | L3_PROT; + pfn_to_paddr(xc_dom_p2m(dom, l2pfn)) | L3_PROT; l2pfn++; } @@ -399,7 +399,7 @@ static int setup_pgtables_x86_64(struct xc_dom_image *dom) goto pfn_error; l2off = l2_table_offset_x86_64(addr); l2tab[l2off] = - pfn_to_paddr(xc_dom_p2m_guest(dom, l1pfn)) | L2_PROT; + pfn_to_paddr(xc_dom_p2m(dom, l1pfn)) | L2_PROT; l1pfn++; } @@ -407,7 +407,7 @@ static int setup_pgtables_x86_64(struct xc_dom_image *dom) l1off = l1_table_offset_x86_64(addr); pgpfn = (addr - dom->parms.virt_base) >> PAGE_SHIFT_X86; l1tab[l1off] = - pfn_to_paddr(xc_dom_p2m_guest(dom, pgpfn)) | L1_PROT; + pfn_to_paddr(xc_dom_p2m(dom, pgpfn)) | L1_PROT; if ( (!dom->pvh_enabled) && (addr >= dom->pgtables_seg.vstart) && (addr < dom->pgtables_seg.vend) ) @@ -490,9 +490,9 @@ static int start_info_x86_32(struct xc_dom_image *dom) start_info->mfn_list = dom->p2m_seg.vstart; start_info->flags = dom->flags; - start_info->store_mfn = xc_dom_p2m_guest(dom, dom->xenstore_pfn); + start_info->store_mfn = xc_dom_p2m(dom, dom->xenstore_pfn); start_info->store_evtchn = dom->xenstore_evtchn; - start_info->console.domU.mfn = xc_dom_p2m_guest(dom, dom->console_pfn); + start_info->console.domU.mfn = xc_dom_p2m(dom, dom->console_pfn); start_info->console.domU.evtchn = dom->console_evtchn; if ( dom->ramdisk_blob ) @@ -536,9 +536,9 @@ static int start_info_x86_64(struct xc_dom_image *dom) start_info->mfn_list = dom->p2m_seg.vstart; start_info->flags = dom->flags; - start_info->store_mfn = xc_dom_p2m_guest(dom, dom->xenstore_pfn); + start_info->store_mfn = xc_dom_p2m(dom, dom->xenstore_pfn); start_info->store_evtchn = dom->xenstore_evtchn; - start_info->console.domU.mfn = xc_dom_p2m_guest(dom, dom->console_pfn); + start_info->console.domU.mfn = xc_dom_p2m(dom, dom->console_pfn); start_info->console.domU.evtchn = dom->console_evtchn; if ( dom->ramdisk_blob ) @@ -622,7 +622,7 @@ static int vcpu_x86_32(struct xc_dom_image *dom, void *ptr) dom->parms.pae == 3 /* bimodal */ ) ctxt->vm_assist |= (1UL << VMASST_TYPE_pae_extended_cr3); - cr3_pfn = xc_dom_p2m_guest(dom, dom->pgtables_seg.pfn); + cr3_pfn = xc_dom_p2m(dom, dom->pgtables_seg.pfn); ctxt->ctrlreg[3] = xen_pfn_to_cr3_x86_32(cr3_pfn); DOMPRINTF("%s: cr3: pfn 0x%" PRIpfn " mfn 0x%" PRIpfn "", __FUNCTION__, dom->pgtables_seg.pfn, cr3_pfn); @@ -648,7 +648,7 @@ static int vcpu_x86_64(struct xc_dom_image *dom, void *ptr) ctxt->user_regs.rflags = 1 << 9; /* Interrupt Enable */ ctxt->flags = VGCF_in_kernel_X86_64 | VGCF_online_X86_64; - cr3_pfn = xc_dom_p2m_guest(dom, dom->pgtables_seg.pfn); + cr3_pfn = xc_dom_p2m(dom, dom->pgtables_seg.pfn); ctxt->ctrlreg[3] = xen_pfn_to_cr3_x86_64(cr3_pfn); DOMPRINTF("%s: cr3: pfn 0x%" PRIpfn " mfn 0x%" PRIpfn "", __FUNCTION__, dom->pgtables_seg.pfn, cr3_pfn); @@ -1020,7 +1020,7 @@ int arch_setup_bootlate(struct xc_dom_image *dom) /* paravirtualized guest */ xc_dom_unmap_one(dom, dom->pgtables_seg.pfn); rc = pin_table(dom->xch, pgd_type, - xc_dom_p2m_host(dom, dom->pgtables_seg.pfn), + xc_dom_p2m(dom, dom->pgtables_seg.pfn), dom->guest_domid); if ( rc != 0 ) { diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index 1c9418a..fb2f916 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -745,8 +745,8 @@ int libxl__build_pv(libxl__gc *gc, uint32_t domid, state->console_mfn = dom->console_pfn; state->store_mfn = dom->xenstore_pfn; } else { - state->console_mfn = xc_dom_p2m_host(dom, dom->console_pfn); - state->store_mfn = xc_dom_p2m_host(dom, dom->xenstore_pfn); + state->console_mfn = xc_dom_p2m(dom, dom->console_pfn); + state->store_mfn = xc_dom_p2m(dom, dom->xenstore_pfn); } libxl__file_reference_unmap(&state->pv_kernel); -- 1.9.5 (Apple Git-50.3) _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |