Bug 240572 - libefi: FreeBSD cannot boot with U-Boot patch efi_loader: parameter checks BLOCK_IO_PROTOCOL
Summary: libefi: FreeBSD cannot boot with U-Boot patch efi_loader: parameter checks BL...
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs mailing list
URL: https://reviews.freebsd.org/D21655
Keywords: needs-qa
Depends on:
Blocks:
 
Reported: 2019-09-13 21:54 UTC by Heinrich Schuchardt
Modified: 2019-09-19 20:55 UTC (History)
3 users (show)

See Also:
koobs: mfc-stable11?
koobs: mfc-stable12?


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Heinrich Schuchardt 2019-09-13 21:54:58 UTC
Booting current FreeBSD fails since patch
f59f0825e8b9fdeb8abe43ffd10c5119ca1a032f
efi_loader: parameter checks BLOCK_IO_PROTOCOL

The reason is that the buffer used by FreeBSD to read is not block aligned.

The UEFI spec requires that EFI_BLOCK_IO_PROTOCOL.ReadBlocks() returns
EFI_INVALID_PARAMETER if the buffer is not properly aligned (i.e. is not
a multiple of EFI_BLOCK_IO_MEDIA.IoAlign)

FreeBSD does not guarantee this alignment, e.g. efi_disk_read_blocks()
is called with buffer 00000000995b08d0 which is not aligned to a
multiple of 512.

FreeBSD function efipart_readwrite writes this error message:
efipart_readwrite: rw=1, blk=62333952 size=1 status=2

The problem can be traced back to the FreeBSD line:

stand/efi/libefi/efipart.c(1043) efipart_realstrategy():
blkbuf = malloc(blkio->Media->BlockSize);

U-Boot does not yet implement the EFI_DISK_IO_PROTOCOL which is a
wrapper for the EFI_BLOCK_IO_PROTOCOL allowing unaligned access.

malloc() could be replaced in FreeBSD by AllocatePages() which returns a
4096 byte aligned memory block.
Comment 1 Kyle Evans freebsd_committer 2019-09-14 02:22:54 UTC
I've opened this up: https://reviews.freebsd.org/D21655
Comment 2 Heinrich Schuchardt 2019-09-19 20:55:01 UTC
Commit 16ef880ce6ee ("loader.efi: efipart needs to use ioalign") was merged into FreeBSD on Sep 17th, 2019.