[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH] xen-mapcache: use MAP_FIXED flag so the mmap address hint is always honored
On Fri, Mar 15, 2019 at 06:14:09PM +0000, Anthony PERARD wrote: > On Fri, Mar 15, 2019 at 09:58:47AM +0100, Roger Pau Monne wrote: > > Or if it's not possible to honor the hinted address an error is returned > > instead. This makes it easier to spot the actual failure, instead of > > failing later on when the caller of xen_remap_bucket realizes the > > mapping has not been created at the requested address. > > > > Also note that at least on FreeBSD using MAP_FIXED will cause mmap to > > try harder to honor the passed address. > > > > Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx> > > The patch looks fine, and MAP_FIXED seems to be the expected behavior > even on Linux. > > Acked-by: Anthony PERARD <anthony.perard@xxxxxxxxxx> > > > diff --git a/hw/i386/xen/xen-mapcache.c b/hw/i386/xen/xen-mapcache.c > > @@ -185,8 +185,14 @@ static void xen_remap_bucket(MapCacheEntry *entry, > > } > > > > if (!dummy) { > > + /* > > + * If the caller has requested the mapping at a specific address > > use > > + * MAP_FIXED to make sure it's honored. Note that with MAP_FIXED at > > + * least FreeBSD will try harder to honor the passed address. > > + */ > > vaddr_base = xenforeignmemory_map2(xen_fmem, xen_domid, vaddr, > > - PROT_READ | PROT_WRITE, 0, > > + PROT_READ | PROT_WRITE, > > + vaddr ? MAP_FIXED : 0, > > nb_pfn, pfns, err); I've noticed that there's a mmap call just after which has also vaddr as hint, should that second call also have MAP_FIXED as flags? On the other hand, it seems that when vaddr!=NULL, dummy==false, so that second mmap call will never be called with vaddr!=NULL. But it might be worse fixing this in the same patch. > } else { > /* > * We create dummy mappings where we are unable to create a foreign > * mapping immediately due to certain circumstances (i.e. on resume now) > */ > vaddr_base = mmap(vaddr, size, PROT_READ | PROT_WRITE, > MAP_ANON | MAP_SHARED, -1, 0); -- Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |