From: Ian Campbell Subject: Re: [PATCH] blkif: add indirect descriptors interface to public headers Date: Tue, 12 Nov 2013 14:54:20 +0000 Message-ID: <1384268060.10204.26.camel@kazak.uk.xensource.com> References: <1384252612-22573-1-git-send-email-roger.pau@citrix.com> <9AAE0902D5BC7E449B7C8E4E778ABCD017021D@AMSPEX01CL01.citrite.net> <20131112142254.GC9306@phenom.dumpdata.com> <1384266541.10204.14.camel@kazak.uk.xensource.com> <20131112144229.GA9435@phenom.dumpdata.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VgFMH-0003P6-6k for xen-devel@lists.xenproject.org; Tue, 12 Nov 2013 14:54:25 +0000 In-Reply-To: <20131112144229.GA9435@phenom.dumpdata.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Konrad Rzeszutek Wilk Cc: "xen-devel@lists.xenproject.org" , Paul Durrant , "Keir (Xen.org)" , Jan Beulich , Roger Pau Monne List-Id: xen-devel@lists.xenproject.org On Tue, 2013-11-12 at 09:42 -0500, Konrad Rzeszutek Wilk wrote: > On Tue, Nov 12, 2013 at 02:29:01PM +0000, Ian Campbell wrote: > > On Tue, 2013-11-12 at 09:22 -0500, Konrad Rzeszutek Wilk wrote: > > > > > > > +struct blkif_request_indirect { > > > > > + uint8_t operation; /* BLKIF_OP_INDIRECT */ > > > > > + uint8_t indirect_op; /* BLKIF_OP_{READ/WRITE} */ > > > > > + uint16_t nr_segments; /* number of segments */ > > > > > > > > This is going to be a problem. What alignment boundary are you > > > expecting the next field to start on? AFAIK 32-bit gcc will 4-byte > > > align it, 32-bit MSVC will 8-byte align it. > > > > > > > > > > Oh no. I thought that the Linux one had this set correctly, ah it did: > > > > > > > > > struct blkif_request_indirect { > > > [...] > > > } __attribute__((__packed__)); > > > > That attribute packed isn't allowed in the public interface headers. > > Right. I had hit that at some point with putting in a u64 and seeing > it mushroom up while if I did two u32 it padded it nicely. > > Perhaps that is what we should do? What you should do is make the struct declare something which matches the required ABI. I don't really care how it is achieved on the Linux side. > The Linux struct has the same size > whether it be 64-bit or 32-bit. > > > > > Since compilers do differ in their packing, and guests may be using > > various pragmas, it might be useful to write down that for x86 these > > headers are to be treated as using the ABI (gcc? Some Intel > > standard?). > > Or perhaps just mention the size of the structure and offset? You'd need to do that for every field of every struct. Which is really why documentation of struct layout ABIs exist... Ian.