From: Stefano Stabellini Subject: Re: [PATCH v2 2/2] xen/m2p: use GNTTABOP_unmap_and_replace to reinstate the original mapping Date: Tue, 23 Jul 2013 13:47:43 +0100 Message-ID: References: <1374510529-10395-2-git-send-email-stefano.stabellini@eu.citrix.com> <51ED65B5.1090705@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <51ED65B5.1090705@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: David Vrabel Cc: xen-devel@lists.xensource.com, Ian.Campbell@citrix.com, Stefano Stabellini , alex@alex.org.uk, dcrisan@flexiant.com List-Id: xen-devel@lists.xenproject.org On Mon, 22 Jul 2013, David Vrabel wrote: > On 22/07/13 17:28, Stefano Stabellini wrote: > > GNTTABOP_unmap_grant_ref unmaps a grant and replaces it with a 0 > > mapping instead of reinstating the original mapping. > > Doing so separately would be racy. > > > > To unmap a grant and reinstate the original mapping atomically we use > > GNTTABOP_unmap_and_replace. > > GNTTABOP_unmap_and_replace doesn't work with GNTMAP_contains_pte, so > > don't use it for kmaps. GNTTABOP_unmap_and_replace zeroes the mapping > > passed in new_addr so we have to reinstate it, however that is a > > per-cpu mapping only used for balloon trade pages, so we can be sure that > > it's not going to be accessed while the mapping is not valid. > > This solves the problem of userspace accessing a disk image on an NFS > mount but what would blkback talking to an iSCSI LUN? Will that need > similar fixes to blkback? This series does not need to fix this now though. No, it wouldn't. We actually need a better hypercall than GNTTABOP_unmap_and_replace for that. > > --- a/arch/x86/xen/p2m.c > > +++ b/arch/x86/xen/p2m.c > > @@ -161,6 +161,7 @@ > > #include > > #include > > #include > > +#include > > #include > > > > #include "multicalls.h" > > @@ -967,7 +968,9 @@ int m2p_remove_override(struct page *page, > > if (kmap_op != NULL) { > > if (!PageHighMem(page)) { > > struct multicall_space mcs; > > - struct gnttab_unmap_grant_ref *unmap_op; > > + struct gnttab_unmap_and_replace *unmap_op; > > + unsigned long trade_page_address = (unsigned long) > > + __va(page_to_pfn(get_balloon_trade_page()) << PAGE_SHIFT); > > struct page *trade_page = get_balloon_trade_page(); > unsigned long trade_page_address = page_address(trade_page); > > (And the corresponding put_balloon_trade_page() once you've added it.) > > Otherwise, > > Reviewed-by: David Vrabel > thanks