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

Re: [Xen-devel] [PATCH] rombios: work around clang's -Waddress-of-packed-member



>>> On 24.08.18 at 17:22, <wei.liu2@xxxxxxxxxx> wrote:
> Building rombios with clang XXX fails with:
> 
> tcgbios.c:1519:34: error: taking address of packed member 'u' of class or 
> structure 'pushad_regs_t' may result in an unaligned pointer value 
> [-Werror,-Waddress-of-packed-member]
>                                               ®s->u.r32.edx);
>                                                ^~~~~~~~~~~~~~~
> 
> Work around that by using an intermediate variable.
> 
> Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
> ---
>  tools/firmware/rombios/32bit/tcgbios/tcgbios.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/firmware/rombios/32bit/tcgbios/tcgbios.c 
> b/tools/firmware/rombios/32bit/tcgbios/tcgbios.c
> index fa22c4460a..581340da8e 100644
> --- a/tools/firmware/rombios/32bit/tcgbios/tcgbios.c
> +++ b/tools/firmware/rombios/32bit/tcgbios/tcgbios.c
> @@ -1507,7 +1507,8 @@ uint32_t TCGInterruptHandler(pushad_regs_t *regs, 
> uint32_t esds,
>                             regs->u.r32.edx);
>               CLEAR_CF();
>               break;
> -     case 0x07:
> +     case 0x07: {
> +             uint32_t edx = regs->u.r32.edx;
>               regs->u.r32.eax =
>                 CompactHashLogExtendEvent32((unsigned char *)
>                                                 ADDR_FROM_SEG_OFF(ES,
> @@ -1516,9 +1517,11 @@ uint32_t TCGInterruptHandler(pushad_regs_t *regs, 
> uint32_t esds,
>                                             regs->u.r32.ebx,
>                                             regs->u.r32.ecx,
>                                             regs->u.r32.edx,
> -                                           &regs->u.r32.edx);
> +                                           &edx);
> +             regs->u.r32.edx = edx;
>               CLEAR_CF();
>               break;
> +     }

Hmm, this addresses a specific instance of the problem. In this (I think)
never changing code base doing so might be okay, but is there a reason
not to fix the root of the problem - remove the bogus packed attribute?
The structure definition in 32bit/rombios_compat.h spells out all padding
fields, and I can't spot any other (side) effect the attribute would have,
the more that it's only the outermost structure which gets the attribute
applied.

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®.