Skip to content
Commit a939aa56 authored by Mikulas Patocka's avatar Mikulas Patocka Committed by Kevin Brace
Browse files

mga_drv: fix image corruption due to memcpy reordering



The memcpy specification doesn't specify how the destination is written -
and on glibc 2.19 memcpy is doing some bytewise writes with the rep stosb
instruction. These bytewise writes confuse the hardware (because it
expects 32-bit writes) and result in image corruption.

This patch replaces memcpy with explicit writes, so that the sequential
write order and 32-bit write size is guaranteed. We use the "volatile"
attribute to make sure that compiler optimizations won't cause write
reordering. When reading the memory, we use a structure with "packed"
attribute to avoid unaligned traps on RISC machines.

Tested-by: default avatarKevin Brace <kevinbrace@gmx.com>
Signed-off-by: default avatarMikulas Patocka <mikulas@twibright.com>
parent 0f4883f0
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment