WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

RE: [Xen-devel] Structure packing when using hypercall.

To: "Keir Fraser" <Keir.Fraser@xxxxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: RE: [Xen-devel] Structure packing when using hypercall.
From: "Roger Cruz" <rcruz@xxxxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 22 Oct 2007 17:55:28 -0400
Delivery-date: Mon, 22 Oct 2007 14:56:11 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <C342B910.F46F%Keir.Fraser@xxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: AcgU3OwgSW1bFsSFSXeroa5uYW2mJQAAjHKAAAC/JssABLvZEA==
Thread-topic: [Xen-devel] Structure packing when using hypercall.
Thanks Keir, but I didn't see anything in that file dealing specifically
with packing issues. Did I miss it? 

We found a couple of problems when we upgraded our hypervisor from 32 to
64-bits this weekend.

1) unsigned long, which is used to define xen_pfn_t is 32-bits in Linux
32 and Windows 32 and Windows 64 but in Linux 64, it is 64-bits.
Therefore, when we compile grant_table.h in Windows 64 and make the
grant_copy hypercall, the field alignment and size of the structure is
different and the hypervisor doesn't access the correct fields.

2) GCC x64 compiler appears to align some of the files to a 64-bit
boundary, where as a Windows 32 compilation would align them to the next
32-bit boundary.  Since we support both 32 and 64-bit Windows, we have
to make sure that the structures used to make the hypercall are
hand-tweaked to match the 64-bit hypervisor.

What I was looking for was public hypercall header files that would work
no matter what OS/compiler the guest application and the hypersor were
built with.  There doesn't appear to be any #pragma pack around the
grant_table.h header files that would force fields to some specific
alignment.

Thanks again.
Roger



-----Original Message-----
From: Keir Fraser [mailto:Keir.Fraser@xxxxxxxxxxxx] 
Sent: Monday, October 22, 2007 3:31 PM
To: Roger Cruz; xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: Re: [Xen-devel] Structure packing when using hypercall.

See arch/x86/hvm/hvm.c. Some 32-to-64 conversion gets done in there, as
a
wrapper around the core hypercall routines.

 -- Keir

On 22/10/07 20:14, "Roger Cruz" <rcruz@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:

> 
> I'm wondering how you resolve the issue of structure packing when an
> application that calls hypervisor functions (say, the grant table map
> reference hypercall that uses struct grant_entry) is compiled with a
> 32-bit compiler and the hypervisor is compiled with a 64-bit version.
> There is a discrepancy in the sizes and alignment of the fields within
> the structure, depending on which compiler is being used.
> 
> So, my problem arises that I have a 64-bit compiler and a 32-bit HVM
> guest making a hypercall using the public H header files.  Is there
some
> packing being done in other files or at compile time that I'm not
> seeing?
> 
> 
> struct grant_entry {
>     /* GTF_xxx: various type and flag information.  [XEN,GST] */
>     uint16_t flags;
>     /* The domain being granted foreign privileges. [GST] */
>     domid_t  domid;
>     /*
>      * GTF_permit_access: Frame that @domid is allowed to map and
> access. [GST]
>      * GTF_accept_transfer: Frame whose ownership transferred by
@domid.
> [XEN]
>      */
>     uint32_t frame;
> };
> typedef struct grant_entry grant_entry_t;
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxxxxxxxx
> http://lists.xensource.com/xen-devel



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel