[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] trace: fix build with gcc9



>>> On 07.03.19 at 12:40, <andrew.cooper3@xxxxxxxxxx> wrote:
> On 07/03/2019 10:34, Jan Beulich wrote:
>> While I've not observed this myself, gcc 9 (imo validly) reportedly may
>> complain
>>
>> trace.c: In function '__trace_hypercall':
>> trace.c:826:19: error: taking address of packed member of 'struct 
>> <anonymous>' may result in an unaligned pointer value
>> [-Werror=address-of-packed-member]
>>   826 |     uint32_t *a = d.args;
>>
>> and the fix is rather simple - remove the __packed attribute. Introduce
>> a BUILD_BUG_ON() as replacement, for the unlikely case that Xen might
>> get ported to an architecture where array alignment higher that that of
>> its elements.
> 
> I really don't think the BUILD_BUG_ON() is helpful.
> 
> Such a theoretical architecture will almost certainly have a compiler
> that spots the misalignment, or will take a trap the first time xentrace
> is ever used.

With the __packed gone there's no misalignment to spot. Such a
compiler would insert a padding field instead. There would also be no
trap, the trace data consumer simply would take 32 bits of garbage
for actual data.

Jan



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.