[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v7 03/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> Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Acked-by: Wei Liu <wei.liu2@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> --- Changes since v3: - Add Andrew Cooper Reviewed-by. - Add Wei Acked-by. --- 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 602c5cd..e794a13 100644 --- a/tools/libxc/include/xc_dom.h +++ b/tools/libxc/include/xc_dom.h @@ -373,19 +373,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 8e06406..7c30f96 100644 --- a/tools/libxc/xc_dom_boot.c +++ b/tools/libxc/xc_dom_boot.c @@ -53,7 +53,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, @@ -83,7 +83,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); @@ -177,7 +177,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, @@ -434,8 +434,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 a3abb99..5c1f043 100644 --- a/tools/libxc/xc_dom_compat_linux.c +++ b/tools/libxc/xc_dom_compat_linux.c @@ -64,8 +64,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 e2f3792..f3962cd 100644 --- a/tools/libxc/xc_dom_x86.c +++ b/tools/libxc/xc_dom_x86.c @@ -247,7 +247,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 == XEN_PAE_YES ) { @@ -279,7 +279,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++; } @@ -291,7 +291,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++; } @@ -299,7 +299,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 ( (!dom->pvh_enabled) && (addr >= dom->pgtables_seg.vstart) && (addr < dom->pgtables_seg.vend) ) @@ -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 ) @@ -606,7 +606,7 @@ static int vcpu_x86_32(struct xc_dom_image *dom, void *ptr) dom->parms.pae == XEN_PAE_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); @@ -645,7 +645,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); @@ -1018,7 +1018,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 b514377..286df93 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -739,8 +739,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 |