From: Attilio Rao <attilio.rao@citrix.com>
To: xen-devel@lists.xen.org
Subject: Re: [PATCH 4/5] xen: Add V4V implementation
Date: Thu, 19 Jul 2012 10:54:58 +0100 [thread overview]
Message-ID: <5007D972.7050308@citrix.com> (raw)
In-Reply-To: <CAEBdQ91aztES9raLGcfNJ+Jca-pgBnhY6rH9DsNnHAkHd8GuPg@mail.gmail.com>
On 19/07/12 10:58, Jean Guyader wrote:
> On 19 July 2012 10:34, Andrew Cooper<andrew.cooper3@citrix.com> wrote:
>
>> On 18/07/12 21:09, Jean Guyader wrote:
>>
>>> On 29 June 2012 11:36, Jan Beulich<JBeulich@suse.com> wrote:
>>>
>>>>>>> On 29.06.12 at 12:03, Jean Guyader<jean.guyader@gmail.com> wrote:
>>>>>>>
>>>>> On 29 June 2012 09:33, Jan Beulich<JBeulich@suse.com> wrote:
>>>>>
>>>>>>>>> On 28.06.12 at 18:26, Jean Guyader<jean.guyader@citrix.com> wrote:
>>>>>>>>>
>>>>>>> +typedef struct v4v_ring_id
>>>>>>> +{
>>>>>>> + struct v4v_addr addr;
>>>>>>> + domid_t partner;
>>>>>>> +} V4V_PACKED v4v_ring_id_t;
>>>>>>> +
>>>>>>>
>>>>> This structure is really the one that cause trouble. domid_t is 16b
>>>>> and v4v_addr_t is used
>>>>> inside v4v_ring_t. I would like the structure to remind as close as we
>>>>> can from the original version
>>>>> as we already versions in the field. Having explicit padding will make
>>>>> all the structures different
>>>>> which will make much harder to write a driver that will support the
>>>>> two versions of the API.
>>>>>
>>>> Oh, I see, "partner" would end up on a different offset if the
>>>> packed attribute was removed from v4v_addr_t. But that
>>>> could still be solved by making this type a union:
>>>>
>>>> typedef union v4v_ring_id
>>>> {
>>>> struct v4v_addr addr;
>>>> struct {
>>>> uint32_t port;
>>>> domid_t domain;
>>>> domid_t partner;
>>>> } full;
>>>> } v4v_ring_id_t;
>>>>
>>>> That would guarantee binary compatibility. And you could even
>>>> achieve source compatibility for gcc users by making the naming
>>>> of the second structure conditional upon __GNUC__ being
>>>> undefined (or adding a second instance of the same, just
>>>> unnamed structure within a respective #ifdef - that would make
>>>> it possible to write code that can be compiled by both gcc and
>>>> non-gcc, yet existing gcc-only code would need changing).
>>>>
>>>>
>>>>> Also most all the consumer of those headers will have to rewrite the
>>>>> structure anyway, for instance
>>>>> the Linux kernel have it's own naming convention, macros definitions
>>>>> which are different, etc..
>>>>>
>>>> Such can usually be done via scripts, so having a fully defined
>>>> public header is still worthwhile.
>>>>
>>>>
>>> Hi,
>>>
>>> I've been working on this and it work for most of it apart from one case.
>>> Let's take this structure:
>>>
>>> struct a
>>> {
>>> uint64_t a;
>>> uint32_t b;
>>>
>> uint32_t _pad0;
>>
>>> uint16_t c;
>>> uint16_t d;
>>> uint32_t e;
>>> uint32_t f;
>>> uint32_t g;
>>> uint8_t h[32];
>>> uint8_t q[0];
>>> };
>>>
>> Manually padding so the alignment is the same on 32 and 64 bit is the
>> only way to do this in the public headers, which cant have gcc'isms for
>> compatibility reasons with other compilers.
>>
>>
> The problem isn't with the individual fields (they are all correctly
> aligned) it is
> the the overall structure size which is 64 even so offset of q is 60
> (and sizeof q
> should be 0).
>
> I think there is no way around it. The structure I have should be
> aligned on 64b anyway.
>
>
Can you use gcc __attribute__((aligned(64))) for this? Or we try to
avoid gcc-ism at all?
Attilio
next prev parent reply other threads:[~2012-07-19 9:54 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-28 16:26 [PATCH 0/5] RFC: V4V (v2) Jean Guyader
2012-06-28 16:26 ` [PATCH 1/5] xen: add ssize_t Jean Guyader
2012-06-29 8:05 ` Jan Beulich
2012-06-29 10:09 ` Jean Guyader
2012-06-29 10:38 ` Jan Beulich
2012-06-28 16:26 ` [PATCH 2/5] v4v: Introduce VIRQ_V4V Jean Guyader
2012-06-29 8:07 ` Jan Beulich
2012-06-29 10:33 ` Jean Guyader
2012-06-28 16:26 ` [PATCH 3/5] xen: Enforce introduce guest_handle_for_field Jean Guyader
2012-06-29 8:10 ` Jan Beulich
2012-06-28 16:26 ` [PATCH 4/5] xen: Add V4V implementation Jean Guyader
2012-06-29 8:33 ` Jan Beulich
2012-06-29 10:03 ` Jean Guyader
2012-06-29 10:36 ` Jan Beulich
2012-07-18 20:09 ` Jean Guyader
2012-07-19 9:34 ` Andrew Cooper
2012-07-19 9:58 ` Jean Guyader
2012-07-19 9:54 ` Attilio Rao [this message]
2012-07-19 10:06 ` Jean Guyader
2012-07-19 10:04 ` Attilio Rao
2012-07-19 10:32 ` Ian Campbell
2012-07-19 10:42 ` Andrew Cooper
2012-07-19 11:33 ` Stefano Stabellini
2012-07-19 11:40 ` Andrew Cooper
2012-07-19 11:58 ` Jean Guyader
2012-07-23 8:18 ` Jan Beulich
2012-07-05 11:36 ` Tim Deegan
2012-06-28 16:26 ` [PATCH 5/5] v4v: Introduce basic access control to V4V Jean Guyader
2012-07-05 14:23 ` Tim Deegan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5007D972.7050308@citrix.com \
--to=attilio.rao@citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).