disk/efi: skip iPXE dummy block devices
PATCH 1/1 disk/efi: skip iPXE dummy block devices
iPXE adds Simple File System Protocol to loaded image handle, as side effect it also adds Block IO protocol (according to comments, to work around some bugs in EDK2). GRUB assumes that every device with Block IO is disk and skips network initialization entirely. But iPXE Block IO implementation is just a stub which always fails for every operation so cannot be used. Attempt to detect and skip such devices.
We are using media ID which iPXE sets to "iPXE" and block IO size in hope that no real device would announce 1B block ...
@Vladimir, @Daniel - this is probably 2.02 material. We cannot use any device that advertises block size less than 512B anyway, so it should not cause regression for disk boot.
It is my fault, I have seen it earlier but was busy with another problem so just worked around it to continue testing.
--- grub-core/disk/efi/efidisk.c | 9 +++++++++ 1 file changed, 9 insertions(+)
grub-core/disk/efi/efidisk.c +9 -0
@@ -80,6 +80,15 @@ make_devices (void)/* This should not happen... Why? */ continue ; +/* iPXE adds stub Block IO protocol to loaded image device handle. It is +completely non-functional and simply returns an error for every method. +So attempt to detect and skip it. Magic number is literal "iPXE" and +check block size as well */ +/* FIXME: shoud we close it? We do not do it elsewhere */ +if (bio->media && bio->media->media_id ==0x69505845U && + bio->media->block_size ==1 ) +continue ; + d =grub_malloc (sizeof (*d));if (! d) {
Signature · 1 line
tg: (bcf3c55..) bug/50518 (depends on: master)
Quoted 28 lines · Andrei Borzenkov
iPXE adds Simple File System Protocol to loaded image handle, as side effect it also adds Block IO protocol (according to comments, to work around some bugs in EDK2). GRUB assumes that every device with Block IO is disk and skips network initialization entirely. But iPXE Block IO implementation is just a stub which always fails for every operation so cannot be used. Attempt to detect and skip such devices.
We are using media ID which iPXE sets to "iPXE" and block IO size in hope that no real device would announce 1B block ...
Closes 50518@Vladimir, @Daniel - this is probably 2.02 material. We cannot use any device that advertises block size less than 512B anyway, so it should not cause regression for disk boot.
It is my fault, I have seen it earlier but was busy with another problem so just worked around it to continue testing.
--- grub-core/disk/efi/efidisk.c | 9 +++++++++ 1 file changed, 9 insertions(+)grub-core/disk/efi/efidisk.c +0
-0
grub-core/disk/efi/efidisk.c make_devices (void) · line 88
Quoted 9 lines
grub-core/disk/efi/efidisk.c +6
-0@@ -80,6 +80,15 @@ make_devices (void)/* This should not happen... Why? */ continue ; +/* iPXE adds stub Block IO protocol to loaded image device handle. It is +completely non-functional and simply returns an error for every method. +So attempt to detect and skip it. Magic number is literal "iPXE" and +check block size as well */ +/* FIXME: shoud we close it? We do not do it elsewhere */ + if (bio->media && bio->media->media_id == 0x69505845U &&
It seems that BE to LE conversion is required here as it tests for 'EXPi' on LE systems.
Thanks,
Michael
Quoted 13 lines
grub-core/disk/efi/efidisk.c +3
-0+ bio->media->block_size == 1) +continue ; + d =grub_malloc (sizeof (*d));if (! d) {Signature · 6 lines
tg: (bcf3c55..) bug/50518 (depends on: master) _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
14.03.2017 06:03, Michael Chang пишет:
Quoted 32 lines · Andrei Borzenkov
Quoted 31 lines
iPXE adds Simple File System Protocol to loaded image handle, as side effect it also adds Block IO protocol (according to comments, to work around some bugs in EDK2). GRUB assumes that every device with Block IO is disk and skips network initialization entirely. But iPXE Block IO implementation is just a stub which always fails for every operation so cannot be used. Attempt to detect and skip such devices.
We are using media ID which iPXE sets to "iPXE" and block IO size in hope that no real device would announce 1B block ...
Closes 50518@Vladimir, @Daniel - this is probably 2.02 material. We cannot use any device that advertises block size less than 512B anyway, so it should not cause regression for disk boot.
It is my fault, I have seen it earlier but was busy with another problem so just worked around it to continue testing.
--- grub-core/disk/efi/efidisk.c | 9 +++++++++ 1 file changed, 9 insertions(+)grub-core/disk/efi/efidisk.c +0
-0@@ -80,6 +80,15 @@ make_devices (void)/* This should not happen... Why? */ continue ;
Quoted 10 lines
grub-core/disk/efi/efidisk.c make_devices (void) · line 88
Quoted 6 lines
grub-core/disk/efi/efidisk.c +6
-0+/* iPXE adds stub Block IO protocol to loaded image device handle. It is +completely non-functional and simply returns an error for every method. +So attempt to detect and skip it. Magic number is literal "iPXE" and +check block size as well */ +/* FIXME: shoud we close it? We do not do it elsewhere */ + if (bio->media && bio->media->media_id == 0x69505845U &&It seems that BE to LE conversion is required here as it tests for 'EXPi' on LE systems.
iPXE sets it to this literal number:
#define EFI_MEDIA_ID_MAGIC 0x69505845
/** Dummy block I/O media */
static EFI_BLOCK_IO_MEDIA efi_block_io_media = {
.MediaId = EFI_MEDIA_ID_MAGIC,
.MediaPresent = TRUE,
.ReadOnly = TRUE,
.BlockSize = 1,
};
Quoted 22 lines
Thanks,
MichaelQuoted 13 lines
grub-core/disk/efi/efidisk.c +3
-0+ bio->media->block_size == 1) +continue ; + d =grub_malloc (sizeof (*d));if (! d) {Signature · 6 lines
tg: (bcf3c55..) bug/50518 (depends on: master) _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 44 lines · Andrei Borzenkov
14.03.2017 06:03, Michael Chang пишет:
Quoted 32 lines · Andrei Borzenkov
Quoted 31 lines
iPXE adds Simple File System Protocol to loaded image handle, as side effect it also adds Block IO protocol (according to comments, to work around some bugs in EDK2). GRUB assumes that every device with Block IO is disk and skips network initialization entirely. But iPXE Block IO implementation is just a stub which always fails for every operation so cannot be used. Attempt to detect and skip such devices.
We are using media ID which iPXE sets to "iPXE" and block IO size in hope that no real device would announce 1B block ...
Closes 50518@Vladimir, @Daniel - this is probably 2.02 material. We cannot use any device that advertises block size less than 512B anyway, so it should not cause regression for disk boot.
It is my fault, I have seen it earlier but was busy with another problem so just worked around it to continue testing.
--- grub-core/disk/efi/efidisk.c | 9 +++++++++ 1 file changed, 9 insertions(+)grub-core/disk/efi/efidisk.c +0
-0@@ -80,6 +80,15 @@ make_devices (void)/* This should not happen... Why? */ continue ;Quoted 10 lines
grub-core/disk/efi/efidisk.c make_devices (void) · line 88
Quoted 6 lines
grub-core/disk/efi/efidisk.c +6
-0+/* iPXE adds stub Block IO protocol to loaded image device handle. It is +completely non-functional and simply returns an error for every method. +So attempt to detect and skip it. Magic number is literal "iPXE" and +check block size as well */ +/* FIXME: shoud we close it? We do not do it elsewhere */ + if (bio->media && bio->media->media_id == 0x69505845U &&It seems that BE to LE conversion is required here as it tests for 'EXPi' on LE systems.
Quoted 1 line
iPXE sets it to this literal number:
Well. The comment said magic number is literal "iPXE" so that's what I am confused.
Thanks,
Michael
Quoted 40 lines
#define
EFI_MEDIA_ID_MAGIC0x69505845/** Dummy block I/O media */
staticEFI_BLOCK_IO_MEDIAefi_block_io_media= {
.MediaId =EFI_MEDIA_ID_MAGIC,
.MediaPresent = TRUE,
.ReadOnly = TRUE,
.BlockSize = 1,
};Quoted 12 lines
Thanks,
MichaelQuoted 9 lines
grub-core/disk/efi/efidisk.c +3
-0+ bio->media->block_size == 1) +continue ; + d =grub_malloc (sizeof (*d));if (! d) {Signature · 1 line
tg: (bcf3c55..) bug/50518 (depends on: master)Quoted 10 lines
Quoted 4 lines
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel