From: Ian Campbell Subject: Re: [PATCH v4 1/9] libxc: add DECLARE_HYPERCALL_BUFFER_SHADOW() Date: Wed, 7 May 2014 12:45:54 +0100 Message-ID: <1399463154.13430.13.camel@kazak.uk.xensource.com> References: <1398883012-28413-1-git-send-email-andrew.cooper3@citrix.com> <1398883012-28413-2-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1398883012-28413-2-git-send-email-andrew.cooper3@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: Andrew Cooper Cc: David Vrabel , Xen-devel List-Id: xen-devel@lists.xenproject.org On Wed, 2014-04-30 at 19:36 +0100, Andrew Cooper wrote: > From: David Vrabel > > DECLARE_HYPERCALL_BUFFER_SHADOW() is like DECLARE_HYPERCALL_BUFFER() > except it is backed by an already allocated hypercall buffer. I suppose enhancing DECLARE_HYPERCALL_BUFFER_ARGUMENT to have this property has issues with unused variables? HYPERCALL_BUFFER_AS_PTR() would have been an alternative implementation (similar to AS_ARG), I suppose there is no particular reason to prefer one over the other? > > Signed-off-by: David Vrabel > --- > tools/libxc/xenctrl.h | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > > diff --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h > index 02129f7..15d2f4f 100644 > --- a/tools/libxc/xenctrl.h > +++ b/tools/libxc/xenctrl.h > @@ -266,6 +266,24 @@ typedef struct xc_hypercall_buffer xc_hypercall_buffer_t; > } > > /* > + * Like DECLARE_HYPERCALL_BUFFER() but using an already allocated > + * hypercall buffer, _hbuf. > + * > + * Useful when a hypercall buffer is passed to a function and access > + * via the user pointer is required. > + * > + * See DECLARE_HYPERCALL_BUFFER_ARGUMENT() if the user pointer is not > + * required. > + */ > +#define DECLARE_HYPERCALL_BUFFER_SHADOW(_type, _name, _hbuf) \ > + _type *_name = _hbuf->hbuf; \ > + xc_hypercall_buffer_t XC__HYPERCALL_BUFFER_NAME(_name) = { \ > + .hbuf = (void *)-1, \ > + .param_shadow = _hbuf, \ > + HYPERCALL_BUFFER_INIT_NO_BOUNCE \ > + } > + > +/* > * Declare the necessary data structure to allow a hypercall buffer > * passed as an argument to a function to be used in the normal way. > */