From: Ian Campbell Subject: Re: [PATCH v5 4/4] xen: introduce XENMEM_exchange_and_pin and XENMEM_unpin Date: Tue, 10 Sep 2013 19:40:48 +0100 Message-ID: <1378838448.3057.45.camel@dagon.hellion.org.uk> References: <1378742763-24299-4-git-send-email-stefano.stabellini@eu.citrix.com> <522F298D02000078000F1DE0@nat28.tlf.novell.com> <1378817450.21748.111.camel@kazak.uk.xensource.com> <522F3AB702000078000F1EA0@nat28.tlf.novell.com> <20130910183759.GE26833@ocelot.phlegethon.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VJSrt-0004v5-Gy for xen-devel@lists.xenproject.org; Tue, 10 Sep 2013 18:40:53 +0000 In-Reply-To: <20130910183759.GE26833@ocelot.phlegethon.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Tim Deegan Cc: xen-devel , Jan Beulich , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org On Tue, 2013-09-10 at 19:37 +0100, Tim Deegan wrote: > At 19:32 +0100 on 10 Sep (1378841575), Stefano Stabellini wrote: > > On Tue, 10 Sep 2013, Jan Beulich wrote: > > > >>> On 10.09.13 at 14:50, Ian Campbell wrote: > > > > On Tue, 2013-09-10 at 13:15 +0100, Jan Beulich wrote: > > > > > > > >> > @@ -459,6 +460,52 @@ DEFINE_XEN_GUEST_HANDLE(xen_mem_sharing_op_t); > > > >> > * The zero value is appropiate. > > > >> > */ > > > >> > > > > >> > +#define XENMEM_exchange_and_pin 26 > > > >> > +/* > > > >> > + * This hypercall is similar to XENMEM_exchange: it takes the same > > > >> > + * struct as an argument and it exchanges the pages passed in with a new > > > >> > + * set of pages. The new pages are going to be "pinned": it's guaranteed > > > >> > + * that their p2m mapping won't be changed until explicitly "unpinned". > > > >> > + * The content of the exchanged pages is lost. > > > >> > + * Only normal guest r/w memory can be pinned: no granted pages or > > > >> > + * ballooned pages. > > > >> > + * If return code is zero then @out.extent_list provides the DMA frame > > > >> > + * numbers of the newly-allocated memory. > > > >> > > > >> "DMA"? I don't think that term is universally true across all possible > > > >> architectures (but we're in an architecture independent header > > > >> here). "Machine" would probably be better (as it implies CPU > > > >> perspective, whereas DMA hints at device perspective). > > > > > > > > I think DMA here is correct. The purpose of exchange and pin is so that > > > > the page can be safely handed to a device for DMA. > > > > > > > > On an architecture where DMA address != Machine address then this should > > > > indeed return the DMA addresses. > > > > > > One problem is that I think there are architectures where there's no > > > single canonical DMA address; such an address may depend on the > > > placement of a device in the system's topology. Hence I don't think > > > it would even be possible to return "the" DMA address here. It ought > > > to be the machine address (CPU view), and the consumer ought to > > > know how to translate this to a DMA address for a particular device. > > > > We could leave it up to each architecture to specify whether the > > hypercall returns a DMA address or a Machine address (according to > > their definition of DMA address and Machine address). > > Even if this is a common header. > > Is this going to be needed on architectures other than arm? It's not > useful for x86, AFAICT. It might be needed for PVH with passthrough? Maybe that insists on an IOMMU, in which case maybe it is arm only. Until someone does e.g. a ppc port ;-) Ian.