From: Ian Campbell <ian.campbell@citrix.com>
To: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: elena.ufimtseva@oracle.com, wei.liu2@citrix.com,
stefano.stabellini@eu.citrix.com, andrew.cooper3@citrix.com,
dario.faggioli@citrix.com, ian.jackson@eu.citrix.com,
xen-devel@lists.xen.org, jbeulich@suse.com, keir@xen.org,
dgdegra@tycho.nsa.gov
Subject: Re: [PATCH v8 4/5] libxc: Provide set_xen_guest_handle_offset macro
Date: Fri, 8 May 2015 17:19:44 +0100 [thread overview]
Message-ID: <1431101984.2660.538.camel@citrix.com> (raw)
In-Reply-To: <554CDEAC.3050709@oracle.com>
On Fri, 2015-05-08 at 12:05 -0400, Boris Ostrovsky wrote:
> On 05/08/2015 11:56 AM, Ian Campbell wrote:
> > On Fri, 2015-05-08 at 11:41 -0400, Boris Ostrovsky wrote:
> >> On 05/08/2015 10:57 AM, Ian Campbell wrote:
> >>> On Wed, 2015-05-06 at 14:15 -0400, Boris Ostrovsky wrote:
> >>>> Add set_xen_guest_handle_offset() macro that can be used for setting
> >>>> xen_guest_handle to an offset into hypercall buffer.
> >>>>
> >>>> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> >>>> ---
> >>>> tools/libxc/include/xenctrl.h | 11 ++++++++---
> >>>> 1 files changed, 8 insertions(+), 3 deletions(-)
> >>>>
> >>>> diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
> >>>> index 8c8eae6..4e6f62c 100644
> >>>> --- a/tools/libxc/include/xenctrl.h
> >>>> +++ b/tools/libxc/include/xenctrl.h
> >>>> @@ -322,16 +322,21 @@ typedef struct xc_hypercall_buffer xc_hypercall_buffer_t;
> >>>> * Set a xen_guest_handle in a type safe manner, ensuring that the
> >>>> * data pointer has been correctly allocated.
> >>>> */
> >>>> -#undef set_xen_guest_handle
> >>>> -#define set_xen_guest_handle(_hnd, _val) \
> >>>> +#undef set_xen_guest_handle_offset
> >>> This isn't strictly speaking needed since you aren't trying to override
> >>> a version of this interface provided by the hypervisor headers.
> >>>
> >>>> +#define set_xen_guest_handle_offset(_hnd, _val, _off) \
> >>>> do { \
> >>>> xc_hypercall_buffer_t _hcbuf_hnd1; \
> >>>> typeof(XC__HYPERCALL_BUFFER_NAME(_val)) *_hcbuf_hnd2 = \
> >>>> HYPERCALL_BUFFER(_val); \
> >>>> (void) (&_hcbuf_hnd1 == _hcbuf_hnd2); \
> >>>> - set_xen_guest_handle_raw(_hnd, (_hcbuf_hnd2)->hbuf); \
> >>>> + set_xen_guest_handle_raw(_hnd, \
> >>>> + (_hcbuf_hnd2)->hbuf + (_off)); \
> >>> The hypervisor side guest_handle_add_offset equivalents operate in
> >>> multiples of the type. If we can arrange that here too then I think that
> >>> would be good.
> >>>
> >>> I think that means
> >>> + (_hcbuf_hnd2)->hbuf + ((sizeof(*_val)*(_off))); \
> >>>
> >>> Then the caller becomes e.g.
> >>>
> >>> set_xen_guest_handle_offset(sysctl.u.pcitopoinfo.devs, devs, processed);
> >>>
> >>> which is much nicer IMHO.
> >>
> >> That's what I started with.
> >>
> >> This, however, breaks at least two things:
> >> -- Callers that pass HYPERCALL_BUFFER_NULL to set_xen_guest_handle().
> >> This I think can be fixed by declaring a void *HYPERCALL_BUFFER_NULL
> >> (currenty HYPERCALL_BUFFER_NULL is just a syntactic building block)
> >>
> >> -- DECLARE_NAMED_HYPERCALL_BOUNCE. This makes _val a non-existing symbol
> >> (it creates a xc__hypercall_buffer_val). That I am not sure I know how
> >> to fix. Add type size filed to struct xc_hypercall_buffer?
> > How about refactoring such that this macro becomes an internal helper
> > used by both set_xen_guest_handle and set_xen_guest_handle_offset and
> > takes the (_hcbuf_hnd2)->hbuf or (_hcbuf_hnd2)->hbuf +
> > ((sizeof(*_val)*(_off)) as appropriate? (iow don't implement set as
> > set_offset(0))
>
> But that will preclude us from using _offset() variant of the macro for
> variables declared with DECLARE_NAMED_HYPERCALL_BOUNCE (and possibly
> others, I haven't checked), won't it? We don't have any such uses now
> but nevertheless...
Lets cross that bridge if/when we come to it.
Ian.
next prev parent reply other threads:[~2015-05-08 16:19 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-06 18:14 [PATCH v8 0/5] Display IO topology when PXM data is available (plus some cleanup) Boris Ostrovsky
2015-05-06 18:14 ` [PATCH v8 1/5] sysctl: Add sysctl interface for querying PCI topology Boris Ostrovsky
2015-05-07 13:52 ` Andrew Cooper
2015-05-06 18:14 ` [PATCH v8 2/5] libxl/libxc: Move libxl_get_cpu_topology()'s hypercall buffer management to libxc Boris Ostrovsky
2015-05-06 18:15 ` [PATCH v8 3/5] libxl/libxc: Move libxl_get_numainfo()'s " Boris Ostrovsky
2015-05-06 18:15 ` [PATCH v8 4/5] libxc: Provide set_xen_guest_handle_offset macro Boris Ostrovsky
2015-05-08 14:57 ` Ian Campbell
2015-05-08 15:41 ` Boris Ostrovsky
2015-05-08 15:56 ` Ian Campbell
2015-05-08 16:05 ` Boris Ostrovsky
2015-05-08 16:19 ` Ian Campbell [this message]
2015-05-06 18:15 ` [PATCH v8 5/5] libxl: Add interface for querying hypervisor about PCI topology Boris Ostrovsky
2015-05-08 15:11 ` Ian Campbell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1431101984.2660.538.camel@citrix.com \
--to=ian.campbell@citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=boris.ostrovsky@oracle.com \
--cc=dario.faggioli@citrix.com \
--cc=dgdegra@tycho.nsa.gov \
--cc=elena.ufimtseva@oracle.com \
--cc=ian.jackson@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=keir@xen.org \
--cc=stefano.stabellini@eu.citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.