From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoph Egger Subject: [PATCH][XEN] PV blk backend: Make 32bit PV guests work on 64bit PV Dom0 Date: Mon, 28 Jul 2008 13:46:01 +0200 Message-ID: <200807281346.01560.Christoph.Egger@amd.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Boundary-00=_5FbjIUvadr9FPbV" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --Boundary-00=_5FbjIUvadr9FPbV Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi, Attached patch makes the PV block driver for 32bit PV guests working on 64bit PV Dom0. In the io/blkif.h, the 'id' field of struct blkif_request is 64bit, but on a LP32 system it's aligned on=20 32bits, while it'll be aligned to 64bits on a LP64 system. So on LP64 there= 'll=20 be 4 bytes of padding between handle and id. The same is true for struct blkif_response: it's 11 bytes long, so will be aligned differently in the ring between a 32 and 64bit systems. In order to fix this, attached patch introduces in the public headers, blkif_request/blkif_response, blkif_x86_32_request/blkif_x86_32_response and blkif_x86_64_request/blkif_x86_64_response. NetBSD is doing so io/blkif.h in the public headers, while Linux does so in include/xen/blkif.h in the linux sources. But the result is the same ... Successfully tested with the combinations: 64bit Dom0 32bit PAE PV guest NetBSD Linux Linux NetBSD The combinations 64bit Dom0, 64bit PV DomU works with and without this patc= h. Signed-off-by: Christoph Egger =2D-=20 AMD Saxony, Dresden, Germany Operating System Research Center Legal Information: AMD Saxony Limited Liability Company & Co. KG Sitz (Gesch=E4ftsanschrift): Wilschdorfer Landstr. 101, 01109 Dresden, Deutschland Registergericht Dresden: HRA 4896 vertretungsberechtigter Komplement=E4r: AMD Saxony LLC (Sitz Wilmington, Delaware, USA) Gesch=E4ftsf=FChrer der AMD Saxony LLC: Dr. Hans-R. Deppe, Thomas McCoy --Boundary-00=_5FbjIUvadr9FPbV Content-Type: text/x-diff; charset="us-ascii"; name="public_blkif.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="public_blkif.diff" diff -r 37fae02cc335 xen/include/public/io/blkif.h --- a/xen/include/public/io/blkif.h Fri Jul 25 15:03:03 2008 +0100 +++ b/xen/include/public/io/blkif.h Mon Jul 28 11:02:12 2008 +0200 @@ -91,6 +91,8 @@ struct blkif_request_segment { uint8_t first_sect, last_sect; }; +/* native-type requests/responses (always used in frontends ) */ + struct blkif_request { uint8_t operation; /* BLKIF_OP_??? */ uint8_t nr_segments; /* number of segments */ @@ -108,6 +110,44 @@ struct blkif_response { }; typedef struct blkif_response blkif_response_t; +/* i386 requests/responses */ +struct blkif_x86_32_request { + uint8_t operation; /* BLKIF_OP_??? */ + uint8_t nr_segments; /* number of segments */ + blkif_vdev_t handle; /* only for read/write requests */ + uint64_t id; /* private guest value, echoed in resp */ + blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */ + struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST]; +} /* __packed */; +typedef struct blkif_x86_32_request blkif_x86_32_request_t; + +struct blkif_x86_32_response { + uint64_t id; /* copied from request */ + uint8_t operation; /* copied from request */ + uint8_t _pad; + int16_t status; /* BLKIF_RSP_??? */ +} /* __packed */; +typedef struct blkif_x86_32_response blkif_x86_32_response_t; + +/* amd64-type requests/responses (always used in frontends ) */ + +struct blkif_x86_64_request { + uint8_t operation; /* BLKIF_OP_??? */ + uint8_t nr_segments; /* number of segments */ + blkif_vdev_t handle; /* only for read/write requests */ + uint64_aligned_t id;/* private guest value, echoed in resp */ + blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */ + struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST]; +}; +typedef struct blkif_x86_64_request blkif_x86_64_request_t; + +struct blkif_x86_64_response { + uint64_aligned_t id; /* copied from request */ + uint8_t operation; /* copied from request */ + int16_t status; /* BLKIF_RSP_??? */ +}; +typedef struct blkif_x86_64_response blkif_x86_64_response_t; + /* * STATUS RETURN CODES. */ @@ -123,6 +163,15 @@ typedef struct blkif_response blkif_resp */ DEFINE_RING_TYPES(blkif, struct blkif_request, struct blkif_response); +DEFINE_RING_TYPES(blkif_x86_32, struct blkif_x86_32_request, struct blkif_x86_32_response); +DEFINE_RING_TYPES(blkif_x86_64, struct blkif_x86_64_request, struct blkif_x86_64_response); + +union blkif_back_ring_proto { + blkif_back_ring_t ring_n; /* native/common members */ + blkif_x86_32_back_ring_t ring_32; + blkif_x86_64_back_ring_t ring_64; +}; +typedef union blkif_back_ring_proto blkif_back_ring_proto_t; #define VDISK_CDROM 0x1 #define VDISK_REMOVABLE 0x2 --Boundary-00=_5FbjIUvadr9FPbV Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --Boundary-00=_5FbjIUvadr9FPbV--