[BUG] ext4: the load command on an EXT4 partitition leads to errors due to unaligned buffers

Heinrich Schuchardt xypron.glpk at gmx.de
Tue Jan 12 23:56:56 CET 2021


When reading a file using the load command from a FAT file system this
works fine irrespective of the alignment.

When reading from an EXT4 partition raw sectors are read to unaligned
addresses which leads to a failure to load the file

=> echo $kernel_addr_r
0x40080000

=> load mmc 0:3 $kernel_addr_r helloworld.efi 10a1 1
fs/fs_internal.c(76) fs_devread: partition->start 0x400000, sector 0x2,
block_len 0x400, log2blksz 0x9, buffer 0x00000000b9f8ea40
fs/fs_internal.c(76) fs_devread: partition->start 0x400000, sector
0x42031, block_len 0xe00, log2blksz 0x9, buffer 0x00000000400801ff
** fs_devread read error - block
Failed to load 'helloworld.efi'

The problem is in fs_devread() in the part marked as

/* Get the read to the beginning of a partition */

Here the wrong assumption is made that variable buf is cache-aligned
after advancing it by an odd number of bytes.

Valerij first observed the problem when trying to read the EXT4
partition why the EFI_FILE_PROTOCOL on a Pine64 system. I was able to
reproduce it on the Pine64 A64 LTS.

Best regards

Heinrich


More information about the U-Boot mailing list