xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* memop struct packing, 32/64 bits
@ 2012-01-19 20:30 Andres Lagar-Cavilla
  2012-01-19 20:49 ` Keir Fraser
  2012-01-19 20:49 ` Konrad Rzeszutek Wilk
  0 siblings, 2 replies; 20+ messages in thread
From: Andres Lagar-Cavilla @ 2012-01-19 20:30 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson, ian.campbell

Hi,
I had the following painful experience. I declared

struct xen_mem_event_op {
    uint8_t       op;           /* XENMEM_*_op_* */
    domid_t       domain;
    uint64_t buffer;
    uint64_t gfn;          /* IN:  gfn of page being operated on */
};
typedef struct xen_mem_event_op xen_mem_event_op_t;

to be passed as the argument of a memory op called form the toolstack. The
hypervisor is 64 bits and the toolstack is 32 bits. My toolstack code
simply:

    xen_mem_event_op_t meo;
... set fields ...
    return do_memory_op(xch, mode, &meo, sizeof(meo));

No joy because 32 bits was packing the struct differently than 64 bits.
Namely, both were adding a 1 byte pad between 'op' and 'domain', but when
compiled in 64 bits mode for the hypervisor, an additional 4 byte pad was
thrown between 'domain' and 'buffer'.

The first question is, what is the preferred way around this. Declare pads
inside the struct?

Exploring the include/public/memory.h declarations and toolstack code, I
see that no current declare includes __attribute__((aligned)) or
__attribute__((packed)), or explicit pads.

So how come things don't break more often for 32 bit toolstacks? pure
luck? Am I missing something?

Thanks!
Andres

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2012-01-23 15:02 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-19 20:30 memop struct packing, 32/64 bits Andres Lagar-Cavilla
2012-01-19 20:49 ` Keir Fraser
2012-01-19 20:57   ` Andres Lagar-Cavilla
2012-01-19 21:11     ` Ian Campbell
2012-01-19 21:21       ` Andres Lagar-Cavilla
2012-01-19 21:23       ` Andres Lagar-Cavilla
2012-01-19 21:56         ` Keir Fraser
2012-01-19 22:00           ` Keir Fraser
2012-01-19 22:04             ` Keir Fraser
2012-01-19 22:05             ` Andres Lagar-Cavilla
2012-01-22 20:37   ` Konrad Rzeszutek Wilk
2012-01-22 20:43     ` Keir Fraser
2012-01-23  9:24     ` Jan Beulich
2012-01-23 15:02       ` Konrad Rzeszutek Wilk
2012-01-19 20:49 ` Konrad Rzeszutek Wilk
2012-01-19 21:07   ` Keir Fraser
2012-01-19 21:12     ` Ian Campbell
2012-01-19 21:56       ` Keir Fraser
2012-01-20 10:12         ` Jan Beulich
2012-01-20 10:32           ` Keir Fraser

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).