]> git.ipfire.org Git - thirdparty/systemd.git/commit
boot: use EFI_DISK_IO_PROTOCOL instead of EFI_BLOCK_IO_PROTOCOL for disk reads
authorDaan De Meyer <daan@amutable.com>
Mon, 30 Mar 2026 18:59:09 +0000 (18:59 +0000)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Sat, 4 Apr 2026 18:03:44 +0000 (20:03 +0200)
commit4e5c605d4b3e29c42c4838ef7181e4db7bc28542
tree0eb44e7a636debb131cacef07bb7f10bf31d6533
parent0245bf7d7e32db6539faa3fcb7d7c6106860cd08
boot: use EFI_DISK_IO_PROTOCOL instead of EFI_BLOCK_IO_PROTOCOL for disk reads

EFI_DISK_IO_PROTOCOL (UEFI spec section 13.7,
https://uefi.org/specs/UEFI/2.10/13_Protocols_Media_Access.html#disk-i-o-protocol)
supports reads at arbitrary byte offsets with no alignment requirements on the
buffer. The UEFI spec mandates that firmware produces this protocol on every
handle that also has EFI_BLOCK_IO_PROTOCOL, so it is always available.

This is a better fit than EFI_BLOCK_IO_PROTOCOL for our GPT parsing and
BitLocker detection because Block I/O requires that both the read offset (LBA)
and the buffer are aligned to the media's IoAlign value. Meeting that
constraint forces us to use xmalloc_aligned_pages() with
PHYSICAL_ADDRESS_TO_POINTER(), page-granularity allocations, and manual size
rounding (ALIGN_TO). Disk I/O handles all of that internally, so callers can
use plain xmalloc() or even stack buffers and read exactly the number of bytes
they need.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
src/boot/boot.c
src/boot/part-discovery.c
src/boot/proto/disk-io.h [new file with mode: 0644]