From mboxrd@z Thu Jan 1 00:00:00 1970 From: George Dunlap Subject: Re: [PATCH RFC v13 19/20] PVH xen tools: libxc changes to build a PVH guest. Date: Mon, 4 Nov 2013 11:56:20 +0000 Message-ID: <52778B64.70400@eu.citrix.com> References: <1379955000-11050-1-git-send-email-george.dunlap@eu.citrix.com> <1379955000-11050-20-git-send-email-george.dunlap@eu.citrix.com> <526165C3.9080400@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1"; Format="flowed" Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <526165C3.9080400@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: =?ISO-8859-1?Q?Roger_Pau_Monn=E9?= , xen-devel@lists.xen.org Cc: Ian Jackson , Ian Campbell List-Id: xen-devel@lists.xenproject.org On 18/10/13 17:45, Roger Pau Monn=E9 wrote: > This patch is incomplete, PVH guests with 4GB of RAM or more will fail > to boot due to libxc temporary mapping the grant table to gfn 0xFFFFE, > which is an invalid gfn on HVM guests, but not on PVH guests. When > libxc removes the mapping of 0xFFFFE it will leave an invalid mfn in > the p2m table, that will make the guest crash when trying to access > that gfn. > > The easiest way I've found to solve this is to temporary map the grant > table to the maximum gfn + 1. This fixes the PVH issue, and also seems > to work fine with HVM guests, here is the diff which should probably be > integrated into this patch: Thanks Roger. I assume it's OK to add your sign-off to this patch? -George > > --- > diff --git a/tools/libxc/xc_dom.h b/tools/libxc/xc_dom.h > index 5168bcd..90679da 100644 > --- a/tools/libxc/xc_dom.h > +++ b/tools/libxc/xc_dom.h > @@ -18,9 +18,6 @@ > = > #define INVALID_P2M_ENTRY ((xen_pfn_t)-1) > = > -/* Scrach PFN for temporary mappings in HVM */ > -#define SCRATCH_PFN_GNTTAB 0xFFFFE > - > /* --- typedefs and structs ---------------------------------------- */ > = > typedef uint64_t xen_vaddr_t; > diff --git a/tools/libxc/xc_dom_boot.c b/tools/libxc/xc_dom_boot.c > index 71e1897..fdfeaf8 100644 > --- a/tools/libxc/xc_dom_boot.c > +++ b/tools/libxc/xc_dom_boot.c > @@ -361,17 +361,27 @@ int xc_dom_gnttab_hvm_seed(xc_interface *xch, domid= _t domid, > domid_t xenstore_domid) > { > int rc; > + xen_pfn_t max_gfn; > struct xen_add_to_physmap xatp =3D { > .domid =3D domid, > .space =3D XENMAPSPACE_grant_table, > .idx =3D 0, > - .gpfn =3D SCRATCH_PFN_GNTTAB > }; > struct xen_remove_from_physmap xrfp =3D { > .domid =3D domid, > - .gpfn =3D SCRATCH_PFN_GNTTAB > }; > = > + max_gfn =3D xc_domain_maximum_gpfn(xch, domid); > + if ( max_gfn <=3D 0 ) { > + xc_dom_panic(xch, XC_INTERNAL_ERROR, > + "%s: failed to get max gfn " > + "[errno=3D%d]\n", > + __FUNCTION__, errno); > + return -1; > + } > + xatp.gpfn =3D max_gfn + 1; > + xrfp.gpfn =3D max_gfn + 1; > + > rc =3D do_memory_op(xch, XENMEM_add_to_physmap, &xatp, sizeof(xatp)= ); > if ( rc !=3D 0 ) > { >