[U-Boot] [PATCH V2 3/7] lcd: prevent unaligned memory access when displaying splash screen

Nikita Kiryanov
2013-01-29T14:34:50Z

Hi Wolfgang Denk,

On 01/29/2013 03:46 PM, Wolfgang Denk wrote:
> Dear Nikita Kiryanov,
>
> In message <1359463349-11649-4-git-send-email-nikita@compulab.co.il> you wrote:
>> When the bmp file is loaded to an address specified by the environment
>> variable "splashimage", its header members might be unaligned.
>> This happens because the bmp header starts with two byte-size fields followd by
>> mostly 32 bit fields, so when the address in splashimage is not equal to aligned
>> address plus/minus 2, the 32 bit members will be placed in unaligned addresses.
>> This results in a data abort on targets that cannot handle unaligned memory
>> accesses.
>
> I don;t understand your +/- 2 argument. When there are 32 bit fielkds
> in the header, these have to be 32 bit aligned, right?

Right. The problem stems from the structure of the bmp header, which
places the 32 bit fields at an offset of 2 from the load address.

From bmp_layout.h:
typedef struct bmp_header {
/* Header */
char signature[2]; <--- This is what's causing the offset
__u32 file_size;
__u32 reserved;
__u32 data_offset;
...
}

This means that in order for these 32 bit fields to be properly aligned
when you load the bmp into memory, it has to be placed with a +/- offset
relative to an aligned address to cancel the shift that
char signature[2] causes.

>
>> Check that the address is safe to use, and fix it if it's not.
>
> If you perform any such fixes (thus essentially not doing what the
> user asked for), you should at least print a warning message so the
> user gets aware of such issues.
>
> Also, you should add the video custodian on Cc: for such patches.
>
> [Done here].

Thanks, I'll do that in the future.

>
>
> Best regards,
>
> Wolfgang Denk
>

--
Regards,
Nikita.