iPXE does insert stub BLOCK IO protocol handler, it is unusable and the
access will result with error. We need to exclude it from the list of disks.
Details
- Reviewers
imp - Commits
- rS326421: loader.efi: efipart should exclude iPXE stub block protocol
Tested with iPXE boot.
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
Lint Passed - Unit
No Test Coverage - Build Status
Buildable 13207 Build 13448: arc lint + arc unit
Event Timeline
So basicaly LGTM, however two things to think about...
#define might be nice. but other than that it looks cool to me.
BlockSize is defined in the standard as:
The intrinsic block size of the device. ... Returns the number of bytes per logical block....
This suggests to me the proper filter is < 512, and maybe even a power of 2 test.
stand/efi/libefi/efipart.c | ||
---|---|---|
266 | Still think we should just replace this whole thing with: if (blkio->Media->BlockSize != 512 || blkio->Media->BlockSize != 4096) |
stand/efi/libefi/efipart.c | ||
---|---|---|
266 | This is not as simple as that. UEFI 2.7 does state about BlockSize: Now ATA IDENTIFY DEVICE: So from ATA, we have at least 256 bytes. and SCSI READ CAPACITY: For iPXE case I did confirm the stub (src/interface/efi/efi_file.c in ipxe source), they do implement FILE interface and to work around other issues, they indeed do insert the dummy block io into the stack, so this test is valid and does fix the issue. I am still a bit hesitant about validating the BlockSize for other values, and mostly because it may help to identify some weird issues if those should arise. |
stand/efi/libefi/efipart.c | ||
---|---|---|
266 | Does our code work with 256 sector size? No. I doubt it works for < 512 for various reasons (not least that we read a sector, then access data > 256 unconditionally). Just because an ATA might possibly be a weird number doesn't mean we should accept it here. We can't use it anyway, and I doubt there's been more than a half a dozen drives made with 256 byte sectors, all in the early days of ATA. I'm more inclined to filter all bogus values. If we know the code can't possibly work with odd-ball sector sizes, we should fail early and tell people they lose. If it's important, they'll let us know. It's been my experience in the past that the harder I tried to support oddball configurations, especially ones I could only lightly test, the result was rarely that the oddballs just worked and more often that the attempt interfered with normal device support. For better or worse, 512, 4k and soon 64k are the only sector sizes that we'll see in the wild. |
stand/efi/libefi/efipart.c | ||
---|---|---|
265 | I don't think this is a power of 2 test, but rather just an even / odd test. #define ispow2(x) ((x) != 0 && !((x) & ((x) - 1))) is the canonical one-liner... |
stand/efi/libefi/efipart.c | ||
---|---|---|
265 | #define powerof2(x) ((((x)-1)&(x))==0) can be found in sys/param.h and could be used. It falsely identifies 0 as a power of 2, but that's OK for this purpose. |
stand/efi/libefi/efipart.c | ||
---|---|---|
265 | indeed, I obviously was way too sleepy already:D |