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

[Xen-devel] [PATCH] xenalyze: use packed structs with u64 members

To: George Dunlap <George.Dunlap@xxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] xenalyze: use packed structs with u64 members
From: Olaf Hering <olaf@xxxxxxxxx>
Date: Tue, 14 Dec 2010 18:46:20 +0100
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Tue, 14 Dec 2010 09:55:30 -0800
Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; t=1292348786; l=1926; s=domk; d=aepfle.de; h=Content-Type:MIME-Version:Subject:Cc:To:From:Date:X-RZG-CLASS-ID: X-RZG-AUTH; bh=cpIjce/uIUYBRMKQxRs640x/0W0=; b=uDxaI6OxQf4h+DGx+bT4c7s9F1OBr8lNFWhL7Qkd1iacVlx3b0P7tP9Ztz3cbpfmyrk tf77n53Kxo4WFu/aWOlJG02vq4aUOtxK98tkE/ud0zsfGubmWKxbRWpz3pnUU9axRI6RS 6ndh/l91fbGYipzH+hs8VmhBagiNw/jxwx0=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.20 (2009-06-14)
George,

there is some padding after the first struct member if it is followed by
an unsigned long long. This happens with 64bit builds.
Adding an attribute to this struct fixes the size checks in
hvm_msr_write_process() for me. There are a few more places where the
padding will break things. This explains also the unexpected rip values.

Signed-off-by: Olaf Hering <olaf@xxxxxxxxx>

--- xenalyze.hg.orig/xenalyze.c
+++ xenalyze.hg/xenalyze.c
@@ -4138,7 +4138,7 @@ void hvm_cr_write_process(struct record_
         struct {
             unsigned cr;
             unsigned long long val;
-        } x64;
+        } __attribute__((packed)) x64;
     } *r = (typeof(r))h->d;
     unsigned cr;
     unsigned long long val;
@@ -4204,7 +4204,7 @@ void hvm_msr_write_process(struct record
     struct {
         unsigned int addr;
         unsigned long long val;
-    } *r = (typeof(r))h->d;
+    } __attribute__((packed)) *r = (typeof(r))h->d;
 
     int expected_extra=(sizeof(*r)/sizeof(unsigned int));
 
@@ -4256,7 +4256,7 @@ void hvm_msr_read_process(struct record_
     struct {
         unsigned int addr;
         unsigned long long val;
-    } *r = (typeof(r))h->d;
+    } __attribute__((packed)) *r = (typeof(r))h->d;
 
     int expected_extra=(sizeof(*r)/sizeof(unsigned int));
 
@@ -4499,7 +4499,7 @@ void hvm_pf_inject_process(struct record
         struct {
             unsigned ec;
             unsigned long long cr2;
-        } x64;
+        } __attribute__((packed)) x64;
     } *r = (typeof(r))h->d;
     unsigned int ec;
     unsigned long long cr2;
@@ -4945,7 +4945,7 @@ void hvm_vmexit_process(struct record_in
             struct {
                 unsigned int exit_reason;
                 unsigned long long rip;
-            } x64;
+            } __attribute__((packed)) x64;
             struct {
                 unsigned int exit_reason;
                 unsigned int eip;
@@ -6788,7 +6788,7 @@ void sched_runstate_process(struct pcpu_
     struct {
         unsigned vcpu:16, dom:16;
         unsigned long long p1, p2;
-    } * r = (typeof(r))ri->d;
+    } __attribute__((packed)) * r = (typeof(r))ri->d;
     union {
         unsigned int event;
         struct {

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

<Prev in Thread] Current Thread [Next in Thread>