All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jean Guyader <jean.guyader@citrix.com>
To: "Tim (Xen.org)" <tim@xen.org>
Cc: Jan Beulich <JBeulich@suse.com>,
	"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Subject: Re: [PATCH 4/5] xen: Enforce casting for guest_handle_cast
Date: Thu, 14 Jun 2012 16:39:13 +0100	[thread overview]
Message-ID: <20120614153913.GC24063@spongy> (raw)
In-Reply-To: <20120614144008.GA24063@spongy>

On 14/06 03:40, Jean Guyader wrote:
> On 14/06 03:27, Tim Deegan wrote:
> > At 15:26 +0100 on 14 Jun (1339687574), Tim Deegan wrote:
> > > At 15:08 +0100 on 14 Jun (1339686495), Jean Guyader wrote:
> > > > Maybe I should put here the reason that led me to do something
> > > > like that. Here is what I'm trying to do:
> > > > 
> > > >         XEN_GUEST_HANDLE (uint8_t) slop_hnd =
> > > >                 guest_handle_cast (pfn_list_hnd, uint8_t);
> > > >         guest_handle_add_offset (slop_hnd, sizeof (v4v_pfn_list_t));
> > > >         pfn_hnd = guest_handle_cast (slop_hnd, v4v_pfn_t);
> > > > 
> > > > I need to cast to uint8_t first to get the add_offset to behave
> > > > correctly. Maybe what I need would need a new macro that would
> > > > do those two operations.
> > > > 
> > > > What would be the proper way to doing something like this?
> > > 
> > > You could avoid it altogether by dropping struct v4v_ring_data, and
> > > passing a v4v_pfn_t array directly with the 'npage' as a separate
> > > hypercall argument.  AFAICS struct v4v_ring_data has no other useful
> > > fields.
> > 
> > Excuse me, I meant struct v4v_pfn_list_t.
> > 
> 
> You probably mean both, because we doing the same thing with
> v4v_ring_data_t and v4v_ring_data_ent_t.
> 

Actually I don't want to get rid of the v4v_ring_data_t struct.

The idea being this struct is that we might want to extend it in the future
so having a wrapper arround with a magic is important to detect which
version of the struct is being used.

Here are the structs:

typedef struct v4v_ring_data_ent                                                                      
{                                                                                                     
    struct v4v_addr ring;                                                                             
    uint16_t flags;                                                                                   
    uint16_t pad0;                                                                                    
    uint32_t space_required;                                                                          
    uint32_t max_message_size;                                                                        
} v4v_ring_data_ent_t;                                                                                
DEFINE_XEN_GUEST_HANDLE (v4v_ring_data_ent_t);                                                        
                                                                                                      
typedef struct v4v_ring_data                                                                          
{                                                                                                     
    uint64_t magic;                                                                                   
    uint32_t nent;                                                                                    
    uint32_t padding;                                                                                 
    uint64_t reserved[4];                                                                             
    v4v_ring_data_ent_t ring[0];                                                                      
} v4v_ring_data_t;                                                                                    
DEFINE_XEN_GUEST_HANDLE (v4v_ring_data_t);

I get a XEN_GUEST_HANDLE(v4v_ring_data_t) as argument of my hypercall and I would
like to access the ring data inside it which is a XEN_GUEST_HANDLE as well.

Here is the code that I use for doing that (with explicte cast in guest_handle_cast):
    XEN_GUEST_HANDLE (v4v_ring_data_ent_t) ring_data_ent_hnd;
    XEN_GUEST_HANDLE (uint8_t) slop_hnd =
        guest_handle_cast (ring_data_hnd, uint8_t);
    guest_handle_add_offset (slop_hnd, sizeof (v4v_ring_data_t));
    ring_data_ent_hnd =
        guest_handle_cast (slop_hnd, v4v_ring_data_ent_t);
    ret = v4v_fill_ring_datas (d, ring_data.nent, ring_data_ent_hnd);

Thanks for your help.
Jean

  reply	other threads:[~2012-06-14 15:39 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-31 15:07 [RFC][PATCH 0/5] Add V4V to Xen Jean Guyader
2012-05-31 15:07 ` [PATCH 1/5] xen: add ssize_t to types.h Jean Guyader
2012-05-31 15:29   ` Jan Beulich
2012-05-31 15:07 ` [PATCH 2/5] xen: Add headers to include/Makefile Jean Guyader
2012-05-31 15:37   ` Jan Beulich
2012-05-31 15:07 ` [PATCH 3/5] v4v: Introduce VIRQ_V4V Jean Guyader
2012-05-31 15:44   ` Jan Beulich
2012-05-31 15:07 ` [PATCH 4/5] xen: Enforce casting for guest_handle_cast Jean Guyader
2012-05-31 15:47   ` Jan Beulich
2012-06-14 14:08     ` Jean Guyader
2012-06-14 14:23       ` Jan Beulich
2012-06-14 14:26       ` Tim Deegan
2012-06-14 14:27         ` Tim Deegan
2012-06-14 14:40           ` Jean Guyader
2012-06-14 15:39             ` Jean Guyader [this message]
2012-06-14 15:50               ` Tim Deegan
2012-06-14 16:00               ` Jan Beulich
2012-06-14 21:19                 ` Jean Guyader
2012-06-18 11:36               ` Jan Beulich
2012-06-18 12:50                 ` Jean Guyader
2012-05-31 15:07 ` [PATCH 5/5] xen: Add V4V implementation Jean Guyader
2012-05-31 15:59   ` Jan Beulich
2012-06-01 12:41 ` [RFC][PATCH 0/5] Add V4V to Xen Jan Beulich
2012-06-01 13:24   ` George Dunlap
2012-06-14 14:01     ` Jean Guyader
2012-06-01 13:47 ` Ian Campbell
2012-06-07  8:47   ` Jean Guyader
2012-06-07  9:42   ` Jean Guyader
2012-06-07 11:40     ` Tim Deegan
2012-06-07 15:36       ` Tim Deegan
2012-06-13 10:48         ` Jean Guyader
2012-06-13 11:44           ` Tim Deegan
2012-06-14 10:55             ` Jean Guyader
2012-06-14 14:56               ` Tim Deegan
2012-06-14 15:10                 ` Jean Guyader
2012-06-14 15:35                   ` Tim Deegan
2012-06-14 21:14                     ` Jean Guyader
2012-06-25  9:05                       ` Tim Deegan
2012-06-26 14:38                         ` Ian Campbell
2012-06-28 10:38                           ` Jean Guyader
2012-06-28 10:50                             ` Tim Deegan
2012-06-28 11:24                               ` Jean Guyader
2012-06-28 11:34                             ` Ian Campbell
2012-06-28 11:43                               ` Jean Guyader
2012-06-28 11:58                                 ` Ian Campbell
2012-06-28 12:10                                   ` Jean Guyader
2012-06-28 12:36                                     ` Ian Campbell
2012-06-28 13:43                                       ` Jean Guyader
2012-06-28 13:47                                         ` Ian Campbell
2012-06-28 16:35                                           ` Jean Guyader
2012-07-02 14:14                                             ` Ian Campbell
2012-06-28 10:19                         ` Jean Guyader
  -- strict thread matches above, loose matches on Subject: below --
2012-05-31 14:52 Jean Guyader
2012-05-31 14:52 ` [PATCH 4/5] xen: Enforce casting for guest_handle_cast Jean Guyader

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=20120614153913.GC24063@spongy \
    --to=jean.guyader@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=tim@xen.org \
    --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.