On Thu, 11 May 2017 23:45:17 +0200
Michele Curti <michele.cu...@gmail.com> wrote:
> On Wed, May 10, 2017 at 08:35:28PM +0200, Patrick Wildt wrote:
>> 
>> I don't think this is the correct fix.  It might solve your issue, but I
>> don't think it's completely right.  So EFI has those so called device
>> paths.  A path is basically a list of nodes.  To compare two paths you
>> need to compare the whole path and not just a single node of it.  If you
>> store dp instead of dp0 you will basically only save a part of the path,
>> not the full path.
>> 
>> What you can do is print the full path of efi_bootdp like..
>> 
>>     for (dp = efi_bootdp; !IsDevicePathEnd(dp);
>>         dp = NextDevicePathNode(dp)) {
>>             printf("%x %x - ", DevicePathType(dp), DevicePathSubType(dp));
>>     }
>>     printf("\n");
>> 
>> And do the same for the DPs that are being put into the
>> efi_device_path_cmp function.  That will at least print the types, but
>> not the content of the nodes.  That's a start into figuring out why it
>> does not correctly compare the paths.
>> 
>> Maybe there's a bug in the compare code?
> 
> Sorry, only now I understood what you said... Got
> 
> 2 1 - 1 1 - 1 5 - 4 1 -
> 
> (2 1) (2 1) da db cmp da db cmp diff bootdev 1
> (2 1) (2 1) da db cmp da db cmp diff bootdev 1
> (2 1) (2 1) da db cmp da db cmp diff bootdev 1
> 
> with the following diff

All disks are identical in HARDWARE_DEVICE_PATH and ACPI_DEVICE_PATH
and they all don't have MESSAGING_DEVICE_PATH.  So the boot loader
mistakenly treats all of them as the bootdisk..

I'd like to know whether there is a way to distigish those disks.  Can
you try the diff following?

diff --git a/sys/arch/amd64/stand/efiboot/efiboot.c 
b/sys/arch/amd64/stand/efiboot/efiboot.c
index efa371f2ecd..891b6c75cc9 100644
--- a/sys/arch/amd64/stand/efiboot/efiboot.c
+++ b/sys/arch/amd64/stand/efiboot/efiboot.c
@@ -208,6 +208,14 @@ next:
                        TAILQ_INSERT_HEAD(&efi_disklist, di, list);
                else
                        TAILQ_INSERT_TAIL(&efi_disklist, di, list);
+
+               printf("%d\n", i);
+               for (; !IsDevicePathEnd(dp); dp = NextDevicePathNode(dp)) {
+                       int ii;
+                       for (ii = 0; ii < DevicePathNodeLength(dp); ii++)
+                               printf("%x ", *((u_char *)dp + ii));
+                       printf("\n");
+               }
        }
 
        free(handles, sz);

Reply via email to