qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v2] acpi-build: don't access unaligned addresses


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH v2] acpi-build: don't access unaligned addresses
Date: Wed, 12 Mar 2014 13:37:24 +0000

On 11 March 2014 12:29, Peter Maydell <address@hidden> wrote:
> On 10 March 2014 19:56, Michael S. Tsirkin <address@hidden> wrote:
>> casting an unaligned address to e.g.
>> uint32_t can trigger undefined behaviour in C.
>> Replace cast + assignment with memcpy.
>>
>> Reported-by: Peter Maydell <address@hidden>
>> Signed-off-by: Michael S. Tsirkin <address@hidden>
>
> This does fix the clang warnings.

I missed that there's still one more warning generated by a
different bit of this file:

/home/petmay01/linaro/qemu-for-merges/hw/i386/acpi-build.c:1022:5:
runtime error: store to misaligned address 0x2b5aa47dfb19 for type
'uint16_t' (aka 'unsigned short'), which requires 2 byte alignment
0x2b5aa47dfb19: note: pointer points here
 45 53 54  0b ff ff 5b 80 50 45 4f  52 01 50 45 53 54 01 5b  81 0b 50
45 4f 52 01 50  45 50 54 08 14
              ^

    *(uint16_t *)(ssdt_ptr + *ssdt_isa_pest) =
        cpu_to_le16(misc->pvpanic_port);

in build_ssdt(). You could change that to:
    stw_le_p(ssdt_ptr + *ssdt_isa_pest, misc->pvpanic_port);
(untested).

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]