grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Skip Apple ghosts
@ 2013-12-24 13:26 Vladimir 'φ-coder/phcoder' Serbinenko
  2013-12-24 16:44 ` Andrey Borzenkov
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2013-12-24 13:26 UTC (permalink / raw)
  To: The development of GRUB 2


[-- Attachment #1.1: Type: text/plain, Size: 699 bytes --]

Hello, all. It was discovered that on macs sometimes firmware defines
ghost disks with vendor suffix. E.g.
/ACPI(a0341d0,0)/PCI(2,1f)/UnknownMessaging(12)/EndEntire
is a normal disks with partitions presented with HD(...) but then
/ACPI(a0341d0,0)/PCI(2,1f)/UnknownMessaging(12)/MediaVendor(Apple)[0:
]/EndEntire
is a ghost disk. It has as suffix a vendor path with empty vendor data.
This is a problem because when chainloading on such disks GRUB can't
find handle of partition as none is defined. I propose to dkip ghosts
completely. This should be safe as the skip happens only for empty Apple
vendor suffix and if the parent is already a known disk.
Did anyone see anything similar?

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: appledisk.diff --]
[-- Type: text/x-diff; name="appledisk.diff", Size: 1035 bytes --]

diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c
index e04203f..3b12c34 100644
--- a/grub-core/disk/efi/efidisk.c
+++ b/grub-core/disk/efi/efidisk.c
@@ -333,6 +333,21 @@ name_devices (struct grub_efidisk_data *devices)
       if (! dp)
 	continue;
 
+      /* Ghosts proudly presented by Apple.  */
+      if (GRUB_EFI_DEVICE_PATH_TYPE (dp) == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE
+	  && GRUB_EFI_DEVICE_PATH_SUBTYPE (dp)
+	  == GRUB_EFI_VENDOR_MEDIA_DEVICE_PATH_SUBTYPE)
+	{
+	  grub_efi_vendor_device_path_t *vendor = (grub_efi_vendor_device_path_t *) dp;
+	  const struct grub_efi_guid apple = GRUB_EFI_VENDOR_APPLE_GUID;
+
+	  if (vendor->header.length == sizeof (*vendor)
+	      && grub_memcmp (&vendor->vendor_guid, &apple,
+			      sizeof (vendor->vendor_guid)) == 0
+	      && find_parent_device (devices, d))
+	    continue;
+	}
+
       m = d->block_io->media;
       if (GRUB_EFI_DEVICE_PATH_TYPE (dp) == GRUB_EFI_ACPI_DEVICE_PATH_TYPE
 	  && GRUB_EFI_DEVICE_PATH_SUBTYPE (dp)

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 291 bytes --]

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Skip Apple ghosts
  2013-12-24 13:26 [PATCH] Skip Apple ghosts Vladimir 'φ-coder/phcoder' Serbinenko
@ 2013-12-24 16:44 ` Andrey Borzenkov
  2013-12-24 17:00   ` Vladimir 'φ-coder/phcoder' Serbinenko
  2014-01-07 18:17 ` Andrey Borzenkov
  2014-01-07 18:20 ` Andrey Borzenkov
  2 siblings, 1 reply; 5+ messages in thread
From: Andrey Borzenkov @ 2013-12-24 16:44 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 1627 bytes --]

В Вт, 24/12/2013 в 14:26 +0100, Vladimir 'φ-coder/phcoder' Serbinenko
пишет:
> Hello, all. It was discovered that on macs sometimes firmware defines
> ghost disks with vendor suffix. E.g.
> /ACPI(a0341d0,0)/PCI(2,1f)/UnknownMessaging(12)/EndEntire
> is a normal disks with partitions presented with HD(...) but then
> /ACPI(a0341d0,0)/PCI(2,1f)/UnknownMessaging(12)/MediaVendor(Apple)[0:
> ]/EndEntire
> is a ghost disk. It has as suffix a vendor path with empty vendor data.

Messaging subtype 12 is IPv4 Device Path. I suppose it is related to
NetBoot.

> This is a problem because when chainloading on such disks GRUB can't
> find handle of partition as none is defined. I propose to dkip ghosts
> completely. This should be safe as the skip happens only for empty Apple
> vendor suffix and if the parent is already a known disk.

Hmm ... should not we simply ignore all unknown media types? They can be
added on case by case basis I guess.

diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c
index e04203f..6dfdb0d 100644
--- a/grub-core/disk/efi/efidisk.c
+++ b/grub-core/disk/efi/efidisk.c
@@ -310,6 +310,7 @@ name_devices (struct grub_efidisk_data *devices)
              grub_efi_print_device_path (d->device_path);
 #endif
              /* For now, ignore the others.  */
+             d->last_device_path = 0;
              break;
            }
        }


> Did anyone see anything similar?
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Skip Apple ghosts
  2013-12-24 16:44 ` Andrey Borzenkov
@ 2013-12-24 17:00   ` Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 0 replies; 5+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2013-12-24 17:00 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 2090 bytes --]

On 24.12.2013 17:44, Andrey Borzenkov wrote:
> В Вт, 24/12/2013 в 14:26 +0100, Vladimir 'φ-coder/phcoder' Serbinenko
> пишет:
>> Hello, all. It was discovered that on macs sometimes firmware defines
>> ghost disks with vendor suffix. E.g.
>> /ACPI(a0341d0,0)/PCI(2,1f)/UnknownMessaging(12)/EndEntire
>> is a normal disks with partitions presented with HD(...) but then
>> /ACPI(a0341d0,0)/PCI(2,1f)/UnknownMessaging(12)/MediaVendor(Apple)[0:
>> ]/EndEntire
>> is a ghost disk. It has as suffix a vendor path with empty vendor data.
> 
> Messaging subtype 12 is IPv4 Device Path. I suppose it is related to
> NetBoot.
It's hex. 0x12 is SATA.
> 
>> This is a problem because when chainloading on such disks GRUB can't
>> find handle of partition as none is defined. I propose to dkip ghosts
>> completely. This should be safe as the skip happens only for empty Apple
>> vendor suffix and if the parent is already a known disk.
> 
> Hmm ... should not we simply ignore all unknown media types? They can be
> added on case by case basis I guess.
> 
Too much breakage potential. And I don't have accessto check it on loads
of different buggy EFI systems and even if I did, it would be a waste of
time.
> diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c
> index e04203f..6dfdb0d 100644
> --- a/grub-core/disk/efi/efidisk.c
> +++ b/grub-core/disk/efi/efidisk.c
> @@ -310,6 +310,7 @@ name_devices (struct grub_efidisk_data *devices)
>               grub_efi_print_device_path (d->device_path);
>  #endif
>               /* For now, ignore the others.  */
> +             d->last_device_path = 0;
>               break;
>             }
>         }
> 
> 
>> Did anyone see anything similar?
>> _______________________________________________
>> 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
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 291 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Skip Apple ghosts
  2013-12-24 13:26 [PATCH] Skip Apple ghosts Vladimir 'φ-coder/phcoder' Serbinenko
  2013-12-24 16:44 ` Andrey Borzenkov
@ 2014-01-07 18:17 ` Andrey Borzenkov
  2014-01-07 18:20 ` Andrey Borzenkov
  2 siblings, 0 replies; 5+ messages in thread
From: Andrey Borzenkov @ 2014-01-07 18:17 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 2136 bytes --]

В Вт, 24/12/2013 в 14:26 +0100, Vladimir 'φ-coder/phcoder' Serbinenko
пишет:
> Hello, all. It was discovered that on macs sometimes firmware defines
> ghost disks with vendor suffix. E.g.
> /ACPI(a0341d0,0)/PCI(2,1f)/UnknownMessaging(12)/EndEntire
> is a normal disks with partitions presented with HD(...) but then
> /ACPI(a0341d0,0)/PCI(2,1f)/UnknownMessaging(12)/MediaVendor(Apple)[0:
> ]/EndEntire
> is a ghost disk. It has as suffix a vendor path with empty vendor data.
> This is a problem because when chainloading on such disks GRUB can't
> find handle of partition as none is defined. I propose to dkip ghosts
> completely. This should be safe as the skip happens only for empty Apple
> vendor suffix and if the parent is already a known disk.
> Did anyone see anything similar?

Yes (on MacBook Pro); 

Here is what I get when EFI-booting from GRUB rescue CD made with single
x86_64-efi target:

/ACPI(a0341d0,0)/PCI(1,1f)/ATAPI(0,0,0)/EndEntire
disk
block
/ACPI(a0341d0,0)/PCI(1,1f)/ATAPI(0,0,0)/MediaVendor(2b0585eb-d8b8-49a9-8b8c-e21b01aef2b7)[0: ]/EndEntire
block
simple FS
/ACPI(a0341d0,0)/PCI(1,1f)/ATAPI(0,0,0)/HD(2,10,5c1,0000000000000000,20,0)/EndEntire
disk
block
/ACPI(a0341d0,0)/PCI(1,1f)/ATAPI(0,0,0)/HD(3,5d1,ca3,0000000000000000,20,0)/EndEntire
simple FS
disk
block
/ACPI(a0341d0,0)/PCI(1,1f)/ATAPI(0,0,0)/HD(4,1274,a2,0000000000000000,20,0)/EndEntire
disk
block

The three HD media paths are for three Apple partitions (and the third
one has simple FS because it does contains HFS+). And I /think/ that the
very first Vendor media path refers to CD-ROM (based on the fact that it
got simple FS protocol). I played a bit with it; when I try to list
filesystem for this media path in EFI shell, it audibly tries to access
CD-ROM but fails. May be it requires Apple ISO9660 extensions, but I do
not know how to create EFI bootable image containing Apple extensions
(mkisofs should support it, but I was lost in arguments. xorriso
apparently does not support Apple extensions).

In your case you have SATA DVD drive, right? And path shown refers to
it?


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Skip Apple ghosts
  2013-12-24 13:26 [PATCH] Skip Apple ghosts Vladimir 'φ-coder/phcoder' Serbinenko
  2013-12-24 16:44 ` Andrey Borzenkov
  2014-01-07 18:17 ` Andrey Borzenkov
@ 2014-01-07 18:20 ` Andrey Borzenkov
  2 siblings, 0 replies; 5+ messages in thread
From: Andrey Borzenkov @ 2014-01-07 18:20 UTC (permalink / raw)
  To: grub-devel


В Вт, 24/12/2013 в 14:26 +0100, Vladimir 'φ-coder/phcoder' Serbinenko
пишет:
> Hello, all. It was discovered that on macs sometimes firmware defines
> ghost disks with vendor suffix. E.g.
> /ACPI(a0341d0,0)/PCI(2,1f)/UnknownMessaging(12)/EndEntire
> is a normal disks with partitions presented with HD(...) but then
> /ACPI(a0341d0,0)/PCI(2,1f)/UnknownMessaging(12)/MediaVendor(Apple)[0:
> ]/EndEntire
> is a ghost disk. It has as suffix a vendor path with empty vendor data.
> This is a problem because when chainloading on such disks GRUB can't
> find handle of partition as none is defined. I propose to dkip ghosts
> completely. This should be safe as the skip happens only for empty Apple
> vendor suffix and if the parent is already a known disk.
> Did anyone see anything similar?

Yes (on MacBook Pro); 

Here is what I get when EFI-booting from GRUB rescue CD made with single
x86_64-efi target:

/ACPI(a0341d0,0)/PCI(1,1f)/ATAPI(0,0,0)/EndEntire
disk
block
/ACPI(a0341d0,0)/PCI(1,1f)/ATAPI(0,0,0)/MediaVendor(2b0585eb-d8b8-49a9-8b8c-e21b01aef2b7)[0: ]/EndEntire
block
simple FS
/ACPI(a0341d0,0)/PCI(1,1f)/ATAPI(0,0,0)/HD(2,10,5c1,0000000000000000,20,0)/EndEntire
disk
block
/ACPI(a0341d0,0)/PCI(1,1f)/ATAPI(0,0,0)/HD(3,5d1,ca3,0000000000000000,20,0)/EndEntire
simple FS
disk
block
/ACPI(a0341d0,0)/PCI(1,1f)/ATAPI(0,0,0)/HD(4,1274,a2,0000000000000000,20,0)/EndEntire
disk
block

The three HD media paths are for three Apple partitions (and the third
one has simple FS because it does contains HFS+). And I /think/ that the
very first Vendor media path refers to CD-ROM (based on the fact that it
got simple FS protocol). I played a bit with it; when I try to list
filesystem for this media path in EFI shell, it audibly tries to access
CD-ROM but fails. May be it requires Apple ISO9660 extensions, but I do
not know how to create EFI bootable image containing Apple extensions
(mkisofs should support it, but I was lost in arguments. xorriso
apparently does not support Apple extensions).

In your case you have SATA DVD drive, right? And path shown refers to
it?





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-01-07 18:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-24 13:26 [PATCH] Skip Apple ghosts Vladimir 'φ-coder/phcoder' Serbinenko
2013-12-24 16:44 ` Andrey Borzenkov
2013-12-24 17:00   ` Vladimir 'φ-coder/phcoder' Serbinenko
2014-01-07 18:17 ` Andrey Borzenkov
2014-01-07 18:20 ` Andrey Borzenkov

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).