grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: Andrei Borzenkov <arvidjaar@gmail.com>
To: The development of GNU GRUB <grub-devel@gnu.org>,
	jamin.collins@gmail.com
Subject: Re: [PATCH] disk/efi: skip iPXE dummy block devices
Date: Tue, 14 Mar 2017 06:19:04 +0300	[thread overview]
Message-ID: <257751b4-373c-a151-8685-b33b3eb2215a@gmail.com> (raw)
In-Reply-To: <20170314030307.GA27844@linux-9gqx.suse.de>

14.03.2017 06:03, Michael Chang пишет:
> On Mon, Mar 13, 2017 at 06:45:02AM +0300, Andrei Borzenkov wrote:
>> 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(+)
>>
>> diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c
>> index 3b79f7b..47a4e99 100644
>> --- a/grub-core/disk/efi/efidisk.c
>> +++ b/grub-core/disk/efi/efidisk.c
>> @@ -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. 
> 

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,
};


> Thanks,
> Michael
> 
>> +	  bio->media->block_size == 1)
>> +	  continue;
>> +
>>        d = grub_malloc (sizeof (*d));
>>        if (! d)
>>  	{
>> -- 
>> tg: (bcf3c55..) bug/50518 (depends on: master)
>>
>> _______________________________________________
>> Grub-devel mailing list
>> Grub-devel@gnu.org
>> https://lists.gnu.org/mailman/listinfo/grub-devel
> 
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
> 



  reply	other threads:[~2017-03-14  3:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-13  3:45 [PATCH] disk/efi: skip iPXE dummy block devices Andrei Borzenkov
2017-03-14  3:03 ` Michael Chang
2017-03-14  3:19   ` Andrei Borzenkov [this message]
2017-03-14  4:57     ` Michael Chang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=257751b4-373c-a151-8685-b33b3eb2215a@gmail.com \
    --to=arvidjaar@gmail.com \
    --cc=grub-devel@gnu.org \
    --cc=jamin.collins@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).