From: Jan Beulich Date: Wed, 31 Jan 2018 11:34:08 +0000 (+0100) Subject: xenmem_add_to_physmap_one() has no need to know of XENMAPSPACE_gmfn_range X-Git-Tag: archive/raspbian/4.11.1-1+rpi1~1^2~66^2~660 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=a3da661ad4b5331ef3a4398898c2f5d47b5a0698;p=xen.git xenmem_add_to_physmap_one() has no need to know of XENMAPSPACE_gmfn_range As its name says, it handles a single GMFN only anyway. Note that ARM needs no adjustment, as it doesn't handle the two types at all. Also take the opportunity and clean up the handling of XENMAPSPACE_gmfn a little: There's no point in going through "idx" when capturing the MFN. Signed-off-by: Jan Beulich Acked-by: Andrew Cooper --- diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index c732734ac1..66ea8225a7 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -4105,20 +4105,18 @@ int xenmem_add_to_physmap_one( if ( rc ) return rc; break; - case XENMAPSPACE_gmfn_range: case XENMAPSPACE_gmfn: { p2m_type_t p2mt; gfn = idx; - idx = mfn_x(get_gfn_unshare(d, idx, &p2mt)); + mfn = get_gfn_unshare(d, gfn, &p2mt); /* If the page is still shared, exit early */ if ( p2m_is_shared(p2mt) ) { put_gfn(d, gfn); return -ENOMEM; } - mfn = _mfn(idx); page = get_page_from_mfn(mfn, d); if ( unlikely(!page) ) mfn = INVALID_MFN; @@ -4156,8 +4154,7 @@ int xenmem_add_to_physmap_one( /* Unmap from old location, if any. */ old_gpfn = get_gpfn_from_mfn(mfn_x(mfn)); ASSERT( old_gpfn != SHARED_M2P_ENTRY ); - if ( (space == XENMAPSPACE_gmfn || space == XENMAPSPACE_gmfn_range) && - old_gpfn != gfn ) + if ( space == XENMAPSPACE_gmfn && old_gpfn != gfn ) { rc = -EXDEV; goto put_both; @@ -4170,8 +4167,8 @@ int xenmem_add_to_physmap_one( rc = guest_physmap_add_page(d, gpfn, mfn, PAGE_ORDER_4K); put_both: - /* In the XENMAPSPACE_gmfn, we took a ref of the gfn at the top */ - if ( space == XENMAPSPACE_gmfn || space == XENMAPSPACE_gmfn_range ) + /* In the XENMAPSPACE_gmfn case, we took a ref of the gfn at the top. */ + if ( space == XENMAPSPACE_gmfn ) put_gfn(d, gfn); if ( page ) diff --git a/xen/common/memory.c b/xen/common/memory.c index 09549abec5..59d23a2a98 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -800,7 +800,7 @@ int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xatp, while ( xatp->size > done ) { - rc = xenmem_add_to_physmap_one(d, xatp->space, extra, + rc = xenmem_add_to_physmap_one(d, XENMAPSPACE_gmfn, extra, xatp->idx, _gfn(xatp->gpfn)); if ( rc < 0 ) break;