c/s 4045953 "x86/paging: Enforce PG_external == PG_translate == PG_refcounts" in the hypervisor finally prevented the construction of PV autotranslate guests.
Remove support for such guests in the domain builder, bailing out with an obvious "no longer supported" message, rather than a more obscure "SHADOW_OP_ENABLED failed". As a piece of cleanup, rename xc_dom_feature_translated() to xc_dom_translated() to match its actual semantics. Signed-off-by: Andrew Cooper <andrew.coop...@citrix.com> --- CC: Ian Jackson <ian.jack...@eu.citrix.com> CC: Wei Liu <wei.l...@citrix.com> --- tools/libxc/include/xc_dom.h | 5 +- tools/libxc/xc_dom_arm.c | 6 +- tools/libxc/xc_dom_boot.c | 2 +- tools/libxc/xc_dom_x86.c | 133 ++++++++----------------------------------- tools/libxl/libxl_dom.c | 2 +- 5 files changed, 30 insertions(+), 118 deletions(-) diff --git a/tools/libxc/include/xc_dom.h b/tools/libxc/include/xc_dom.h index b416eb5..ce47058 100644 --- a/tools/libxc/include/xc_dom.h +++ b/tools/libxc/include/xc_dom.h @@ -168,7 +168,6 @@ struct xc_dom_image { xc_interface *xch; domid_t guest_domid; int claim_enabled; /* 0 by default, 1 enables it */ - int shadow_enabled; int xen_version; xen_capabilities_info_t xen_caps; @@ -334,7 +333,7 @@ int xc_dom_gnttab_seed(xc_interface *xch, domid_t domid, xen_pfn_t xenstore_gmfn, domid_t console_domid, domid_t xenstore_domid); -int xc_dom_feature_translated(struct xc_dom_image *dom); +bool xc_dom_translated(const struct xc_dom_image *dom); /* --- debugging bits ---------------------------------------------- */ @@ -420,7 +419,7 @@ static inline void *xc_dom_vaddr_to_ptr(struct xc_dom_image *dom, static inline xen_pfn_t xc_dom_p2m(struct xc_dom_image *dom, xen_pfn_t pfn) { - if ( dom->shadow_enabled || xc_dom_feature_translated(dom) ) + if ( xc_dom_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_arm.c b/tools/libxc/xc_dom_arm.c index a7e839e..e7d4bd0 100644 --- a/tools/libxc/xc_dom_arm.c +++ b/tools/libxc/xc_dom_arm.c @@ -419,8 +419,6 @@ static int meminit(struct xc_dom_image *dom) if ( rc ) return rc; - dom->shadow_enabled = 1; - for ( i = 0; ramsize && i < GUEST_RAM_BANKS; i++ ) { uint64_t banksize = ramsize > bankmax[i] ? bankmax[i] : ramsize; @@ -504,9 +502,9 @@ static int meminit(struct xc_dom_image *dom) return 0; } -int xc_dom_feature_translated(struct xc_dom_image *dom) +bool xc_dom_translated(const struct xc_dom_image *dom) { - return 1; + return true; } /* ------------------------------------------------------------------------ */ diff --git a/tools/libxc/xc_dom_boot.c b/tools/libxc/xc_dom_boot.c index 791041b..c3b44dd 100644 --- a/tools/libxc/xc_dom_boot.c +++ b/tools/libxc/xc_dom_boot.c @@ -407,7 +407,7 @@ int xc_dom_gnttab_hvm_seed(xc_interface *xch, domid_t domid, int xc_dom_gnttab_init(struct xc_dom_image *dom) { - if ( xc_dom_feature_translated(dom) ) { + if ( xc_dom_translated(dom) ) { return xc_dom_gnttab_hvm_seed(dom->xch, dom->guest_domid, dom->console_pfn, dom->xenstore_pfn, dom->console_domid, dom->xenstore_domid); diff --git a/tools/libxc/xc_dom_x86.c b/tools/libxc/xc_dom_x86.c index c176c00..cb68efc 100644 --- a/tools/libxc/xc_dom_x86.c +++ b/tools/libxc/xc_dom_x86.c @@ -546,7 +546,7 @@ static int alloc_magic_pages(struct xc_dom_image *dom) dom->console_pfn = xc_dom_alloc_page(dom, "console"); if ( dom->console_pfn == INVALID_PFN ) return -1; - if ( xc_dom_feature_translated(dom) ) + if ( xc_dom_translated(dom) ) { dom->shared_info_pfn = xc_dom_alloc_page(dom, "shared info"); if ( dom->shared_info_pfn == INVALID_PFN ) @@ -720,8 +720,7 @@ static int start_info_x86_32(struct xc_dom_image *dom) start_info_x86_32_t *start_info = xc_dom_pfn_to_ptr(dom, dom->start_info_pfn, 1); xen_pfn_t shinfo = - xc_dom_feature_translated(dom) ? dom->shared_info_pfn : dom-> - shared_info_mfn; + xc_dom_translated(dom) ? dom->shared_info_pfn : dom->shared_info_mfn; DOMPRINTF_CALLED(dom->xch); @@ -767,8 +766,7 @@ static int start_info_x86_64(struct xc_dom_image *dom) start_info_x86_64_t *start_info = xc_dom_pfn_to_ptr(dom, dom->start_info_pfn, 1); xen_pfn_t shinfo = - xc_dom_feature_translated(dom) ? dom->shared_info_pfn : dom-> - shared_info_mfn; + xc_dom_translated(dom) ? dom->shared_info_pfn : dom->shared_info_mfn; DOMPRINTF_CALLED(dom->xch); @@ -1063,29 +1061,6 @@ static int x86_compat(xc_interface *xch, domid_t domid, char *guest_type) return rc; } -static int x86_shadow(xc_interface *xch, domid_t domid) -{ - int rc, mode; - - DOMPRINTF_CALLED(xch); - - mode = XEN_DOMCTL_SHADOW_ENABLE_REFCOUNT | - XEN_DOMCTL_SHADOW_ENABLE_TRANSLATE; - - rc = xc_shadow_control(xch, domid, - XEN_DOMCTL_SHADOW_OP_ENABLE, - NULL, 0, NULL, mode, NULL); - if ( rc != 0 ) - { - xc_dom_panic(xch, XC_INTERNAL_ERROR, - "%s: SHADOW_OP_ENABLE (mode=0x%x) failed (rc=%d)", - __FUNCTION__, mode, rc); - return rc; - } - xc_dom_printf(xch, "%s: shadow enabled (mode=0x%x)", __FUNCTION__, mode); - return rc; -} - static int meminit_pv(struct xc_dom_image *dom) { int rc; @@ -1100,13 +1075,6 @@ static int meminit_pv(struct xc_dom_image *dom) rc = x86_compat(dom->xch, dom->guest_domid, dom->guest_type); if ( rc ) return rc; - if ( xc_dom_feature_translated(dom) ) - { - dom->shadow_enabled = 1; - rc = x86_shadow(dom->xch, dom->guest_domid); - if ( rc ) - return rc; - } /* try to claim pages for early warning of insufficient memory avail */ if ( dom->claim_enabled ) @@ -1576,37 +1544,14 @@ static int meminit_hvm(struct xc_dom_image *dom) static int bootearly(struct xc_dom_image *dom) { - DOMPRINTF("%s: doing nothing", __FUNCTION__); - return 0; -} - -/* - * Map grant table frames into guest physmap. PVH manages grant during boot - * via HVM mechanisms. - */ -static int map_grant_table_frames(struct xc_dom_image *dom) -{ - int i, rc; - - for ( i = 0; ; i++ ) + if ( dom->container_type == XC_DOM_PV_CONTAINER && + elf_xen_feature_get(XENFEAT_auto_translated_physmap, dom->f_active) ) { - rc = xc_domain_add_to_physmap(dom->xch, dom->guest_domid, - XENMAPSPACE_grant_table, - i, dom->p2m_size + i); - if ( rc != 0 ) - { - if ( (i > 0) && (errno == EINVAL) ) - { - DOMPRINTF("%s: %d grant tables mapped", __FUNCTION__, i); - break; - } - xc_dom_panic(dom->xch, XC_INTERNAL_ERROR, - "%s: mapping grant tables failed " "(pfn=0x%" PRIpfn - ", rc=%d, errno=%d)", __FUNCTION__, dom->p2m_size + i, - rc, errno); - return rc; - } + DOMPRINTF("PV Autotranslate guests no longer supported"); + errno = EOPNOTSUPP; + return -1; } + return 0; } @@ -1629,47 +1574,20 @@ static int bootlate_pv(struct xc_dom_image *dom) if ( !strcmp(types[i].guest, dom->guest_type) ) pgd_type = types[i].pgd_type; - if ( !xc_dom_feature_translated(dom) ) - { - /* paravirtualized guest */ - - /* Drop references to all initial page tables before pinning. */ - xc_dom_unmap_one(dom, dom->pgtables_seg.pfn); - xc_dom_unmap_one(dom, dom->p2m_seg.pfn); - rc = pin_table(dom->xch, pgd_type, - xc_dom_p2m(dom, dom->pgtables_seg.pfn), - dom->guest_domid); - if ( rc != 0 ) - { - xc_dom_panic(dom->xch, XC_INTERNAL_ERROR, - "%s: pin_table failed (pfn 0x%" PRIpfn ", rc=%d)", - __FUNCTION__, dom->pgtables_seg.pfn, rc); - return rc; - } - shinfo = dom->shared_info_mfn; - } - else + /* Drop references to all initial page tables before pinning. */ + xc_dom_unmap_one(dom, dom->pgtables_seg.pfn); + xc_dom_unmap_one(dom, dom->p2m_seg.pfn); + rc = pin_table(dom->xch, pgd_type, + xc_dom_p2m(dom, dom->pgtables_seg.pfn), + dom->guest_domid); + if ( rc != 0 ) { - /* paravirtualized guest with auto-translation */ - - /* Map shared info frame into guest physmap. */ - rc = xc_domain_add_to_physmap(dom->xch, dom->guest_domid, - XENMAPSPACE_shared_info, - 0, dom->shared_info_pfn); - if ( rc != 0 ) - { - xc_dom_panic(dom->xch, XC_INTERNAL_ERROR, "%s: mapping" - " shared_info failed (pfn=0x%" PRIpfn ", rc=%d, errno: %d)", - __FUNCTION__, dom->shared_info_pfn, rc, errno); - return rc; - } - - rc = map_grant_table_frames(dom); - if ( rc != 0 ) - return rc; - - shinfo = dom->shared_info_pfn; + xc_dom_panic(dom->xch, XC_INTERNAL_ERROR, + "%s: pin_table failed (pfn 0x%" PRIpfn ", rc=%d)", + __FUNCTION__, dom->pgtables_seg.pfn, rc); + return rc; } + shinfo = dom->shared_info_mfn; /* setup shared_info page */ DOMPRINTF("%s: shared_info: pfn 0x%" PRIpfn ", mfn 0x%" PRIpfn "", @@ -1823,13 +1741,10 @@ static int bootlate_hvm(struct xc_dom_image *dom) return 0; } -int xc_dom_feature_translated(struct xc_dom_image *dom) +bool xc_dom_translated(const struct xc_dom_image *dom) { - /* Guests running inside HVM containers are always auto-translated. */ - if ( dom->container_type == XC_DOM_HVM_CONTAINER ) - return 1; - - return elf_xen_feature_get(XENFEAT_auto_translated_physmap, dom->f_active); + /* HVM guests are translated. PV guests are not. */ + return dom->container_type == XC_DOM_HVM_CONTAINER; } /* ------------------------------------------------------------------------ */ diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index e133962..c88b904 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -767,7 +767,7 @@ int libxl__build_pv(libxl__gc *gc, uint32_t domid, if (ret != 0) goto out; - if (xc_dom_feature_translated(dom)) { + if (xc_dom_translated(dom)) { state->console_mfn = dom->console_pfn; state->store_mfn = dom->xenstore_pfn; } else { -- 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org https://lists.xen.org/xen-devel