All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] Revert unified GUID struct
@ 2023-10-05 10:47 Oliver Steffen
  2023-10-05 10:47 ` [PATCH 1/4] bli: don't use %pG format specifier Oliver Steffen
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Oliver Steffen @ 2023-10-05 10:47 UTC (permalink / raw)
  To: grub-devel
  Cc: Daniel Kiper, Gerd Hoffmann, Tobias Powalowski,
	Pedro Miguel Justo, Laszlo Ersek, Frank Scheiner,
	Vladimir 'phcoder' Serbinenko, John Paul Adrian Glaubitz,
	Ard Biesheuvel, Oliver Steffen

The introduction of the new grub_guid struct which unified the three
previously existing guid structs [1,2] causes regressions on some
architectures [3..7].

Since there is no satisfactory solution yet and I am too short on time
to properly solve this quickly, and not to delay the release of Grub
2.12 any further, I propose to undo these changes and revisit the topic
of guid data types and related functions at a later point. This would
also give us more time for testing, on a wider set of architectures.

This series reverts the unified guid struct and the introduction of the
%pG printf format specifier, introduced by these commits:

  6ad116e5f guid: Make use of GUID printf format specifier
  f82dbf2bd kern/misc: Add a format specifier GUIDs
  06edd40db guid: Unify GUID types

It also fixes code introduced by these commits, since it makes use of
the unified GUID struct:

  e83a88f6e efi: Add grub_efi_set_variable_to_string()
  e0fa7dc84 bli: Add a module for the Boot Loader Interface

This restores the guid handling to the state from before 06edd40db,
which has been working on all platforms for many years.

Oliver

bli patch series:
[1] https://mail.gnu.org/archive/html/grub-devel/2023-05/msg00156.html

GUID unification:
[2] https://mail.gnu.org/archive/html/grub-devel/2023-05/msg00142.html

Itanium trap issue:
[3] https://mail.gnu.org/archive/html/grub-devel/2023-08/msg00019.html

bli blank screen issue:
[4] https://mail.gnu.org/archive/html/grub-devel/2023-07/msg00077.html
[5] https://mail.gnu.org/archive/html/grub-devel/2023-08/msg00030.html
[6] https://mail.gnu.org/archive/html/grub-devel/2023-09/msg00093.html
[7] https://mail.gnu.org/archive/html/grub-devel/2023-10/msg00000.html

Oliver Steffen (4):
  bli: don't use %pG format specifier
  Revert "guid: Make use of GUID printf format specifier"
  Revert "kern/misc: Add a format specifier GUIDs"
  guid: un-unifiy GUID types

 grub-core/commands/acpi.c            |  4 +-
 grub-core/commands/bli.c             | 11 +++-
 grub-core/commands/efi/efifwsetup.c  |  4 +-
 grub-core/commands/efi/loadbios.c    | 14 ++---
 grub-core/commands/efi/lsefi.c       | 17 ++++--
 grub-core/commands/efi/lsefisystab.c | 10 ++--
 grub-core/commands/efi/lssal.c       |  4 +-
 grub-core/commands/efi/smbios.c      | 12 ++---
 grub-core/commands/efi/tpm.c         |  6 +--
 grub-core/commands/probe.c           | 14 +++--
 grub-core/disk/efi/efidisk.c         |  4 +-
 grub-core/disk/ldm.c                 |  2 +-
 grub-core/efiemu/i386/pc/cfgtables.c |  6 +--
 grub-core/efiemu/main.c              |  4 +-
 grub-core/efiemu/runtime/efiemu.c    | 14 ++---
 grub-core/kern/efi/acpi.c            | 12 ++---
 grub-core/kern/efi/efi.c             | 52 +++++++++++++-----
 grub-core/kern/efi/fdt.c             |  2 +-
 grub-core/kern/efi/init.c            |  2 +-
 grub-core/kern/efi/sb.c              |  4 +-
 grub-core/kern/misc.c                | 81 ++++++++--------------------
 grub-core/loader/efi/fdt.c           |  2 +-
 grub-core/loader/efi/linux.c         |  4 +-
 grub-core/loader/i386/xnu.c          | 13 +++--
 grub-core/loader/ia64/efi/linux.c    |  2 +-
 grub-core/net/drivers/efi/efinet.c   |  4 +-
 grub-core/partmap/gpt.c              |  4 +-
 grub-core/term/efi/console.c         |  2 +-
 grub-core/term/efi/serial.c          |  2 +-
 grub-core/video/efi_gop.c            |  8 +--
 grub-core/video/efi_uga.c            |  2 +-
 include/grub/efi/api.h               | 64 ++++++++++++++--------
 include/grub/efi/efi.h               | 18 +++----
 include/grub/efiemu/efiemu.h         | 10 ++--
 include/grub/efiemu/runtime.h        |  2 +-
 include/grub/gpt_partition.h         | 13 ++++-
 include/grub/types.h                 |  9 ----
 util/grub-install.c                  |  2 +-
 util/grub-probe.c                    |  2 +-
 39 files changed, 238 insertions(+), 204 deletions(-)

-- 
2.41.0


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

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

* [PATCH 1/4] bli: don't use %pG format specifier
  2023-10-05 10:47 [PATCH 0/4] Revert unified GUID struct Oliver Steffen
@ 2023-10-05 10:47 ` Oliver Steffen
  2023-10-05 14:24   ` Laszlo Ersek
  2023-10-05 10:47 ` [PATCH 2/4] Revert "guid: Make use of GUID printf format specifier" Oliver Steffen
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Oliver Steffen @ 2023-10-05 10:47 UTC (permalink / raw)
  To: grub-devel
  Cc: Daniel Kiper, Gerd Hoffmann, Tobias Powalowski,
	Pedro Miguel Justo, Laszlo Ersek, Frank Scheiner,
	Vladimir 'phcoder' Serbinenko, John Paul Adrian Glaubitz,
	Ard Biesheuvel, Oliver Steffen

We are about to revert the unified GUID type and it's printf format
specifier, so do use the explicit printf statement for the partition
UUID here instread.

Signed-off-by: Oliver Steffen <osteffen@redhat.com>
---
 grub-core/commands/bli.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/grub-core/commands/bli.c b/grub-core/commands/bli.c
index e0d8a54f7..2a3933925 100644
--- a/grub-core/commands/bli.c
+++ b/grub-core/commands/bli.c
@@ -70,7 +70,14 @@ get_part_uuid (const char *device_name, char **part_uuid)
       goto fail;
     }
 
-  *part_uuid = grub_xasprintf ("%pG", &entry.guid);
+  *part_uuid = grub_xasprintf (
+		 "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+		 grub_le_to_cpu32 (entry.guid.data1),
+		 grub_le_to_cpu16 (entry.guid.data2),
+		 grub_le_to_cpu16 (entry.guid.data3),
+		 entry.guid.data4[0], entry.guid.data4[1], entry.guid.data4[2],
+		 entry.guid.data4[3], entry.guid.data4[4], entry.guid.data4[5],
+		 entry.guid.data4[6], entry.guid.data4[7]);
   if (*part_uuid == NULL)
     status = grub_errno;
 
-- 
2.41.0


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

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

* [PATCH 2/4] Revert "guid: Make use of GUID printf format specifier"
  2023-10-05 10:47 [PATCH 0/4] Revert unified GUID struct Oliver Steffen
  2023-10-05 10:47 ` [PATCH 1/4] bli: don't use %pG format specifier Oliver Steffen
@ 2023-10-05 10:47 ` Oliver Steffen
  2023-10-05 14:28   ` Laszlo Ersek
  2023-10-05 10:47 ` [PATCH 3/4] Revert "kern/misc: Add a format specifier GUIDs" Oliver Steffen
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Oliver Steffen @ 2023-10-05 10:47 UTC (permalink / raw)
  To: grub-devel
  Cc: Daniel Kiper, Gerd Hoffmann, Tobias Powalowski,
	Pedro Miguel Justo, Laszlo Ersek, Frank Scheiner,
	Vladimir 'phcoder' Serbinenko, John Paul Adrian Glaubitz,
	Ard Biesheuvel, Oliver Steffen

This reverts commit 6ad116e5ff459ae06eb993d386da5e7589242667.

Signed-off-by: Oliver Steffen <osteffen@redhat.com>
---
 grub-core/commands/efi/lsefi.c       | 13 ++++++++++++-
 grub-core/commands/efi/lsefisystab.c |  6 +++++-
 grub-core/commands/probe.c           | 12 ++++++++----
 grub-core/kern/efi/efi.c             | 28 ++++++++++++++++++++++++++--
 grub-core/loader/i386/xnu.c          |  9 +++++++--
 5 files changed, 58 insertions(+), 10 deletions(-)

diff --git a/grub-core/commands/efi/lsefi.c b/grub-core/commands/efi/lsefi.c
index 05e2e511e..6935cd302 100644
--- a/grub-core/commands/efi/lsefi.c
+++ b/grub-core/commands/efi/lsefi.c
@@ -124,7 +124,18 @@ grub_cmd_lsefi (grub_command_t cmd __attribute__ ((unused)),
 	  if (k < ARRAY_SIZE (known_protocols))
 	    grub_printf ("  %s\n", known_protocols[k].name);
 	  else
-	    grub_printf ("  %pG\n", protocols[j]);
+	    grub_printf ("  %08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x\n",
+			 protocols[j]->data1,
+			 protocols[j]->data2,
+			 protocols[j]->data3,
+			 (unsigned) protocols[j]->data4[0],
+			 (unsigned) protocols[j]->data4[1],
+			 (unsigned) protocols[j]->data4[2],
+			 (unsigned) protocols[j]->data4[3],
+			 (unsigned) protocols[j]->data4[4],
+			 (unsigned) protocols[j]->data4[5],
+			 (unsigned) protocols[j]->data4[6],
+			 (unsigned) protocols[j]->data4[7]);
 	}
 
     }
diff --git a/grub-core/commands/efi/lsefisystab.c b/grub-core/commands/efi/lsefisystab.c
index 79ccee12a..eff8c41f3 100644
--- a/grub-core/commands/efi/lsefisystab.c
+++ b/grub-core/commands/efi/lsefisystab.c
@@ -96,7 +96,11 @@ grub_cmd_lsefisystab (struct grub_command *cmd __attribute__ ((unused)),
 
       grub_printf ("%p  ", t->vendor_table);
 
-      grub_printf ("%pG", &t->vendor_guid);
+      grub_printf ("%08x-%04x-%04x-",
+		   t->vendor_guid.data1, t->vendor_guid.data2,
+		   t->vendor_guid.data3);
+      for (j = 0; j < 8; j++)
+	grub_printf ("%02x", t->vendor_guid.data4[j]);
 
       for (j = 0; j < ARRAY_SIZE (guid_mappings); j++)
 	if (grub_memcmp (&guid_mappings[j].guid, &t->vendor_guid,
diff --git a/grub-core/commands/probe.c b/grub-core/commands/probe.c
index be9637f33..cc8c05586 100644
--- a/grub-core/commands/probe.c
+++ b/grub-core/commands/probe.c
@@ -130,10 +130,14 @@ grub_cmd_probe (grub_extcmd_context_t ctxt, int argc, char **args)
 		  return grub_errno;
 		}
 	      guid = &entry.guid;
-	      guid->data1 = grub_le_to_cpu32 (guid->data1);
-	      guid->data2 = grub_le_to_cpu16 (guid->data2);
-	      guid->data3 = grub_le_to_cpu16 (guid->data3);
-	      grub_snprintf (val, sizeof(val), "%pG", guid);
+	      grub_snprintf (val, sizeof(val),
+			     "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+			     grub_le_to_cpu32 (guid->data1),
+			     grub_le_to_cpu16 (guid->data2),
+			     grub_le_to_cpu16 (guid->data3),
+			     guid->data4[0], guid->data4[1], guid->data4[2],
+			     guid->data4[3], guid->data4[4], guid->data4[5],
+			     guid->data4[6], guid->data4[7]);
 	    }
 	  else if (grub_strcmp(dev->disk->partition->partmap->name, "msdos") == 0)
 	    {
diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c
index a2afd8de9..5e1c147a5 100644
--- a/grub-core/kern/efi/efi.c
+++ b/grub-core/kern/efi/efi.c
@@ -558,7 +558,20 @@ static void
 dump_vendor_path (const char *type, grub_efi_vendor_device_path_t *vendor)
 {
   grub_uint32_t vendor_data_len = vendor->header.length - sizeof (*vendor);
-  grub_printf ("/%sVendor(%pG)[%x: ", type, &vendor->vendor_guid, vendor_data_len);
+  grub_printf ("/%sVendor(%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x)[%x: ",
+	       type,
+	       (unsigned) vendor->vendor_guid.data1,
+	       (unsigned) vendor->vendor_guid.data2,
+	       (unsigned) vendor->vendor_guid.data3,
+	       (unsigned) vendor->vendor_guid.data4[0],
+	       (unsigned) vendor->vendor_guid.data4[1],
+	       (unsigned) vendor->vendor_guid.data4[2],
+	       (unsigned) vendor->vendor_guid.data4[3],
+	       (unsigned) vendor->vendor_guid.data4[4],
+	       (unsigned) vendor->vendor_guid.data4[5],
+	       (unsigned) vendor->vendor_guid.data4[6],
+	       (unsigned) vendor->vendor_guid.data4[7],
+	       vendor_data_len);
   if (vendor->header.length > sizeof (*vendor))
     {
       grub_uint32_t i;
@@ -929,7 +942,18 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
 	      {
 		grub_efi_protocol_device_path_t *proto
 		  = (grub_efi_protocol_device_path_t *) dp;
-		grub_printf ("/Protocol(%pG)",&proto->guid);
+		grub_printf ("/Protocol(%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x)",
+			     (unsigned) proto->guid.data1,
+			     (unsigned) proto->guid.data2,
+			     (unsigned) proto->guid.data3,
+			     (unsigned) proto->guid.data4[0],
+			     (unsigned) proto->guid.data4[1],
+			     (unsigned) proto->guid.data4[2],
+			     (unsigned) proto->guid.data4[3],
+			     (unsigned) proto->guid.data4[4],
+			     (unsigned) proto->guid.data4[5],
+			     (unsigned) proto->guid.data4[6],
+			     (unsigned) proto->guid.data4[7]);
 	      }
 	      break;
 	    default:
diff --git a/grub-core/loader/i386/xnu.c b/grub-core/loader/i386/xnu.c
index 4e31ce99a..93ba4476d 100644
--- a/grub-core/loader/i386/xnu.c
+++ b/grub-core/loader/i386/xnu.c
@@ -726,8 +726,13 @@ grub_cpu_xnu_fill_devicetree (grub_uint64_t *fsbfreq_out)
 #endif
 
       /* The name of key for new table. */
-      grub_snprintf (guidbuf, sizeof (guidbuf), "%pG", &guid);
-
+      grub_snprintf (guidbuf, sizeof (guidbuf), "%08x-%04x-%04x-%02x%02x-",
+		     guid.data1, guid.data2, guid.data3, guid.data4[0],
+		     guid.data4[1]);
+      for (j = 2; j < 8; j++)
+	grub_snprintf (guidbuf + grub_strlen (guidbuf),
+		       sizeof (guidbuf) - grub_strlen (guidbuf),
+		       "%02x", guid.data4[j]);
       /* For some reason GUID has to be in uppercase. */
       for (j = 0; guidbuf[j] ; j++)
 	if (guidbuf[j] >= 'a' && guidbuf[j] <= 'f')
-- 
2.41.0


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

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

* [PATCH 3/4] Revert "kern/misc: Add a format specifier GUIDs"
  2023-10-05 10:47 [PATCH 0/4] Revert unified GUID struct Oliver Steffen
  2023-10-05 10:47 ` [PATCH 1/4] bli: don't use %pG format specifier Oliver Steffen
  2023-10-05 10:47 ` [PATCH 2/4] Revert "guid: Make use of GUID printf format specifier" Oliver Steffen
@ 2023-10-05 10:47 ` Oliver Steffen
  2023-10-05 14:29   ` Laszlo Ersek
  2023-10-05 10:47 ` [PATCH 4/4] guid: un-unifiy GUID types Oliver Steffen
  2023-10-05 16:26 ` [PATCH 0/4] Revert unified GUID struct Vladimir 'phcoder' Serbinenko
  4 siblings, 1 reply; 10+ messages in thread
From: Oliver Steffen @ 2023-10-05 10:47 UTC (permalink / raw)
  To: grub-devel
  Cc: Daniel Kiper, Gerd Hoffmann, Tobias Powalowski,
	Pedro Miguel Justo, Laszlo Ersek, Frank Scheiner,
	Vladimir 'phcoder' Serbinenko, John Paul Adrian Glaubitz,
	Ard Biesheuvel, Oliver Steffen

This reverts commit f82dbf2bd871e9cce327b511a393ffa543d7f69e.

Signed-off-by: Oliver Steffen <osteffen@redhat.com>
---
 grub-core/kern/misc.c | 81 +++++++++++--------------------------------
 1 file changed, 21 insertions(+), 60 deletions(-)

diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c
index b57249acb..0854fefc0 100644
--- a/grub-core/kern/misc.c
+++ b/grub-core/kern/misc.c
@@ -24,7 +24,6 @@
 #include <grub/term.h>
 #include <grub/env.h>
 #include <grub/i18n.h>
-#include <grub/types.h>
 #include <grub/charset.h>
 
 union printf_arg
@@ -36,8 +35,7 @@ union printf_arg
     {
       INT, LONG, LONGLONG,
       UNSIGNED_INT = 3, UNSIGNED_LONG, UNSIGNED_LONGLONG,
-      STRING,
-      GUID
+      STRING
     } type;
   long long ll;
 };
@@ -781,9 +779,6 @@ parse_printf_arg_fmt (const char *fmt0, struct printf_args *args,
       switch (c)
 	{
 	case 'p':
-	  if (*(fmt) == 'G')
-	    ++fmt;
-	  /* Fall through. */
 	case 'x':
 	case 'X':
 	case 'u':
@@ -899,10 +894,6 @@ parse_printf_arg_fmt (const char *fmt0, struct printf_args *args,
 	    args->ptr[curn].type = UNSIGNED_LONGLONG;
 	  else
 	    args->ptr[curn].type = UNSIGNED_INT;
-	  if (*(fmt) == 'G') {
-	    args->ptr[curn].type = GUID;
-	    ++fmt;
-	  }
 	  break;
 	case 's':
 	  args->ptr[curn].type = STRING;
@@ -944,7 +935,6 @@ parse_printf_args (const char *fmt0, struct printf_args *args, va_list args_in)
 	args->ptr[n].ll = va_arg (args_in, long long);
 	break;
       case STRING:
-      case GUID:
 	if (sizeof (void *) == sizeof (long long))
 	  args->ptr[n].ll = va_arg (args_in, long long);
 	else
@@ -962,27 +952,6 @@ write_char (char *str, grub_size_t *count, grub_size_t max_len, unsigned char ch
   (*count)++;
 }
 
-static void
-write_number (char *str, grub_size_t *count, grub_size_t max_len, grub_size_t format1,
-	     char rightfill, char zerofill, char c, long long value)
-{
-  char tmp[32];
-  const char *p = tmp;
-  grub_size_t len;
-  grub_size_t fill;
-
-  len = grub_lltoa (tmp, c, value) - tmp;
-  fill = len < format1 ? format1 - len : 0;
-  if (! rightfill)
-    while (fill--)
-      write_char (str, count, max_len, zerofill);
-  while (*p)
-    write_char (str, count, max_len, *p++);
-  if (rightfill)
-    while (fill--)
-      write_char (str, count, max_len, zerofill);
-}
-
 static int
 grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0,
 		     struct printf_args *args)
@@ -1065,40 +1034,32 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0,
       switch (c)
 	{
 	case 'p':
-	  if (*(fmt) == 'G')
-	    {
-	      ++fmt;
-	      grub_guid_t *guid = (grub_guid_t *)(grub_addr_t) curarg;
-	      write_number (str, &count, max_len, 8, 0, '0', 'x', guid->data1);
-	      write_char (str, &count, max_len, '-');
-	      write_number (str, &count, max_len, 4, 0, '0', 'x', guid->data2);
-	      write_char (str, &count, max_len, '-');
-	      write_number (str, &count, max_len, 4, 0, '0', 'x', guid->data3);
-	      write_char (str, &count, max_len, '-');
-	      write_number (str, &count, max_len, 2, 0, '0', 'x', guid->data4[0]);
-	      write_number (str, &count, max_len, 2, 0, '0', 'x', guid->data4[1]);
-	      write_char (str, &count, max_len, '-');
-	      write_number (str, &count, max_len, 2, 0, '0', 'x', guid->data4[2]);
-	      write_number (str, &count, max_len, 2, 0, '0', 'x', guid->data4[3]);
-	      write_number (str, &count, max_len, 2, 0, '0', 'x', guid->data4[4]);
-	      write_number (str, &count, max_len, 2, 0, '0', 'x', guid->data4[5]);
-	      write_number (str, &count, max_len, 2, 0, '0', 'x', guid->data4[6]);
-	      write_number (str, &count, max_len, 2, 0, '0', 'x', guid->data4[7]);
-	      break;
-	    }
-	  else
-	    {
-	      write_char (str, &count, max_len, '0');
-	      write_char (str, &count, max_len, 'x');
-	      c = 'x';
-	    }
+	  write_char (str, &count, max_len, '0');
+	  write_char (str, &count, max_len, 'x');
+	  c = 'x';
 	  /* Fall through. */
 	case 'x':
 	case 'X':
 	case 'u':
 	case 'd':
 	case 'o':
-	  write_number (str, &count, max_len, format1, rightfill, zerofill, c, curarg);
+	  {
+	    char tmp[32];
+	    const char *p = tmp;
+	    grub_size_t len;
+	    grub_size_t fill;
+
+	    len = grub_lltoa (tmp, c, curarg) - tmp;
+	    fill = len < format1 ? format1 - len : 0;
+	    if (! rightfill)
+	      while (fill--)
+		write_char (str, &count, max_len, zerofill);
+	    while (*p)
+	      write_char (str, &count, max_len, *p++);
+	    if (rightfill)
+	      while (fill--)
+		write_char (str, &count, max_len, zerofill);
+	  }
 	  break;
 
 	case 'c':
-- 
2.41.0


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

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

* [PATCH 4/4] guid: un-unifiy GUID types
  2023-10-05 10:47 [PATCH 0/4] Revert unified GUID struct Oliver Steffen
                   ` (2 preceding siblings ...)
  2023-10-05 10:47 ` [PATCH 3/4] Revert "kern/misc: Add a format specifier GUIDs" Oliver Steffen
@ 2023-10-05 10:47 ` Oliver Steffen
  2023-10-05 14:38   ` Laszlo Ersek
  2023-10-05 16:26 ` [PATCH 0/4] Revert unified GUID struct Vladimir 'phcoder' Serbinenko
  4 siblings, 1 reply; 10+ messages in thread
From: Oliver Steffen @ 2023-10-05 10:47 UTC (permalink / raw)
  To: grub-devel
  Cc: Daniel Kiper, Gerd Hoffmann, Tobias Powalowski,
	Pedro Miguel Justo, Laszlo Ersek, Frank Scheiner,
	Vladimir 'phcoder' Serbinenko, John Paul Adrian Glaubitz,
	Ard Biesheuvel, Oliver Steffen

Switch back to separate GUID types, depending on use-case.

- Reverts commit 06edd40db76bb78457ac26156ed5f7b62381bbe8,
  "guid: Unify GUID types"
- Changes the guid type used in grub_efi_set_variable_to_string()
  to grub_efi_guid_t.
- Fixes the type of bli_vendor_guid in bli.c

Signed-off-by: Oliver Steffen <osteffen@redhat.com>
---
 grub-core/commands/acpi.c            |  4 +-
 grub-core/commands/bli.c             |  2 +-
 grub-core/commands/efi/efifwsetup.c  |  4 +-
 grub-core/commands/efi/loadbios.c    | 14 +++---
 grub-core/commands/efi/lsefi.c       |  4 +-
 grub-core/commands/efi/lsefisystab.c |  4 +-
 grub-core/commands/efi/lssal.c       |  4 +-
 grub-core/commands/efi/smbios.c      | 12 +++---
 grub-core/commands/efi/tpm.c         |  6 +--
 grub-core/commands/probe.c           |  2 +-
 grub-core/disk/efi/efidisk.c         |  4 +-
 grub-core/disk/ldm.c                 |  2 +-
 grub-core/efiemu/i386/pc/cfgtables.c |  6 +--
 grub-core/efiemu/main.c              |  4 +-
 grub-core/efiemu/runtime/efiemu.c    | 14 +++---
 grub-core/kern/efi/acpi.c            | 12 +++---
 grub-core/kern/efi/efi.c             | 24 +++++------
 grub-core/kern/efi/fdt.c             |  2 +-
 grub-core/kern/efi/init.c            |  2 +-
 grub-core/kern/efi/sb.c              |  4 +-
 grub-core/loader/efi/fdt.c           |  2 +-
 grub-core/loader/efi/linux.c         |  4 +-
 grub-core/loader/i386/xnu.c          |  4 +-
 grub-core/loader/ia64/efi/linux.c    |  2 +-
 grub-core/net/drivers/efi/efinet.c   |  4 +-
 grub-core/partmap/gpt.c              |  4 +-
 grub-core/term/efi/console.c         |  2 +-
 grub-core/term/efi/serial.c          |  2 +-
 grub-core/video/efi_gop.c            |  8 ++--
 grub-core/video/efi_uga.c            |  2 +-
 include/grub/efi/api.h               | 64 ++++++++++++++++++----------
 include/grub/efi/efi.h               | 18 ++++----
 include/grub/efiemu/efiemu.h         | 10 ++---
 include/grub/efiemu/runtime.h        |  2 +-
 include/grub/gpt_partition.h         | 13 +++++-
 include/grub/types.h                 |  9 ----
 util/grub-install.c                  |  2 +-
 util/grub-probe.c                    |  2 +-
 38 files changed, 151 insertions(+), 133 deletions(-)

diff --git a/grub-core/commands/acpi.c b/grub-core/commands/acpi.c
index 1c034463c..0d0c14810 100644
--- a/grub-core/commands/acpi.c
+++ b/grub-core/commands/acpi.c
@@ -763,8 +763,8 @@ grub_cmd_acpi (struct grub_extcmd_context *ctxt, int argc, char **args)
 
 #ifdef GRUB_MACHINE_EFI
   {
-    static grub_guid_t acpi = GRUB_EFI_ACPI_TABLE_GUID;
-    static grub_guid_t acpi20 = GRUB_EFI_ACPI_20_TABLE_GUID;
+    struct grub_efi_guid acpi = GRUB_EFI_ACPI_TABLE_GUID;
+    struct grub_efi_guid acpi20 = GRUB_EFI_ACPI_20_TABLE_GUID;
 
     grub_efi_system_table->boot_services->install_configuration_table (&acpi20,
 								       grub_acpi_get_rsdpv2 ());
diff --git a/grub-core/commands/bli.c b/grub-core/commands/bli.c
index 2a3933925..d1aeeea59 100644
--- a/grub-core/commands/bli.c
+++ b/grub-core/commands/bli.c
@@ -34,7 +34,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
 
 #define MODNAME "bli"
 
-static const grub_guid_t bli_vendor_guid = GRUB_EFI_VENDOR_BOOT_LOADER_INTERFACE_GUID;
+static const grub_efi_guid_t bli_vendor_guid = GRUB_EFI_VENDOR_BOOT_LOADER_INTERFACE_GUID;
 
 static grub_err_t
 get_part_uuid (const char *device_name, char **part_uuid)
diff --git a/grub-core/commands/efi/efifwsetup.c b/grub-core/commands/efi/efifwsetup.c
index 704f9d352..de66c3035 100644
--- a/grub-core/commands/efi/efifwsetup.c
+++ b/grub-core/commands/efi/efifwsetup.c
@@ -38,7 +38,7 @@ grub_cmd_fwsetup (grub_command_t cmd __attribute__ ((unused)),
   grub_efi_uint64_t os_indications = GRUB_EFI_OS_INDICATIONS_BOOT_TO_FW_UI;
   grub_err_t status;
   grub_size_t oi_size;
-  static grub_guid_t global = GRUB_EFI_GLOBAL_VARIABLE_GUID;
+  static grub_efi_guid_t global = GRUB_EFI_GLOBAL_VARIABLE_GUID;
 
   if (argc >= 1 && grub_strcmp(args[0], "--is-supported") == 0)
     return !efifwsetup_is_supported ();
@@ -72,7 +72,7 @@ efifwsetup_is_supported (void)
 {
   grub_efi_uint64_t *os_indications_supported = NULL;
   grub_size_t oi_size = 0;
-  static grub_guid_t global = GRUB_EFI_GLOBAL_VARIABLE_GUID;
+  static grub_efi_guid_t global = GRUB_EFI_GLOBAL_VARIABLE_GUID;
   grub_efi_boolean_t ret = 0;
 
   grub_efi_get_variable ("OsIndicationsSupported", &global, &oi_size,
diff --git a/grub-core/commands/efi/loadbios.c b/grub-core/commands/efi/loadbios.c
index 8f6b0ecfc..574e41046 100644
--- a/grub-core/commands/efi/loadbios.c
+++ b/grub-core/commands/efi/loadbios.c
@@ -27,9 +27,9 @@
 
 GRUB_MOD_LICENSE ("GPLv3+");
 
-static grub_guid_t acpi_guid = GRUB_EFI_ACPI_TABLE_GUID;
-static grub_guid_t acpi2_guid = GRUB_EFI_ACPI_20_TABLE_GUID;
-static grub_guid_t smbios_guid = GRUB_EFI_SMBIOS_TABLE_GUID;
+static grub_efi_guid_t acpi_guid = GRUB_EFI_ACPI_TABLE_GUID;
+static grub_efi_guid_t acpi2_guid = GRUB_EFI_ACPI_20_TABLE_GUID;
+static grub_efi_guid_t smbios_guid = GRUB_EFI_SMBIOS_TABLE_GUID;
 
 #define EBDA_SEG_ADDR	0x40e
 #define LOW_MEM_ADDR	0x413
@@ -105,15 +105,15 @@ fake_bios_data (int use_rom)
   smbios = 0;
   for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
     {
-      grub_guid_t *guid =
+      grub_efi_packed_guid_t *guid =
 	&grub_efi_system_table->configuration_table[i].vendor_guid;
 
-      if (! grub_memcmp (guid, &acpi2_guid, sizeof (grub_guid_t)))
+      if (! grub_memcmp (guid, &acpi2_guid, sizeof (grub_efi_guid_t)))
 	{
 	  acpi = grub_efi_system_table->configuration_table[i].vendor_table;
 	  grub_dprintf ("efi", "ACPI2: %p\n", acpi);
 	}
-      else if (! grub_memcmp (guid, &acpi_guid, sizeof (grub_guid_t)))
+      else if (! grub_memcmp (guid, &acpi_guid, sizeof (grub_efi_guid_t)))
 	{
 	  void *t;
 
@@ -122,7 +122,7 @@ fake_bios_data (int use_rom)
 	    acpi = t;
 	  grub_dprintf ("efi", "ACPI: %p\n", t);
 	}
-      else if (! grub_memcmp (guid, &smbios_guid, sizeof (grub_guid_t)))
+      else if (! grub_memcmp (guid, &smbios_guid, sizeof (grub_efi_guid_t)))
 	{
 	  smbios = grub_efi_system_table->configuration_table[i].vendor_table;
 	  grub_dprintf ("efi", "SMBIOS: %p\n", smbios);
diff --git a/grub-core/commands/efi/lsefi.c b/grub-core/commands/efi/lsefi.c
index 6935cd302..539701497 100644
--- a/grub-core/commands/efi/lsefi.c
+++ b/grub-core/commands/efi/lsefi.c
@@ -31,7 +31,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
 
 struct known_protocol
 {
-  grub_guid_t guid;
+  grub_efi_guid_t guid;
   const char *name;
 } known_protocols[] =
   {
@@ -96,7 +96,7 @@ grub_cmd_lsefi (grub_command_t cmd __attribute__ ((unused)),
       grub_efi_handle_t handle = handles[i];
       grub_efi_status_t status;
       grub_efi_uintn_t num_protocols;
-      grub_guid_t **protocols;
+      grub_efi_packed_guid_t **protocols;
       grub_efi_device_path_t *dp;
 
       grub_printf ("Handle %p\n", handle);
diff --git a/grub-core/commands/efi/lsefisystab.c b/grub-core/commands/efi/lsefisystab.c
index eff8c41f3..ac3299b7f 100644
--- a/grub-core/commands/efi/lsefisystab.c
+++ b/grub-core/commands/efi/lsefisystab.c
@@ -29,7 +29,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
 
 struct guid_mapping
 {
-  grub_guid_t guid;
+  grub_efi_guid_t guid;
   const char *name;
 };
 
@@ -104,7 +104,7 @@ grub_cmd_lsefisystab (struct grub_command *cmd __attribute__ ((unused)),
 
       for (j = 0; j < ARRAY_SIZE (guid_mappings); j++)
 	if (grub_memcmp (&guid_mappings[j].guid, &t->vendor_guid,
-			 sizeof (grub_guid_t)) == 0)
+			 sizeof (grub_efi_guid_t)) == 0)
 	  grub_printf ("   %s", guid_mappings[j].name);
 
       grub_printf ("\n");
diff --git a/grub-core/commands/efi/lssal.c b/grub-core/commands/efi/lssal.c
index fd6085f1b..5084ddd8b 100644
--- a/grub-core/commands/efi/lssal.c
+++ b/grub-core/commands/efi/lssal.c
@@ -139,12 +139,12 @@ grub_cmd_lssal (struct grub_command *cmd __attribute__ ((unused)),
   const grub_efi_system_table_t *st = grub_efi_system_table;
   grub_efi_configuration_table_t *t = st->configuration_table;
   unsigned int i;
-  static grub_guid_t guid = GRUB_EFI_SAL_TABLE_GUID;
+  grub_efi_packed_guid_t guid = GRUB_EFI_SAL_TABLE_GUID;
 
   for (i = 0; i < st->num_table_entries; i++)
     {
       if (grub_memcmp (&guid, &t->vendor_guid,
-		       sizeof (grub_guid_t)) == 0)
+		       sizeof (grub_efi_packed_guid_t)) == 0)
 	{
 	  disp_sal (t->vendor_table);
 	  return GRUB_ERR_NONE;
diff --git a/grub-core/commands/efi/smbios.c b/grub-core/commands/efi/smbios.c
index d77239732..75202d5aa 100644
--- a/grub-core/commands/efi/smbios.c
+++ b/grub-core/commands/efi/smbios.c
@@ -26,14 +26,14 @@ struct grub_smbios_eps *
 grub_machine_smbios_get_eps (void)
 {
   unsigned i;
-  static grub_guid_t smbios_guid = GRUB_EFI_SMBIOS_TABLE_GUID;
+  static grub_efi_packed_guid_t smbios_guid = GRUB_EFI_SMBIOS_TABLE_GUID;
 
   for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
     {
-      grub_guid_t *guid =
+      grub_efi_packed_guid_t *guid =
 	&grub_efi_system_table->configuration_table[i].vendor_guid;
 
-      if (! grub_memcmp (guid, &smbios_guid, sizeof (grub_guid_t)))
+      if (! grub_memcmp (guid, &smbios_guid, sizeof (grub_efi_packed_guid_t)))
 	return (struct grub_smbios_eps *)
 	  grub_efi_system_table->configuration_table[i].vendor_table;
     }
@@ -45,14 +45,14 @@ struct grub_smbios_eps3 *
 grub_machine_smbios_get_eps3 (void)
 {
   unsigned i;
-  static grub_guid_t smbios3_guid = GRUB_EFI_SMBIOS3_TABLE_GUID;
+  static grub_efi_packed_guid_t smbios3_guid = GRUB_EFI_SMBIOS3_TABLE_GUID;
 
   for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
     {
-      grub_guid_t *guid =
+      grub_efi_packed_guid_t *guid =
 	&grub_efi_system_table->configuration_table[i].vendor_guid;
 
-      if (! grub_memcmp (guid, &smbios3_guid, sizeof (grub_guid_t)))
+      if (! grub_memcmp (guid, &smbios3_guid, sizeof (grub_efi_packed_guid_t)))
 	return (struct grub_smbios_eps3 *)
 	  grub_efi_system_table->configuration_table[i].vendor_table;
     }
diff --git a/grub-core/commands/efi/tpm.c b/grub-core/commands/efi/tpm.c
index f250c30db..bf98c9a6d 100644
--- a/grub-core/commands/efi/tpm.c
+++ b/grub-core/commands/efi/tpm.c
@@ -30,9 +30,9 @@
 
 typedef TCG_PCR_EVENT grub_tpm_event_t;
 
-static grub_guid_t tpm_guid = EFI_TPM_GUID;
-static grub_guid_t tpm2_guid = EFI_TPM2_GUID;
-static grub_guid_t cc_measurement_guid = GRUB_EFI_CC_MEASUREMENT_PROTOCOL_GUID;
+static grub_efi_guid_t tpm_guid = EFI_TPM_GUID;
+static grub_efi_guid_t tpm2_guid = EFI_TPM2_GUID;
+static grub_efi_guid_t cc_measurement_guid = GRUB_EFI_CC_MEASUREMENT_PROTOCOL_GUID;
 
 static grub_efi_handle_t *grub_tpm_handle;
 static grub_uint8_t grub_tpm_version;
diff --git a/grub-core/commands/probe.c b/grub-core/commands/probe.c
index cc8c05586..9a80ea54f 100644
--- a/grub-core/commands/probe.c
+++ b/grub-core/commands/probe.c
@@ -119,7 +119,7 @@ grub_cmd_probe (grub_extcmd_context_t ctxt, int argc, char **args)
 	  if (grub_strcmp(dev->disk->partition->partmap->name, "gpt") == 0)
 	    {
 	      struct grub_gpt_partentry entry;
-	      grub_guid_t *guid;
+	      grub_gpt_part_guid_t *guid;
 
 	      if (grub_disk_read(disk, p->offset, p->index, sizeof(entry), &entry))
 		{
diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c
index 3b5ed5691..ad025010a 100644
--- a/grub-core/disk/efi/efidisk.c
+++ b/grub-core/disk/efi/efidisk.c
@@ -37,7 +37,7 @@ struct grub_efidisk_data
 };
 
 /* GUID.  */
-static grub_guid_t block_io_guid = GRUB_EFI_BLOCK_IO_GUID;
+static grub_efi_guid_t block_io_guid = GRUB_EFI_BLOCK_IO_GUID;
 
 static struct grub_efidisk_data *fd_devices;
 static struct grub_efidisk_data *hd_devices;
@@ -319,7 +319,7 @@ name_devices (struct grub_efidisk_data *devices)
 	  == GRUB_EFI_VENDOR_MEDIA_DEVICE_PATH_SUBTYPE)
 	{
 	  grub_efi_vendor_device_path_t *vendor = (grub_efi_vendor_device_path_t *) dp;
-	  static const grub_guid_t apple = GRUB_EFI_VENDOR_APPLE_GUID;
+	  const struct grub_efi_guid apple = GRUB_EFI_VENDOR_APPLE_GUID;
 
 	  if (vendor->header.length == sizeof (*vendor)
 	      && grub_memcmp (&vendor->vendor_guid, &apple,
diff --git a/grub-core/disk/ldm.c b/grub-core/disk/ldm.c
index 34bfe6bd1..9632bc489 100644
--- a/grub-core/disk/ldm.c
+++ b/grub-core/disk/ldm.c
@@ -136,7 +136,7 @@ msdos_has_ldm_partition (grub_disk_t dsk)
   return has_ldm;
 }
 
-static const grub_guid_t ldm_type = GRUB_GPT_PARTITION_TYPE_LDM;
+static const grub_gpt_part_guid_t ldm_type = GRUB_GPT_PARTITION_TYPE_LDM;
 
 /* Helper for gpt_ldm_sector.  */
 static int
diff --git a/grub-core/efiemu/i386/pc/cfgtables.c b/grub-core/efiemu/i386/pc/cfgtables.c
index 056ec0bc9..1098f0b79 100644
--- a/grub-core/efiemu/i386/pc/cfgtables.c
+++ b/grub-core/efiemu/i386/pc/cfgtables.c
@@ -29,9 +29,9 @@ grub_machine_efiemu_init_tables (void)
 {
   void *table;
   grub_err_t err;
-  static grub_guid_t smbios = GRUB_EFI_SMBIOS_TABLE_GUID;
-  static grub_guid_t acpi20 = GRUB_EFI_ACPI_20_TABLE_GUID;
-  static grub_guid_t acpi = GRUB_EFI_ACPI_TABLE_GUID;
+  static grub_efi_guid_t smbios = GRUB_EFI_SMBIOS_TABLE_GUID;
+  static grub_efi_guid_t acpi20 = GRUB_EFI_ACPI_20_TABLE_GUID;
+  static grub_efi_guid_t acpi = GRUB_EFI_ACPI_TABLE_GUID;
 
   err = grub_efiemu_unregister_configuration_table (smbios);
   if (err)
diff --git a/grub-core/efiemu/main.c b/grub-core/efiemu/main.c
index e7037f4ed..a81934725 100644
--- a/grub-core/efiemu/main.c
+++ b/grub-core/efiemu/main.c
@@ -80,7 +80,7 @@ grub_efiemu_unload (void)
 
 /* Remove previously registered table from the list */
 grub_err_t
-grub_efiemu_unregister_configuration_table (grub_guid_t guid)
+grub_efiemu_unregister_configuration_table (grub_efi_guid_t guid)
 {
   struct grub_efiemu_configuration_table *cur, *prev;
 
@@ -136,7 +136,7 @@ grub_efiemu_register_prepare_hook (grub_err_t (*hook) (void *data),
    or with a hook
 */
 grub_err_t
-grub_efiemu_register_configuration_table (grub_guid_t guid,
+grub_efiemu_register_configuration_table (grub_efi_guid_t guid,
 					  void * (*get_table) (void *data),
 					  void (*unload) (void *data),
 					  void *data)
diff --git a/grub-core/efiemu/runtime/efiemu.c b/grub-core/efiemu/runtime/efiemu.c
index c84b30652..53b3cce7b 100644
--- a/grub-core/efiemu/runtime/efiemu.c
+++ b/grub-core/efiemu/runtime/efiemu.c
@@ -66,7 +66,7 @@ efiemu_convert_pointer (grub_efi_uintn_t debug_disposition,
 
 grub_efi_status_t __grub_efi_api
 efiemu_get_variable (grub_efi_char16_t *variable_name,
-		     const grub_guid_t *vendor_guid,
+		     const grub_efi_guid_t *vendor_guid,
 		     grub_efi_uint32_t *attributes,
 		     grub_efi_uintn_t *data_size,
 		     void *data);
@@ -74,11 +74,11 @@ efiemu_get_variable (grub_efi_char16_t *variable_name,
 grub_efi_status_t __grub_efi_api
 efiemu_get_next_variable_name (grub_efi_uintn_t *variable_name_size,
 			       grub_efi_char16_t *variable_name,
-			       grub_guid_t *vendor_guid);
+			       grub_efi_guid_t *vendor_guid);
 
 grub_efi_status_t __grub_efi_api
 efiemu_set_variable (grub_efi_char16_t *variable_name,
-		     const grub_guid_t *vendor_guid,
+		     const grub_efi_guid_t *vendor_guid,
 		     grub_efi_uint32_t attributes,
 		     grub_efi_uintn_t data_size,
 		     void *data);
@@ -416,7 +416,7 @@ EFI_FUNC (efiemu_convert_pointer) (grub_efi_uintn_t debug_disposition,
 
 /* Find variable by name and GUID. */
 static struct efi_variable *
-find_variable (const grub_guid_t *vendor_guid,
+find_variable (const grub_efi_guid_t *vendor_guid,
 	       grub_efi_char16_t *variable_name)
 {
   grub_uint8_t *ptr;
@@ -438,7 +438,7 @@ find_variable (const grub_guid_t *vendor_guid,
 
 grub_efi_status_t __grub_efi_api
 EFI_FUNC (efiemu_get_variable) (grub_efi_char16_t *variable_name,
-				const grub_guid_t *vendor_guid,
+				const grub_efi_guid_t *vendor_guid,
 				grub_efi_uint32_t *attributes,
 				grub_efi_uintn_t *data_size,
 				void *data)
@@ -464,7 +464,7 @@ EFI_FUNC (efiemu_get_variable) (grub_efi_char16_t *variable_name,
 grub_efi_status_t __grub_efi_api EFI_FUNC
 (efiemu_get_next_variable_name) (grub_efi_uintn_t *variable_name_size,
 				 grub_efi_char16_t *variable_name,
-				 grub_guid_t *vendor_guid)
+				 grub_efi_guid_t *vendor_guid)
 {
   struct efi_variable *efivar;
   LOG ('l');
@@ -503,7 +503,7 @@ grub_efi_status_t __grub_efi_api EFI_FUNC
 
 grub_efi_status_t __grub_efi_api
 EFI_FUNC (efiemu_set_variable) (grub_efi_char16_t *variable_name,
-				const grub_guid_t *vendor_guid,
+				const grub_efi_guid_t *vendor_guid,
 				grub_efi_uint32_t attributes,
 				grub_efi_uintn_t data_size,
 				void *data)
diff --git a/grub-core/kern/efi/acpi.c b/grub-core/kern/efi/acpi.c
index 461c77c33..74f8cd1a9 100644
--- a/grub-core/kern/efi/acpi.c
+++ b/grub-core/kern/efi/acpi.c
@@ -26,14 +26,14 @@ struct grub_acpi_rsdp_v10 *
 grub_machine_acpi_get_rsdpv1 (void)
 {
   unsigned i;
-  static grub_guid_t acpi_guid = GRUB_EFI_ACPI_TABLE_GUID;
+  static grub_efi_packed_guid_t acpi_guid = GRUB_EFI_ACPI_TABLE_GUID;
 
   for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
     {
-      grub_guid_t *guid =
+      grub_efi_packed_guid_t *guid =
 	&grub_efi_system_table->configuration_table[i].vendor_guid;
 
-      if (! grub_memcmp (guid, &acpi_guid, sizeof (grub_guid_t)))
+      if (! grub_memcmp (guid, &acpi_guid, sizeof (grub_efi_packed_guid_t)))
 	return (struct grub_acpi_rsdp_v10 *)
 	  grub_efi_system_table->configuration_table[i].vendor_table;
     }
@@ -44,14 +44,14 @@ struct grub_acpi_rsdp_v20 *
 grub_machine_acpi_get_rsdpv2 (void)
 {
   unsigned i;
-  static grub_guid_t acpi20_guid = GRUB_EFI_ACPI_20_TABLE_GUID;
+  static grub_efi_packed_guid_t acpi20_guid = GRUB_EFI_ACPI_20_TABLE_GUID;
 
   for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
     {
-      grub_guid_t *guid =
+      grub_efi_packed_guid_t *guid =
 	&grub_efi_system_table->configuration_table[i].vendor_guid;
 
-      if (! grub_memcmp (guid, &acpi20_guid, sizeof (grub_guid_t)))
+      if (! grub_memcmp (guid, &acpi20_guid, sizeof (grub_efi_packed_guid_t)))
 	return (struct grub_acpi_rsdp_v20 *)
 	  grub_efi_system_table->configuration_table[i].vendor_table;
     }
diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c
index 5e1c147a5..629ccb7b7 100644
--- a/grub-core/kern/efi/efi.c
+++ b/grub-core/kern/efi/efi.c
@@ -35,12 +35,12 @@ grub_efi_handle_t grub_efi_image_handle;
 /* The pointer to a system table. Filled in by the startup code.  */
 grub_efi_system_table_t *grub_efi_system_table;
 
-static grub_guid_t console_control_guid = GRUB_EFI_CONSOLE_CONTROL_GUID;
-static grub_guid_t loaded_image_guid = GRUB_EFI_LOADED_IMAGE_GUID;
-static grub_guid_t device_path_guid = GRUB_EFI_DEVICE_PATH_GUID;
+static grub_efi_guid_t console_control_guid = GRUB_EFI_CONSOLE_CONTROL_GUID;
+static grub_efi_guid_t loaded_image_guid = GRUB_EFI_LOADED_IMAGE_GUID;
+static grub_efi_guid_t device_path_guid = GRUB_EFI_DEVICE_PATH_GUID;
 
 void *
-grub_efi_locate_protocol (grub_guid_t *protocol, void *registration)
+grub_efi_locate_protocol (grub_efi_guid_t *protocol, void *registration)
 {
   void *interface;
   grub_efi_status_t status;
@@ -59,7 +59,7 @@ grub_efi_locate_protocol (grub_guid_t *protocol, void *registration)
    from the heap.  */
 grub_efi_handle_t *
 grub_efi_locate_handle (grub_efi_locate_search_type_t search_type,
-			grub_guid_t *protocol,
+			grub_efi_guid_t *protocol,
 			void *search_key,
 			grub_efi_uintn_t *num_handles)
 {
@@ -98,7 +98,7 @@ grub_efi_locate_handle (grub_efi_locate_search_type_t search_type,
 
 void *
 grub_efi_open_protocol (grub_efi_handle_t handle,
-			grub_guid_t *protocol,
+			grub_efi_guid_t *protocol,
 			grub_efi_uint32_t attributes)
 {
   grub_efi_boot_services_t *b;
@@ -119,7 +119,7 @@ grub_efi_open_protocol (grub_efi_handle_t handle,
 }
 
 grub_efi_status_t
-grub_efi_close_protocol (grub_efi_handle_t handle, grub_guid_t *protocol)
+grub_efi_close_protocol (grub_efi_handle_t handle, grub_efi_guid_t *protocol)
 {
   grub_efi_boot_services_t *b = grub_efi_system_table->boot_services;
 
@@ -203,7 +203,7 @@ grub_efi_set_virtual_address_map (grub_efi_uintn_t memory_map_size,
 }
 
 grub_err_t
-grub_efi_set_variable_with_attributes (const char *var, const grub_guid_t *guid,
+grub_efi_set_variable_with_attributes (const char *var, const grub_efi_guid_t *guid,
 		      void *data, grub_size_t datasize, grub_efi_uint32_t attributes)
 {
   grub_efi_status_t status;
@@ -226,7 +226,7 @@ grub_efi_set_variable_with_attributes (const char *var, const grub_guid_t *guid,
 }
 
 grub_err_t
-grub_efi_set_variable (const char *var, const grub_guid_t *guid,
+grub_efi_set_variable (const char *var, const grub_efi_guid_t *guid,
 		      void *data, grub_size_t datasize)
 {
   return grub_efi_set_variable_with_attributes (var, guid, data, datasize,
@@ -237,7 +237,7 @@ grub_efi_set_variable (const char *var, const grub_guid_t *guid,
 
 grub_efi_status_t
 grub_efi_get_variable_with_attributes (const char *var,
-				       const grub_guid_t *guid,
+				       const grub_efi_guid_t *guid,
 				       grub_size_t *datasize_out,
 				       void **data_out,
 				       grub_efi_uint32_t *attributes)
@@ -287,7 +287,7 @@ grub_efi_get_variable_with_attributes (const char *var,
 }
 
 grub_err_t
-grub_efi_set_variable_to_string (const char *name, const grub_guid_t *guid,
+grub_efi_set_variable_to_string (const char *name, const grub_efi_guid_t *guid,
 			         const char *value, grub_efi_uint32_t attributes)
 {
   grub_efi_char16_t *value_16;
@@ -309,7 +309,7 @@ grub_efi_set_variable_to_string (const char *name, const grub_guid_t *guid,
 }
 
 grub_efi_status_t
-grub_efi_get_variable (const char *var, const grub_guid_t *guid,
+grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid,
 		       grub_size_t *datasize_out, void **data_out)
 {
   return grub_efi_get_variable_with_attributes (var, guid, datasize_out, data_out, NULL);
diff --git a/grub-core/kern/efi/fdt.c b/grub-core/kern/efi/fdt.c
index 8fcf43f1b..24f955289 100644
--- a/grub-core/kern/efi/fdt.c
+++ b/grub-core/kern/efi/fdt.c
@@ -24,7 +24,7 @@ void *
 grub_efi_get_firmware_fdt (void)
 {
   grub_efi_configuration_table_t *tables;
-  static grub_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID;
+  static grub_efi_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID;
   void *firmware_fdt = NULL;
   unsigned int i;
 
diff --git a/grub-core/kern/efi/init.c b/grub-core/kern/efi/init.c
index 6fe1ff8c8..ae8c2e1e4 100644
--- a/grub-core/kern/efi/init.c
+++ b/grub-core/kern/efi/init.c
@@ -37,7 +37,7 @@ static grub_efi_char16_t stack_chk_fail_msg[] =
   L"* GRUB: ABORTED!!! *\r\n"
   L"* GRUB: REBOOTING IN 5 SECONDS... *\r\n";
 
-static grub_guid_t rng_protocol_guid = GRUB_EFI_RNG_PROTOCOL_GUID;
+static grub_efi_guid_t rng_protocol_guid = GRUB_EFI_RNG_PROTOCOL_GUID;
 
 /*
  * Don't put this on grub_efi_init()'s local stack to avoid it
diff --git a/grub-core/kern/efi/sb.c b/grub-core/kern/efi/sb.c
index 60550a6da..583002ae4 100644
--- a/grub-core/kern/efi/sb.c
+++ b/grub-core/kern/efi/sb.c
@@ -30,7 +30,7 @@
 #include <grub/types.h>
 #include <grub/verify.h>
 
-static grub_guid_t shim_lock_guid = GRUB_EFI_SHIM_LOCK_GUID;
+static grub_efi_guid_t shim_lock_guid = GRUB_EFI_SHIM_LOCK_GUID;
 
 static bool shim_lock_enabled = false;
 
@@ -43,7 +43,7 @@ static bool shim_lock_enabled = false;
 grub_uint8_t
 grub_efi_get_secureboot (void)
 {
-  static grub_guid_t efi_variable_guid = GRUB_EFI_GLOBAL_VARIABLE_GUID;
+  static grub_efi_guid_t efi_variable_guid = GRUB_EFI_GLOBAL_VARIABLE_GUID;
   grub_efi_status_t status;
   grub_efi_uint32_t attr = 0;
   grub_size_t size = 0;
diff --git a/grub-core/loader/efi/fdt.c b/grub-core/loader/efi/fdt.c
index 439964b9c..35a3be2e5 100644
--- a/grub-core/loader/efi/fdt.c
+++ b/grub-core/loader/efi/fdt.c
@@ -86,7 +86,7 @@ grub_err_t
 grub_fdt_install (void)
 {
   grub_efi_boot_services_t *b;
-  static grub_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID;
+  static grub_efi_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID;
   grub_efi_status_t status;
 
   if (fdt == NULL && loaded_fdt == NULL)
diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c
index bfbd95aee..ca69f4350 100644
--- a/grub-core/loader/efi/linux.c
+++ b/grub-core/loader/efi/linux.c
@@ -52,8 +52,8 @@ static struct grub_linux_initrd_context initrd_ctx = {0, 0, 0};
 static grub_efi_handle_t initrd_lf2_handle = NULL;
 static bool initrd_use_loadfile2 = false;
 
-static grub_guid_t load_file2_guid = GRUB_EFI_LOAD_FILE2_PROTOCOL_GUID;
-static grub_guid_t device_path_guid = GRUB_EFI_DEVICE_PATH_GUID;
+static grub_efi_guid_t load_file2_guid = GRUB_EFI_LOAD_FILE2_PROTOCOL_GUID;
+static grub_efi_guid_t device_path_guid = GRUB_EFI_DEVICE_PATH_GUID;
 
 static initrd_media_device_path_t initrd_lf2_device_path = {
   {
diff --git a/grub-core/loader/i386/xnu.c b/grub-core/loader/i386/xnu.c
index 93ba4476d..4c88ce5e0 100644
--- a/grub-core/loader/i386/xnu.c
+++ b/grub-core/loader/i386/xnu.c
@@ -48,7 +48,7 @@ grub_uint32_t grub_xnu_entry_point, grub_xnu_arg1, grub_xnu_stack;
 /* Aliases set for some tables. */
 struct tbl_alias
 {
-  grub_guid_t guid;
+  grub_efi_guid_t guid;
   const char *name;
 };
 
@@ -694,7 +694,7 @@ grub_cpu_xnu_fill_devicetree (grub_uint64_t *fsbfreq_out)
     {
       void *ptr;
       struct grub_xnu_devtree_key *curkey;
-      grub_guid_t guid;
+      grub_efi_packed_guid_t guid;
       char guidbuf[64];
 
       /* Retrieve current key. */
diff --git a/grub-core/loader/ia64/efi/linux.c b/grub-core/loader/ia64/efi/linux.c
index 3dd2e8236..fb9b961f7 100644
--- a/grub-core/loader/ia64/efi/linux.c
+++ b/grub-core/loader/ia64/efi/linux.c
@@ -106,7 +106,7 @@ query_fpswa (void)
   grub_efi_boot_services_t *bs;
   grub_efi_status_t status;
   grub_efi_uintn_t size;
-  static const grub_guid_t fpswa_protocol =
+  static const grub_efi_guid_t fpswa_protocol =
     { 0xc41b6531, 0x97b9, 0x11d3,
       {0x9a, 0x29, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} };
 
diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c
index 3ea25cf98..56a179709 100644
--- a/grub-core/net/drivers/efi/efinet.c
+++ b/grub-core/net/drivers/efi/efinet.c
@@ -27,8 +27,8 @@
 GRUB_MOD_LICENSE ("GPLv3+");
 
 /* GUID.  */
-static grub_guid_t net_io_guid = GRUB_EFI_SIMPLE_NETWORK_GUID;
-static grub_guid_t pxe_io_guid = GRUB_EFI_PXE_GUID;
+static grub_efi_guid_t net_io_guid = GRUB_EFI_SIMPLE_NETWORK_GUID;
+static grub_efi_guid_t pxe_io_guid = GRUB_EFI_PXE_GUID;
 
 static grub_err_t
 send_card_buffer (struct grub_net_card *dev,
diff --git a/grub-core/partmap/gpt.c b/grub-core/partmap/gpt.c
index 877ceefc3..075cc96f1 100644
--- a/grub-core/partmap/gpt.c
+++ b/grub-core/partmap/gpt.c
@@ -36,10 +36,10 @@ static grub_uint8_t grub_gpt_magic[8] =
     0x45, 0x46, 0x49, 0x20, 0x50, 0x41, 0x52, 0x54
   };
 
-static const grub_guid_t grub_gpt_partition_type_empty = GRUB_GPT_PARTITION_TYPE_EMPTY;
+static const grub_gpt_part_guid_t grub_gpt_partition_type_empty = GRUB_GPT_PARTITION_TYPE_EMPTY;
 
 #ifdef GRUB_UTIL
-static const grub_guid_t grub_gpt_partition_type_bios_boot = GRUB_GPT_PARTITION_TYPE_BIOS_BOOT;
+static const grub_gpt_part_guid_t grub_gpt_partition_type_bios_boot = GRUB_GPT_PARTITION_TYPE_BIOS_BOOT;
 #endif
 
 /* 512 << 7 = 65536 byte sectors.  */
diff --git a/grub-core/term/efi/console.c b/grub-core/term/efi/console.c
index bb587f39d..9a7bc0fcf 100644
--- a/grub-core/term/efi/console.c
+++ b/grub-core/term/efi/console.c
@@ -352,7 +352,7 @@ grub_console_getkeystatus (struct grub_term_input *term)
 static grub_err_t
 grub_efi_console_input_init (struct grub_term_input *term)
 {
-  static grub_guid_t text_input_ex_guid =
+  static grub_efi_guid_t text_input_ex_guid =
     GRUB_EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID;
 
   if (grub_efi_is_finished)
diff --git a/grub-core/term/efi/serial.c b/grub-core/term/efi/serial.c
index 5dfd2d86c..e86ebce3f 100644
--- a/grub-core/term/efi/serial.c
+++ b/grub-core/term/efi/serial.c
@@ -31,7 +31,7 @@
 #include <grub/i18n.h>
 
 /* GUID.  */
-static grub_guid_t serial_io_guid = GRUB_EFI_SERIAL_IO_GUID;
+static grub_efi_guid_t serial_io_guid = GRUB_EFI_SERIAL_IO_GUID;
 
 static void
 do_real_config (struct grub_serial_port *port)
diff --git a/grub-core/video/efi_gop.c b/grub-core/video/efi_gop.c
index 9452f5e58..68c9d58f9 100644
--- a/grub-core/video/efi_gop.c
+++ b/grub-core/video/efi_gop.c
@@ -32,10 +32,10 @@
 
 GRUB_MOD_LICENSE ("GPLv3+");
 
-static grub_guid_t graphics_output_guid = GRUB_EFI_GOP_GUID;
-static grub_guid_t active_edid_guid = GRUB_EFI_EDID_ACTIVE_GUID;
-static grub_guid_t discovered_edid_guid = GRUB_EFI_EDID_DISCOVERED_GUID;
-static grub_guid_t efi_var_guid = GRUB_EFI_GLOBAL_VARIABLE_GUID;
+static grub_efi_guid_t graphics_output_guid = GRUB_EFI_GOP_GUID;
+static grub_efi_guid_t active_edid_guid = GRUB_EFI_EDID_ACTIVE_GUID;
+static grub_efi_guid_t discovered_edid_guid = GRUB_EFI_EDID_DISCOVERED_GUID;
+static grub_efi_guid_t efi_var_guid = GRUB_EFI_GLOBAL_VARIABLE_GUID;
 static struct grub_efi_gop *gop;
 static unsigned old_mode;
 static int restore_needed;
diff --git a/grub-core/video/efi_uga.c b/grub-core/video/efi_uga.c
index d53079e0b..aa4659b8e 100644
--- a/grub-core/video/efi_uga.c
+++ b/grub-core/video/efi_uga.c
@@ -32,7 +32,7 @@
 
 GRUB_MOD_LICENSE ("GPLv3+");
 
-static grub_guid_t uga_draw_guid = GRUB_EFI_UGA_DRAW_GUID;
+static grub_efi_guid_t uga_draw_guid = GRUB_EFI_UGA_DRAW_GUID;
 static struct grub_efi_uga_draw_protocol *uga;
 static grub_uint64_t uga_fb;
 static grub_uint32_t uga_pitch;
diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h
index d3eaef3fb..b846c2e5d 100644
--- a/include/grub/efi/api.h
+++ b/include/grub/efi/api.h
@@ -644,6 +644,24 @@ typedef grub_uint8_t grub_efi_ip_address_t[8] __attribute__ ((aligned(4)));
 typedef grub_efi_uint64_t grub_efi_physical_address_t;
 typedef grub_efi_uint64_t grub_efi_virtual_address_t;
 
+struct grub_efi_guid
+{
+  grub_uint32_t data1;
+  grub_uint16_t data2;
+  grub_uint16_t data3;
+  grub_uint8_t data4[8];
+} __attribute__ ((aligned(8)));
+typedef struct grub_efi_guid grub_efi_guid_t;
+
+struct grub_efi_packed_guid
+{
+  grub_uint32_t data1;
+  grub_uint16_t data2;
+  grub_uint16_t data3;
+  grub_uint8_t data4[8];
+} GRUB_PACKED;
+typedef struct grub_efi_packed_guid grub_efi_packed_guid_t;
+
 /* XXX although the spec does not specify the padding, this actually
    must have the padding!  */
 struct grub_efi_memory_descriptor
@@ -730,7 +748,7 @@ typedef struct grub_efi_memory_mapped_device_path grub_efi_memory_mapped_device_
 struct grub_efi_vendor_device_path
 {
   grub_efi_device_path_t header;
-  grub_guid_t vendor_guid;
+  grub_efi_packed_guid_t vendor_guid;
   grub_efi_uint8_t vendor_defined_data[0];
 } GRUB_PACKED;
 typedef struct grub_efi_vendor_device_path grub_efi_vendor_device_path_t;
@@ -974,7 +992,7 @@ typedef struct grub_efi_cdrom_device_path grub_efi_cdrom_device_path_t;
 struct grub_efi_vendor_media_device_path
 {
   grub_efi_device_path_t header;
-  grub_guid_t vendor_guid;
+  grub_efi_packed_guid_t vendor_guid;
   grub_efi_uint8_t vendor_defined_data[0];
 } GRUB_PACKED;
 typedef struct grub_efi_vendor_media_device_path grub_efi_vendor_media_device_path_t;
@@ -993,7 +1011,7 @@ typedef struct grub_efi_file_path_device_path grub_efi_file_path_device_path_t;
 struct grub_efi_protocol_device_path
 {
   grub_efi_device_path_t header;
-  grub_guid_t guid;
+  grub_efi_packed_guid_t guid;
 } GRUB_PACKED;
 typedef struct grub_efi_protocol_device_path grub_efi_protocol_device_path_t;
 
@@ -1002,7 +1020,7 @@ typedef struct grub_efi_protocol_device_path grub_efi_protocol_device_path_t;
 struct grub_efi_piwg_device_path
 {
   grub_efi_device_path_t header;
-  grub_guid_t guid;
+  grub_efi_packed_guid_t guid;
 } GRUB_PACKED;
 typedef struct grub_efi_piwg_device_path grub_efi_piwg_device_path_t;
 
@@ -1173,47 +1191,47 @@ struct grub_efi_boot_services
 
   grub_efi_status_t
   (__grub_efi_api *install_protocol_interface) (grub_efi_handle_t *handle,
-						grub_guid_t *protocol,
+						grub_efi_guid_t *protocol,
 						grub_efi_interface_type_t protocol_interface_type,
 						void *protocol_interface);
 
   grub_efi_status_t
   (__grub_efi_api *reinstall_protocol_interface) (grub_efi_handle_t handle,
-						  grub_guid_t *protocol,
+						  grub_efi_guid_t *protocol,
 						  void *old_interface,
 						  void *new_interface);
 
   grub_efi_status_t
   (__grub_efi_api *uninstall_protocol_interface) (grub_efi_handle_t handle,
-						  grub_guid_t *protocol,
+						  grub_efi_guid_t *protocol,
 						  void *protocol_interface);
 
   grub_efi_status_t
   (__grub_efi_api *handle_protocol) (grub_efi_handle_t handle,
-				     grub_guid_t *protocol,
+				     grub_efi_guid_t *protocol,
 				     void **protocol_interface);
 
   void *reserved;
 
   grub_efi_status_t
-  (__grub_efi_api *register_protocol_notify) (grub_guid_t *protocol,
+  (__grub_efi_api *register_protocol_notify) (grub_efi_guid_t *protocol,
 					      grub_efi_event_t event,
 					      void **registration);
 
   grub_efi_status_t
   (__grub_efi_api *locate_handle) (grub_efi_locate_search_type_t search_type,
-				   grub_guid_t *protocol,
+				   grub_efi_guid_t *protocol,
 				   void *search_key,
 				   grub_efi_uintn_t *buffer_size,
 				   grub_efi_handle_t *buffer);
 
   grub_efi_status_t
-  (__grub_efi_api *locate_device_path) (grub_guid_t *protocol,
+  (__grub_efi_api *locate_device_path) (grub_efi_guid_t *protocol,
 					grub_efi_device_path_t **device_path,
 					grub_efi_handle_t *device);
 
   grub_efi_status_t
-  (__grub_efi_api *install_configuration_table) (grub_guid_t *guid,
+  (__grub_efi_api *install_configuration_table) (grub_efi_guid_t *guid,
 						 void *table);
 
   grub_efi_status_t
@@ -1267,7 +1285,7 @@ struct grub_efi_boot_services
 
   grub_efi_status_t
   (__grub_efi_api *open_protocol) (grub_efi_handle_t handle,
-				   grub_guid_t *protocol,
+				   grub_efi_guid_t *protocol,
 				   void **protocol_interface,
 				   grub_efi_handle_t agent_handle,
 				   grub_efi_handle_t controller_handle,
@@ -1275,30 +1293,30 @@ struct grub_efi_boot_services
 
   grub_efi_status_t
   (__grub_efi_api *close_protocol) (grub_efi_handle_t handle,
-				    grub_guid_t *protocol,
+				    grub_efi_guid_t *protocol,
 				    grub_efi_handle_t agent_handle,
 				    grub_efi_handle_t controller_handle);
 
   grub_efi_status_t
   (__grub_efi_api *open_protocol_information) (grub_efi_handle_t handle,
-					       grub_guid_t *protocol,
+					       grub_efi_guid_t *protocol,
 					       grub_efi_open_protocol_information_entry_t **entry_buffer,
 					       grub_efi_uintn_t *entry_count);
 
   grub_efi_status_t
   (__grub_efi_api *protocols_per_handle) (grub_efi_handle_t handle,
-					  grub_guid_t ***protocol_buffer,
+					  grub_efi_packed_guid_t ***protocol_buffer,
 					  grub_efi_uintn_t *protocol_buffer_count);
 
   grub_efi_status_t
   (__grub_efi_api *locate_handle_buffer) (grub_efi_locate_search_type_t search_type,
-					  grub_guid_t *protocol,
+					  grub_efi_guid_t *protocol,
 					  void *search_key,
 					  grub_efi_uintn_t *no_handles,
 					  grub_efi_handle_t **buffer);
 
   grub_efi_status_t
-  (__grub_efi_api *locate_protocol) (grub_guid_t *protocol,
+  (__grub_efi_api *locate_protocol) (grub_efi_guid_t *protocol,
 				     void *registration,
 				     void **protocol_interface);
 
@@ -1356,7 +1374,7 @@ struct grub_efi_runtime_services
 
   grub_efi_status_t
   (__grub_efi_api *get_variable) (grub_efi_char16_t *variable_name,
-				  const grub_guid_t *vendor_guid,
+				  const grub_efi_guid_t *vendor_guid,
 				  grub_efi_uint32_t *attributes,
 				  grub_efi_uintn_t *data_size,
 				  void *data);
@@ -1364,11 +1382,11 @@ struct grub_efi_runtime_services
   grub_efi_status_t
   (__grub_efi_api *get_next_variable_name) (grub_efi_uintn_t *variable_name_size,
 					    grub_efi_char16_t *variable_name,
-					    grub_guid_t *vendor_guid);
+					    grub_efi_guid_t *vendor_guid);
 
   grub_efi_status_t
   (__grub_efi_api *set_variable) (grub_efi_char16_t *variable_name,
-				  const grub_guid_t *vendor_guid,
+				  const grub_efi_guid_t *vendor_guid,
 				  grub_efi_uint32_t attributes,
 				  grub_efi_uintn_t data_size,
 				  void *data);
@@ -1386,7 +1404,7 @@ typedef struct grub_efi_runtime_services grub_efi_runtime_services_t;
 
 struct grub_efi_configuration_table
 {
-  grub_guid_t vendor_guid;
+  grub_efi_packed_guid_t vendor_guid;
   void *vendor_table;
 } GRUB_PACKED;
 typedef struct grub_efi_configuration_table grub_efi_configuration_table_t;
@@ -1785,7 +1803,7 @@ struct grub_efi_shim_lock_protocol
 };
 typedef struct grub_efi_shim_lock_protocol grub_efi_shim_lock_protocol_t;
 
-typedef grub_guid_t grub_efi_rng_algorithm_t;
+typedef grub_efi_guid_t grub_efi_rng_algorithm_t;
 
 struct grub_efi_rng_protocol
 {
diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h
index 572f7135f..bf9e7f275 100644
--- a/include/grub/efi/efi.h
+++ b/include/grub/efi/efi.h
@@ -37,18 +37,18 @@ struct linux_arch_kernel_header {
 };
 
 /* Functions.  */
-void *EXPORT_FUNC(grub_efi_locate_protocol) (grub_guid_t *protocol,
+void *EXPORT_FUNC(grub_efi_locate_protocol) (grub_efi_guid_t *protocol,
 					     void *registration);
 grub_efi_handle_t *
 EXPORT_FUNC(grub_efi_locate_handle) (grub_efi_locate_search_type_t search_type,
-				     grub_guid_t *protocol,
+				     grub_efi_guid_t *protocol,
 				     void *search_key,
 				     grub_efi_uintn_t *num_handles);
 void *EXPORT_FUNC(grub_efi_open_protocol) (grub_efi_handle_t handle,
-					   grub_guid_t *protocol,
+					   grub_efi_guid_t *protocol,
 					   grub_efi_uint32_t attributes);
 grub_efi_status_t
-EXPORT_FUNC(grub_efi_close_protocol) (grub_efi_handle_t handle, grub_guid_t *protocol);
+EXPORT_FUNC(grub_efi_close_protocol) (grub_efi_handle_t handle, grub_efi_guid_t *protocol);
 int EXPORT_FUNC(grub_efi_set_text_mode) (int on);
 void EXPORT_FUNC(grub_efi_stall) (grub_efi_uintn_t microseconds);
 void *
@@ -89,27 +89,27 @@ grub_err_t EXPORT_FUNC (grub_efi_set_virtual_address_map) (grub_efi_uintn_t memo
 							   grub_efi_uint32_t descriptor_version,
 							   grub_efi_memory_descriptor_t *virtual_map);
 grub_efi_status_t EXPORT_FUNC (grub_efi_get_variable_with_attributes) (const char *variable,
-								       const grub_guid_t *guid,
+								       const grub_efi_guid_t *guid,
 								       grub_size_t *datasize_out,
 								       void **data_out,
 								       grub_efi_uint32_t *attributes);
 grub_efi_status_t EXPORT_FUNC (grub_efi_get_variable) (const char *variable,
-						       const grub_guid_t *guid,
+						       const grub_efi_guid_t *guid,
 						       grub_size_t *datasize_out,
 						       void **data_out);
 grub_err_t
 EXPORT_FUNC (grub_efi_set_variable_with_attributes) (const char *var,
-				     const grub_guid_t *guid,
+				     const grub_efi_guid_t *guid,
 				     void *data,
 				     grub_size_t datasize,
 				     grub_efi_uint32_t attributes);
 grub_err_t
 EXPORT_FUNC (grub_efi_set_variable) (const char *var,
-				     const grub_guid_t *guid,
+				     const grub_efi_guid_t *guid,
 				     void *data,
 				     grub_size_t datasize);
 grub_err_t
-EXPORT_FUNC (grub_efi_set_variable_to_string) (const char *name, const grub_guid_t *guid,
+EXPORT_FUNC (grub_efi_set_variable_to_string) (const char *name, const grub_efi_guid_t *guid,
 					       const char *value, grub_efi_uint32_t attributes);
 int
 EXPORT_FUNC (grub_efi_compare_device_paths) (const grub_efi_device_path_t *dp1,
diff --git a/include/grub/efiemu/efiemu.h b/include/grub/efiemu/efiemu.h
index caf0b505f..5325e5839 100644
--- a/include/grub/efiemu/efiemu.h
+++ b/include/grub/efiemu/efiemu.h
@@ -176,26 +176,26 @@ grub_err_t grub_efiemu_loadcore_load (void);
 struct grub_efiemu_configuration_table
 {
   struct grub_efiemu_configuration_table *next;
-  grub_guid_t guid;
+  grub_efi_guid_t guid;
   void * (*get_table) (void *data);
   void (*unload) (void *data);
   void *data;
 };
 struct grub_efiemu_configuration_table32
 {
-  grub_guid_t vendor_guid;
+  grub_efi_packed_guid_t vendor_guid;
   grub_efi_uint32_t vendor_table;
 } GRUB_PACKED;
 typedef struct grub_efiemu_configuration_table32 grub_efiemu_configuration_table32_t;
 struct grub_efiemu_configuration_table64
 {
-  grub_guid_t vendor_guid;
+  grub_efi_packed_guid_t vendor_guid;
   grub_efi_uint64_t vendor_table;
 } GRUB_PACKED;
 typedef struct grub_efiemu_configuration_table64 grub_efiemu_configuration_table64_t;
-grub_err_t grub_efiemu_unregister_configuration_table (grub_guid_t guid);
+grub_err_t grub_efiemu_unregister_configuration_table (grub_efi_guid_t guid);
 grub_err_t
-grub_efiemu_register_configuration_table (grub_guid_t guid,
+grub_efiemu_register_configuration_table (grub_efi_guid_t guid,
 					  void * (*get_table) (void *data),
 					  void (*unload) (void *data),
 					  void *data);
diff --git a/include/grub/efiemu/runtime.h b/include/grub/efiemu/runtime.h
index c9ad9fdfa..36d2dedf4 100644
--- a/include/grub/efiemu/runtime.h
+++ b/include/grub/efiemu/runtime.h
@@ -29,7 +29,7 @@ struct grub_efiemu_ptv_rel
 
 struct efi_variable
 {
-  grub_guid_t guid;
+  grub_efi_packed_guid_t guid;
   grub_uint32_t namelen;
   grub_uint32_t size;
   grub_efi_uint32_t attributes;
diff --git a/include/grub/gpt_partition.h b/include/grub/gpt_partition.h
index 020e71920..7a93f4329 100644
--- a/include/grub/gpt_partition.h
+++ b/include/grub/gpt_partition.h
@@ -22,6 +22,15 @@
 #include <grub/types.h>
 #include <grub/partition.h>
 
+struct grub_gpt_part_guid
+{
+  grub_uint32_t data1;
+  grub_uint16_t data2;
+  grub_uint16_t data3;
+  grub_uint8_t data4[8];
+} GRUB_PACKED;
+typedef struct grub_gpt_part_guid grub_gpt_part_guid_t;
+
 #define GRUB_GPT_PARTITION_TYPE_EMPTY \
   { 0x0, 0x0, 0x0, \
     { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } \
@@ -61,8 +70,8 @@ struct grub_gpt_header
 
 struct grub_gpt_partentry
 {
-  grub_guid_t type;
-  grub_guid_t guid;
+  grub_gpt_part_guid_t type;
+  grub_gpt_part_guid_t guid;
   grub_uint64_t start;
   grub_uint64_t end;
   grub_uint64_t attrib;
diff --git a/include/grub/types.h b/include/grub/types.h
index 0d96006fe..756a29a08 100644
--- a/include/grub/types.h
+++ b/include/grub/types.h
@@ -370,13 +370,4 @@ static inline void grub_set_unaligned64 (void *ptr, grub_uint64_t val)
 # define grub_absolute_pointer(val) ((void *) (val))
 #endif
 
-struct grub_guid
-{
-  grub_uint32_t data1;
-  grub_uint16_t data2;
-  grub_uint16_t data3;
-  grub_uint8_t data4[8];
-} GRUB_PACKED;
-typedef struct grub_guid grub_guid_t;
-
 #endif /* ! GRUB_TYPES_HEADER */
diff --git a/util/grub-install.c b/util/grub-install.c
index 1ad04db36..e20820d9e 100644
--- a/util/grub-install.c
+++ b/util/grub-install.c
@@ -728,7 +728,7 @@ is_prep_partition (grub_device_t dev)
       if (grub_disk_read (dev->disk, p->offset, p->index,
 			  sizeof (gptdata), &gptdata) == 0)
 	{
-	  const grub_guid_t template = {
+	  const grub_gpt_part_guid_t template = {
 	    grub_cpu_to_le32_compile_time (0x9e1a2d38),
 	    grub_cpu_to_le16_compile_time (0xc612),
 	    grub_cpu_to_le16_compile_time (0x4316),
diff --git a/util/grub-probe.c b/util/grub-probe.c
index 65c1ca3f8..446bd2553 100644
--- a/util/grub-probe.c
+++ b/util/grub-probe.c
@@ -133,7 +133,7 @@ get_targets_string (void)
 }
 
 static int
-print_gpt_guid (grub_guid_t guid)
+print_gpt_guid (grub_gpt_part_guid_t guid)
 {
   guid.data1 = grub_le_to_cpu32 (guid.data1);
   guid.data2 = grub_le_to_cpu16 (guid.data2);
-- 
2.41.0


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

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

* Re: [PATCH 1/4] bli: don't use %pG format specifier
  2023-10-05 10:47 ` [PATCH 1/4] bli: don't use %pG format specifier Oliver Steffen
@ 2023-10-05 14:24   ` Laszlo Ersek
  0 siblings, 0 replies; 10+ messages in thread
From: Laszlo Ersek @ 2023-10-05 14:24 UTC (permalink / raw)
  To: Oliver Steffen, grub-devel
  Cc: Daniel Kiper, Gerd Hoffmann, Tobias Powalowski,
	Pedro Miguel Justo, Frank Scheiner,
	Vladimir 'phcoder' Serbinenko, John Paul Adrian Glaubitz,
	Ard Biesheuvel

On 10/5/23 12:47, Oliver Steffen wrote:
> We are about to revert the unified GUID type and it's printf format
> specifier, so do use the explicit printf statement for the partition
> UUID here instread.
> 
> Signed-off-by: Oliver Steffen <osteffen@redhat.com>
> ---
>  grub-core/commands/bli.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/grub-core/commands/bli.c b/grub-core/commands/bli.c
> index e0d8a54f7..2a3933925 100644
> --- a/grub-core/commands/bli.c
> +++ b/grub-core/commands/bli.c
> @@ -70,7 +70,14 @@ get_part_uuid (const char *device_name, char **part_uuid)
>        goto fail;
>      }
>  
> -  *part_uuid = grub_xasprintf ("%pG", &entry.guid);
> +  *part_uuid = grub_xasprintf (
> +		 "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
> +		 grub_le_to_cpu32 (entry.guid.data1),
> +		 grub_le_to_cpu16 (entry.guid.data2),
> +		 grub_le_to_cpu16 (entry.guid.data3),
> +		 entry.guid.data4[0], entry.guid.data4[1], entry.guid.data4[2],
> +		 entry.guid.data4[3], entry.guid.data4[4], entry.guid.data4[5],
> +		 entry.guid.data4[6], entry.guid.data4[7]);
>    if (*part_uuid == NULL)
>      status = grub_errno;
>  

Reviewed-by: Laszlo Ersek <lersek@redhat.com>


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

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

* Re: [PATCH 2/4] Revert "guid: Make use of GUID printf format specifier"
  2023-10-05 10:47 ` [PATCH 2/4] Revert "guid: Make use of GUID printf format specifier" Oliver Steffen
@ 2023-10-05 14:28   ` Laszlo Ersek
  0 siblings, 0 replies; 10+ messages in thread
From: Laszlo Ersek @ 2023-10-05 14:28 UTC (permalink / raw)
  To: Oliver Steffen, grub-devel
  Cc: Daniel Kiper, Gerd Hoffmann, Tobias Powalowski,
	Pedro Miguel Justo, Frank Scheiner,
	Vladimir 'phcoder' Serbinenko, John Paul Adrian Glaubitz,
	Ard Biesheuvel

On 10/5/23 12:47, Oliver Steffen wrote:
> This reverts commit 6ad116e5ff459ae06eb993d386da5e7589242667.
> 
> Signed-off-by: Oliver Steffen <osteffen@redhat.com>
> ---
>  grub-core/commands/efi/lsefi.c       | 13 ++++++++++++-
>  grub-core/commands/efi/lsefisystab.c |  6 +++++-
>  grub-core/commands/probe.c           | 12 ++++++++----
>  grub-core/kern/efi/efi.c             | 28 ++++++++++++++++++++++++++--
>  grub-core/loader/i386/xnu.c          |  9 +++++++--
>  5 files changed, 58 insertions(+), 10 deletions(-)
> 
> diff --git a/grub-core/commands/efi/lsefi.c b/grub-core/commands/efi/lsefi.c
> index 05e2e511e..6935cd302 100644
> --- a/grub-core/commands/efi/lsefi.c
> +++ b/grub-core/commands/efi/lsefi.c
> @@ -124,7 +124,18 @@ grub_cmd_lsefi (grub_command_t cmd __attribute__ ((unused)),
>  	  if (k < ARRAY_SIZE (known_protocols))
>  	    grub_printf ("  %s\n", known_protocols[k].name);
>  	  else
> -	    grub_printf ("  %pG\n", protocols[j]);
> +	    grub_printf ("  %08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x\n",
> +			 protocols[j]->data1,
> +			 protocols[j]->data2,
> +			 protocols[j]->data3,
> +			 (unsigned) protocols[j]->data4[0],
> +			 (unsigned) protocols[j]->data4[1],
> +			 (unsigned) protocols[j]->data4[2],
> +			 (unsigned) protocols[j]->data4[3],
> +			 (unsigned) protocols[j]->data4[4],
> +			 (unsigned) protocols[j]->data4[5],
> +			 (unsigned) protocols[j]->data4[6],
> +			 (unsigned) protocols[j]->data4[7]);
>  	}
>  
>      }
> diff --git a/grub-core/commands/efi/lsefisystab.c b/grub-core/commands/efi/lsefisystab.c
> index 79ccee12a..eff8c41f3 100644
> --- a/grub-core/commands/efi/lsefisystab.c
> +++ b/grub-core/commands/efi/lsefisystab.c
> @@ -96,7 +96,11 @@ grub_cmd_lsefisystab (struct grub_command *cmd __attribute__ ((unused)),
>  
>        grub_printf ("%p  ", t->vendor_table);
>  
> -      grub_printf ("%pG", &t->vendor_guid);
> +      grub_printf ("%08x-%04x-%04x-",
> +		   t->vendor_guid.data1, t->vendor_guid.data2,
> +		   t->vendor_guid.data3);
> +      for (j = 0; j < 8; j++)
> +	grub_printf ("%02x", t->vendor_guid.data4[j]);
>  
>        for (j = 0; j < ARRAY_SIZE (guid_mappings); j++)
>  	if (grub_memcmp (&guid_mappings[j].guid, &t->vendor_guid,
> diff --git a/grub-core/commands/probe.c b/grub-core/commands/probe.c
> index be9637f33..cc8c05586 100644
> --- a/grub-core/commands/probe.c
> +++ b/grub-core/commands/probe.c
> @@ -130,10 +130,14 @@ grub_cmd_probe (grub_extcmd_context_t ctxt, int argc, char **args)
>  		  return grub_errno;
>  		}
>  	      guid = &entry.guid;
> -	      guid->data1 = grub_le_to_cpu32 (guid->data1);
> -	      guid->data2 = grub_le_to_cpu16 (guid->data2);
> -	      guid->data3 = grub_le_to_cpu16 (guid->data3);
> -	      grub_snprintf (val, sizeof(val), "%pG", guid);
> +	      grub_snprintf (val, sizeof(val),
> +			     "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
> +			     grub_le_to_cpu32 (guid->data1),
> +			     grub_le_to_cpu16 (guid->data2),
> +			     grub_le_to_cpu16 (guid->data3),
> +			     guid->data4[0], guid->data4[1], guid->data4[2],
> +			     guid->data4[3], guid->data4[4], guid->data4[5],
> +			     guid->data4[6], guid->data4[7]);
>  	    }
>  	  else if (grub_strcmp(dev->disk->partition->partmap->name, "msdos") == 0)
>  	    {
> diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c
> index a2afd8de9..5e1c147a5 100644
> --- a/grub-core/kern/efi/efi.c
> +++ b/grub-core/kern/efi/efi.c
> @@ -558,7 +558,20 @@ static void
>  dump_vendor_path (const char *type, grub_efi_vendor_device_path_t *vendor)
>  {
>    grub_uint32_t vendor_data_len = vendor->header.length - sizeof (*vendor);
> -  grub_printf ("/%sVendor(%pG)[%x: ", type, &vendor->vendor_guid, vendor_data_len);
> +  grub_printf ("/%sVendor(%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x)[%x: ",
> +	       type,
> +	       (unsigned) vendor->vendor_guid.data1,
> +	       (unsigned) vendor->vendor_guid.data2,
> +	       (unsigned) vendor->vendor_guid.data3,
> +	       (unsigned) vendor->vendor_guid.data4[0],
> +	       (unsigned) vendor->vendor_guid.data4[1],
> +	       (unsigned) vendor->vendor_guid.data4[2],
> +	       (unsigned) vendor->vendor_guid.data4[3],
> +	       (unsigned) vendor->vendor_guid.data4[4],
> +	       (unsigned) vendor->vendor_guid.data4[5],
> +	       (unsigned) vendor->vendor_guid.data4[6],
> +	       (unsigned) vendor->vendor_guid.data4[7],
> +	       vendor_data_len);
>    if (vendor->header.length > sizeof (*vendor))
>      {
>        grub_uint32_t i;
> @@ -929,7 +942,18 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
>  	      {
>  		grub_efi_protocol_device_path_t *proto
>  		  = (grub_efi_protocol_device_path_t *) dp;
> -		grub_printf ("/Protocol(%pG)",&proto->guid);
> +		grub_printf ("/Protocol(%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x)",
> +			     (unsigned) proto->guid.data1,
> +			     (unsigned) proto->guid.data2,
> +			     (unsigned) proto->guid.data3,
> +			     (unsigned) proto->guid.data4[0],
> +			     (unsigned) proto->guid.data4[1],
> +			     (unsigned) proto->guid.data4[2],
> +			     (unsigned) proto->guid.data4[3],
> +			     (unsigned) proto->guid.data4[4],
> +			     (unsigned) proto->guid.data4[5],
> +			     (unsigned) proto->guid.data4[6],
> +			     (unsigned) proto->guid.data4[7]);
>  	      }
>  	      break;
>  	    default:
> diff --git a/grub-core/loader/i386/xnu.c b/grub-core/loader/i386/xnu.c
> index 4e31ce99a..93ba4476d 100644
> --- a/grub-core/loader/i386/xnu.c
> +++ b/grub-core/loader/i386/xnu.c
> @@ -726,8 +726,13 @@ grub_cpu_xnu_fill_devicetree (grub_uint64_t *fsbfreq_out)
>  #endif
>  
>        /* The name of key for new table. */
> -      grub_snprintf (guidbuf, sizeof (guidbuf), "%pG", &guid);
> -
> +      grub_snprintf (guidbuf, sizeof (guidbuf), "%08x-%04x-%04x-%02x%02x-",
> +		     guid.data1, guid.data2, guid.data3, guid.data4[0],
> +		     guid.data4[1]);
> +      for (j = 2; j < 8; j++)
> +	grub_snprintf (guidbuf + grub_strlen (guidbuf),
> +		       sizeof (guidbuf) - grub_strlen (guidbuf),
> +		       "%02x", guid.data4[j]);
>        /* For some reason GUID has to be in uppercase. */
>        for (j = 0; guidbuf[j] ; j++)
>  	if (guidbuf[j] >= 'a' && guidbuf[j] <= 'f')

Acked-by: Laszlo Ersek <lersek@redhat.com>


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

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

* Re: [PATCH 3/4] Revert "kern/misc: Add a format specifier GUIDs"
  2023-10-05 10:47 ` [PATCH 3/4] Revert "kern/misc: Add a format specifier GUIDs" Oliver Steffen
@ 2023-10-05 14:29   ` Laszlo Ersek
  0 siblings, 0 replies; 10+ messages in thread
From: Laszlo Ersek @ 2023-10-05 14:29 UTC (permalink / raw)
  To: Oliver Steffen, grub-devel
  Cc: Daniel Kiper, Gerd Hoffmann, Tobias Powalowski,
	Pedro Miguel Justo, Frank Scheiner,
	Vladimir 'phcoder' Serbinenko, John Paul Adrian Glaubitz,
	Ard Biesheuvel

On 10/5/23 12:47, Oliver Steffen wrote:
> This reverts commit f82dbf2bd871e9cce327b511a393ffa543d7f69e.
> 
> Signed-off-by: Oliver Steffen <osteffen@redhat.com>
> ---
>  grub-core/kern/misc.c | 81 +++++++++++--------------------------------
>  1 file changed, 21 insertions(+), 60 deletions(-)
> 
> diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c
> index b57249acb..0854fefc0 100644
> --- a/grub-core/kern/misc.c
> +++ b/grub-core/kern/misc.c
> @@ -24,7 +24,6 @@
>  #include <grub/term.h>
>  #include <grub/env.h>
>  #include <grub/i18n.h>
> -#include <grub/types.h>
>  #include <grub/charset.h>
>  
>  union printf_arg
> @@ -36,8 +35,7 @@ union printf_arg
>      {
>        INT, LONG, LONGLONG,
>        UNSIGNED_INT = 3, UNSIGNED_LONG, UNSIGNED_LONGLONG,
> -      STRING,
> -      GUID
> +      STRING
>      } type;
>    long long ll;
>  };
> @@ -781,9 +779,6 @@ parse_printf_arg_fmt (const char *fmt0, struct printf_args *args,
>        switch (c)
>  	{
>  	case 'p':
> -	  if (*(fmt) == 'G')
> -	    ++fmt;
> -	  /* Fall through. */
>  	case 'x':
>  	case 'X':
>  	case 'u':
> @@ -899,10 +894,6 @@ parse_printf_arg_fmt (const char *fmt0, struct printf_args *args,
>  	    args->ptr[curn].type = UNSIGNED_LONGLONG;
>  	  else
>  	    args->ptr[curn].type = UNSIGNED_INT;
> -	  if (*(fmt) == 'G') {
> -	    args->ptr[curn].type = GUID;
> -	    ++fmt;
> -	  }
>  	  break;
>  	case 's':
>  	  args->ptr[curn].type = STRING;
> @@ -944,7 +935,6 @@ parse_printf_args (const char *fmt0, struct printf_args *args, va_list args_in)
>  	args->ptr[n].ll = va_arg (args_in, long long);
>  	break;
>        case STRING:
> -      case GUID:
>  	if (sizeof (void *) == sizeof (long long))
>  	  args->ptr[n].ll = va_arg (args_in, long long);
>  	else
> @@ -962,27 +952,6 @@ write_char (char *str, grub_size_t *count, grub_size_t max_len, unsigned char ch
>    (*count)++;
>  }
>  
> -static void
> -write_number (char *str, grub_size_t *count, grub_size_t max_len, grub_size_t format1,
> -	     char rightfill, char zerofill, char c, long long value)
> -{
> -  char tmp[32];
> -  const char *p = tmp;
> -  grub_size_t len;
> -  grub_size_t fill;
> -
> -  len = grub_lltoa (tmp, c, value) - tmp;
> -  fill = len < format1 ? format1 - len : 0;
> -  if (! rightfill)
> -    while (fill--)
> -      write_char (str, count, max_len, zerofill);
> -  while (*p)
> -    write_char (str, count, max_len, *p++);
> -  if (rightfill)
> -    while (fill--)
> -      write_char (str, count, max_len, zerofill);
> -}
> -
>  static int
>  grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0,
>  		     struct printf_args *args)
> @@ -1065,40 +1034,32 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0,
>        switch (c)
>  	{
>  	case 'p':
> -	  if (*(fmt) == 'G')
> -	    {
> -	      ++fmt;
> -	      grub_guid_t *guid = (grub_guid_t *)(grub_addr_t) curarg;
> -	      write_number (str, &count, max_len, 8, 0, '0', 'x', guid->data1);
> -	      write_char (str, &count, max_len, '-');
> -	      write_number (str, &count, max_len, 4, 0, '0', 'x', guid->data2);
> -	      write_char (str, &count, max_len, '-');
> -	      write_number (str, &count, max_len, 4, 0, '0', 'x', guid->data3);
> -	      write_char (str, &count, max_len, '-');
> -	      write_number (str, &count, max_len, 2, 0, '0', 'x', guid->data4[0]);
> -	      write_number (str, &count, max_len, 2, 0, '0', 'x', guid->data4[1]);
> -	      write_char (str, &count, max_len, '-');
> -	      write_number (str, &count, max_len, 2, 0, '0', 'x', guid->data4[2]);
> -	      write_number (str, &count, max_len, 2, 0, '0', 'x', guid->data4[3]);
> -	      write_number (str, &count, max_len, 2, 0, '0', 'x', guid->data4[4]);
> -	      write_number (str, &count, max_len, 2, 0, '0', 'x', guid->data4[5]);
> -	      write_number (str, &count, max_len, 2, 0, '0', 'x', guid->data4[6]);
> -	      write_number (str, &count, max_len, 2, 0, '0', 'x', guid->data4[7]);
> -	      break;
> -	    }
> -	  else
> -	    {
> -	      write_char (str, &count, max_len, '0');
> -	      write_char (str, &count, max_len, 'x');
> -	      c = 'x';
> -	    }
> +	  write_char (str, &count, max_len, '0');
> +	  write_char (str, &count, max_len, 'x');
> +	  c = 'x';
>  	  /* Fall through. */
>  	case 'x':
>  	case 'X':
>  	case 'u':
>  	case 'd':
>  	case 'o':
> -	  write_number (str, &count, max_len, format1, rightfill, zerofill, c, curarg);
> +	  {
> +	    char tmp[32];
> +	    const char *p = tmp;
> +	    grub_size_t len;
> +	    grub_size_t fill;
> +
> +	    len = grub_lltoa (tmp, c, curarg) - tmp;
> +	    fill = len < format1 ? format1 - len : 0;
> +	    if (! rightfill)
> +	      while (fill--)
> +		write_char (str, &count, max_len, zerofill);
> +	    while (*p)
> +	      write_char (str, &count, max_len, *p++);
> +	    if (rightfill)
> +	      while (fill--)
> +		write_char (str, &count, max_len, zerofill);
> +	  }
>  	  break;
>  
>  	case 'c':

Acked-by: Laszlo Ersek <lersek@redhat.com>


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

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

* Re: [PATCH 4/4] guid: un-unifiy GUID types
  2023-10-05 10:47 ` [PATCH 4/4] guid: un-unifiy GUID types Oliver Steffen
@ 2023-10-05 14:38   ` Laszlo Ersek
  0 siblings, 0 replies; 10+ messages in thread
From: Laszlo Ersek @ 2023-10-05 14:38 UTC (permalink / raw)
  To: Oliver Steffen, grub-devel
  Cc: Daniel Kiper, Gerd Hoffmann, Tobias Powalowski,
	Pedro Miguel Justo, Frank Scheiner,
	Vladimir 'phcoder' Serbinenko, John Paul Adrian Glaubitz,
	Ard Biesheuvel

On 10/5/23 12:47, Oliver Steffen wrote:
> Switch back to separate GUID types, depending on use-case.
> 
> - Reverts commit 06edd40db76bb78457ac26156ed5f7b62381bbe8,
>   "guid: Unify GUID types"

ack

> - Changes the guid type used in grub_efi_set_variable_to_string()
>   to grub_efi_guid_t.

Yes, that seems justified; the function was added in a later commit in
the series (e83a88f6ea7f, "efi: Add grub_efi_set_variable_to_string()",
2023-06-01).

> - Fixes the type of bli_vendor_guid in bli.c

Ditto (e0fa7dc84c03, "bli: Add a module for the Boot Loader Interface",
2023-06-01).

Acked-by: Laszlo Ersek <lersek@redhat.com>

I support "revisit[ing] the topic of guid data types and related
functions at a later point". I too happen to have a particular technical
opinion on how that should be done, but first of all, this mess needs to
be disentangled for getting the release unstuck (with BLI included), and
then it should be re-approached in isolation, with a clean slate.

Laszlo


> 
> Signed-off-by: Oliver Steffen <osteffen@redhat.com>
> ---
>  grub-core/commands/acpi.c            |  4 +-
>  grub-core/commands/bli.c             |  2 +-
>  grub-core/commands/efi/efifwsetup.c  |  4 +-
>  grub-core/commands/efi/loadbios.c    | 14 +++---
>  grub-core/commands/efi/lsefi.c       |  4 +-
>  grub-core/commands/efi/lsefisystab.c |  4 +-
>  grub-core/commands/efi/lssal.c       |  4 +-
>  grub-core/commands/efi/smbios.c      | 12 +++---
>  grub-core/commands/efi/tpm.c         |  6 +--
>  grub-core/commands/probe.c           |  2 +-
>  grub-core/disk/efi/efidisk.c         |  4 +-
>  grub-core/disk/ldm.c                 |  2 +-
>  grub-core/efiemu/i386/pc/cfgtables.c |  6 +--
>  grub-core/efiemu/main.c              |  4 +-
>  grub-core/efiemu/runtime/efiemu.c    | 14 +++---
>  grub-core/kern/efi/acpi.c            | 12 +++---
>  grub-core/kern/efi/efi.c             | 24 +++++------
>  grub-core/kern/efi/fdt.c             |  2 +-
>  grub-core/kern/efi/init.c            |  2 +-
>  grub-core/kern/efi/sb.c              |  4 +-
>  grub-core/loader/efi/fdt.c           |  2 +-
>  grub-core/loader/efi/linux.c         |  4 +-
>  grub-core/loader/i386/xnu.c          |  4 +-
>  grub-core/loader/ia64/efi/linux.c    |  2 +-
>  grub-core/net/drivers/efi/efinet.c   |  4 +-
>  grub-core/partmap/gpt.c              |  4 +-
>  grub-core/term/efi/console.c         |  2 +-
>  grub-core/term/efi/serial.c          |  2 +-
>  grub-core/video/efi_gop.c            |  8 ++--
>  grub-core/video/efi_uga.c            |  2 +-
>  include/grub/efi/api.h               | 64 ++++++++++++++++++----------
>  include/grub/efi/efi.h               | 18 ++++----
>  include/grub/efiemu/efiemu.h         | 10 ++---
>  include/grub/efiemu/runtime.h        |  2 +-
>  include/grub/gpt_partition.h         | 13 +++++-
>  include/grub/types.h                 |  9 ----
>  util/grub-install.c                  |  2 +-
>  util/grub-probe.c                    |  2 +-
>  38 files changed, 151 insertions(+), 133 deletions(-)
> 
> diff --git a/grub-core/commands/acpi.c b/grub-core/commands/acpi.c
> index 1c034463c..0d0c14810 100644
> --- a/grub-core/commands/acpi.c
> +++ b/grub-core/commands/acpi.c
> @@ -763,8 +763,8 @@ grub_cmd_acpi (struct grub_extcmd_context *ctxt, int argc, char **args)
>  
>  #ifdef GRUB_MACHINE_EFI
>    {
> -    static grub_guid_t acpi = GRUB_EFI_ACPI_TABLE_GUID;
> -    static grub_guid_t acpi20 = GRUB_EFI_ACPI_20_TABLE_GUID;
> +    struct grub_efi_guid acpi = GRUB_EFI_ACPI_TABLE_GUID;
> +    struct grub_efi_guid acpi20 = GRUB_EFI_ACPI_20_TABLE_GUID;
>  
>      grub_efi_system_table->boot_services->install_configuration_table (&acpi20,
>  								       grub_acpi_get_rsdpv2 ());
> diff --git a/grub-core/commands/bli.c b/grub-core/commands/bli.c
> index 2a3933925..d1aeeea59 100644
> --- a/grub-core/commands/bli.c
> +++ b/grub-core/commands/bli.c
> @@ -34,7 +34,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
>  
>  #define MODNAME "bli"
>  
> -static const grub_guid_t bli_vendor_guid = GRUB_EFI_VENDOR_BOOT_LOADER_INTERFACE_GUID;
> +static const grub_efi_guid_t bli_vendor_guid = GRUB_EFI_VENDOR_BOOT_LOADER_INTERFACE_GUID;
>  
>  static grub_err_t
>  get_part_uuid (const char *device_name, char **part_uuid)
> diff --git a/grub-core/commands/efi/efifwsetup.c b/grub-core/commands/efi/efifwsetup.c
> index 704f9d352..de66c3035 100644
> --- a/grub-core/commands/efi/efifwsetup.c
> +++ b/grub-core/commands/efi/efifwsetup.c
> @@ -38,7 +38,7 @@ grub_cmd_fwsetup (grub_command_t cmd __attribute__ ((unused)),
>    grub_efi_uint64_t os_indications = GRUB_EFI_OS_INDICATIONS_BOOT_TO_FW_UI;
>    grub_err_t status;
>    grub_size_t oi_size;
> -  static grub_guid_t global = GRUB_EFI_GLOBAL_VARIABLE_GUID;
> +  static grub_efi_guid_t global = GRUB_EFI_GLOBAL_VARIABLE_GUID;
>  
>    if (argc >= 1 && grub_strcmp(args[0], "--is-supported") == 0)
>      return !efifwsetup_is_supported ();
> @@ -72,7 +72,7 @@ efifwsetup_is_supported (void)
>  {
>    grub_efi_uint64_t *os_indications_supported = NULL;
>    grub_size_t oi_size = 0;
> -  static grub_guid_t global = GRUB_EFI_GLOBAL_VARIABLE_GUID;
> +  static grub_efi_guid_t global = GRUB_EFI_GLOBAL_VARIABLE_GUID;
>    grub_efi_boolean_t ret = 0;
>  
>    grub_efi_get_variable ("OsIndicationsSupported", &global, &oi_size,
> diff --git a/grub-core/commands/efi/loadbios.c b/grub-core/commands/efi/loadbios.c
> index 8f6b0ecfc..574e41046 100644
> --- a/grub-core/commands/efi/loadbios.c
> +++ b/grub-core/commands/efi/loadbios.c
> @@ -27,9 +27,9 @@
>  
>  GRUB_MOD_LICENSE ("GPLv3+");
>  
> -static grub_guid_t acpi_guid = GRUB_EFI_ACPI_TABLE_GUID;
> -static grub_guid_t acpi2_guid = GRUB_EFI_ACPI_20_TABLE_GUID;
> -static grub_guid_t smbios_guid = GRUB_EFI_SMBIOS_TABLE_GUID;
> +static grub_efi_guid_t acpi_guid = GRUB_EFI_ACPI_TABLE_GUID;
> +static grub_efi_guid_t acpi2_guid = GRUB_EFI_ACPI_20_TABLE_GUID;
> +static grub_efi_guid_t smbios_guid = GRUB_EFI_SMBIOS_TABLE_GUID;
>  
>  #define EBDA_SEG_ADDR	0x40e
>  #define LOW_MEM_ADDR	0x413
> @@ -105,15 +105,15 @@ fake_bios_data (int use_rom)
>    smbios = 0;
>    for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
>      {
> -      grub_guid_t *guid =
> +      grub_efi_packed_guid_t *guid =
>  	&grub_efi_system_table->configuration_table[i].vendor_guid;
>  
> -      if (! grub_memcmp (guid, &acpi2_guid, sizeof (grub_guid_t)))
> +      if (! grub_memcmp (guid, &acpi2_guid, sizeof (grub_efi_guid_t)))
>  	{
>  	  acpi = grub_efi_system_table->configuration_table[i].vendor_table;
>  	  grub_dprintf ("efi", "ACPI2: %p\n", acpi);
>  	}
> -      else if (! grub_memcmp (guid, &acpi_guid, sizeof (grub_guid_t)))
> +      else if (! grub_memcmp (guid, &acpi_guid, sizeof (grub_efi_guid_t)))
>  	{
>  	  void *t;
>  
> @@ -122,7 +122,7 @@ fake_bios_data (int use_rom)
>  	    acpi = t;
>  	  grub_dprintf ("efi", "ACPI: %p\n", t);
>  	}
> -      else if (! grub_memcmp (guid, &smbios_guid, sizeof (grub_guid_t)))
> +      else if (! grub_memcmp (guid, &smbios_guid, sizeof (grub_efi_guid_t)))
>  	{
>  	  smbios = grub_efi_system_table->configuration_table[i].vendor_table;
>  	  grub_dprintf ("efi", "SMBIOS: %p\n", smbios);
> diff --git a/grub-core/commands/efi/lsefi.c b/grub-core/commands/efi/lsefi.c
> index 6935cd302..539701497 100644
> --- a/grub-core/commands/efi/lsefi.c
> +++ b/grub-core/commands/efi/lsefi.c
> @@ -31,7 +31,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
>  
>  struct known_protocol
>  {
> -  grub_guid_t guid;
> +  grub_efi_guid_t guid;
>    const char *name;
>  } known_protocols[] =
>    {
> @@ -96,7 +96,7 @@ grub_cmd_lsefi (grub_command_t cmd __attribute__ ((unused)),
>        grub_efi_handle_t handle = handles[i];
>        grub_efi_status_t status;
>        grub_efi_uintn_t num_protocols;
> -      grub_guid_t **protocols;
> +      grub_efi_packed_guid_t **protocols;
>        grub_efi_device_path_t *dp;
>  
>        grub_printf ("Handle %p\n", handle);
> diff --git a/grub-core/commands/efi/lsefisystab.c b/grub-core/commands/efi/lsefisystab.c
> index eff8c41f3..ac3299b7f 100644
> --- a/grub-core/commands/efi/lsefisystab.c
> +++ b/grub-core/commands/efi/lsefisystab.c
> @@ -29,7 +29,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
>  
>  struct guid_mapping
>  {
> -  grub_guid_t guid;
> +  grub_efi_guid_t guid;
>    const char *name;
>  };
>  
> @@ -104,7 +104,7 @@ grub_cmd_lsefisystab (struct grub_command *cmd __attribute__ ((unused)),
>  
>        for (j = 0; j < ARRAY_SIZE (guid_mappings); j++)
>  	if (grub_memcmp (&guid_mappings[j].guid, &t->vendor_guid,
> -			 sizeof (grub_guid_t)) == 0)
> +			 sizeof (grub_efi_guid_t)) == 0)
>  	  grub_printf ("   %s", guid_mappings[j].name);
>  
>        grub_printf ("\n");
> diff --git a/grub-core/commands/efi/lssal.c b/grub-core/commands/efi/lssal.c
> index fd6085f1b..5084ddd8b 100644
> --- a/grub-core/commands/efi/lssal.c
> +++ b/grub-core/commands/efi/lssal.c
> @@ -139,12 +139,12 @@ grub_cmd_lssal (struct grub_command *cmd __attribute__ ((unused)),
>    const grub_efi_system_table_t *st = grub_efi_system_table;
>    grub_efi_configuration_table_t *t = st->configuration_table;
>    unsigned int i;
> -  static grub_guid_t guid = GRUB_EFI_SAL_TABLE_GUID;
> +  grub_efi_packed_guid_t guid = GRUB_EFI_SAL_TABLE_GUID;
>  
>    for (i = 0; i < st->num_table_entries; i++)
>      {
>        if (grub_memcmp (&guid, &t->vendor_guid,
> -		       sizeof (grub_guid_t)) == 0)
> +		       sizeof (grub_efi_packed_guid_t)) == 0)
>  	{
>  	  disp_sal (t->vendor_table);
>  	  return GRUB_ERR_NONE;
> diff --git a/grub-core/commands/efi/smbios.c b/grub-core/commands/efi/smbios.c
> index d77239732..75202d5aa 100644
> --- a/grub-core/commands/efi/smbios.c
> +++ b/grub-core/commands/efi/smbios.c
> @@ -26,14 +26,14 @@ struct grub_smbios_eps *
>  grub_machine_smbios_get_eps (void)
>  {
>    unsigned i;
> -  static grub_guid_t smbios_guid = GRUB_EFI_SMBIOS_TABLE_GUID;
> +  static grub_efi_packed_guid_t smbios_guid = GRUB_EFI_SMBIOS_TABLE_GUID;
>  
>    for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
>      {
> -      grub_guid_t *guid =
> +      grub_efi_packed_guid_t *guid =
>  	&grub_efi_system_table->configuration_table[i].vendor_guid;
>  
> -      if (! grub_memcmp (guid, &smbios_guid, sizeof (grub_guid_t)))
> +      if (! grub_memcmp (guid, &smbios_guid, sizeof (grub_efi_packed_guid_t)))
>  	return (struct grub_smbios_eps *)
>  	  grub_efi_system_table->configuration_table[i].vendor_table;
>      }
> @@ -45,14 +45,14 @@ struct grub_smbios_eps3 *
>  grub_machine_smbios_get_eps3 (void)
>  {
>    unsigned i;
> -  static grub_guid_t smbios3_guid = GRUB_EFI_SMBIOS3_TABLE_GUID;
> +  static grub_efi_packed_guid_t smbios3_guid = GRUB_EFI_SMBIOS3_TABLE_GUID;
>  
>    for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
>      {
> -      grub_guid_t *guid =
> +      grub_efi_packed_guid_t *guid =
>  	&grub_efi_system_table->configuration_table[i].vendor_guid;
>  
> -      if (! grub_memcmp (guid, &smbios3_guid, sizeof (grub_guid_t)))
> +      if (! grub_memcmp (guid, &smbios3_guid, sizeof (grub_efi_packed_guid_t)))
>  	return (struct grub_smbios_eps3 *)
>  	  grub_efi_system_table->configuration_table[i].vendor_table;
>      }
> diff --git a/grub-core/commands/efi/tpm.c b/grub-core/commands/efi/tpm.c
> index f250c30db..bf98c9a6d 100644
> --- a/grub-core/commands/efi/tpm.c
> +++ b/grub-core/commands/efi/tpm.c
> @@ -30,9 +30,9 @@
>  
>  typedef TCG_PCR_EVENT grub_tpm_event_t;
>  
> -static grub_guid_t tpm_guid = EFI_TPM_GUID;
> -static grub_guid_t tpm2_guid = EFI_TPM2_GUID;
> -static grub_guid_t cc_measurement_guid = GRUB_EFI_CC_MEASUREMENT_PROTOCOL_GUID;
> +static grub_efi_guid_t tpm_guid = EFI_TPM_GUID;
> +static grub_efi_guid_t tpm2_guid = EFI_TPM2_GUID;
> +static grub_efi_guid_t cc_measurement_guid = GRUB_EFI_CC_MEASUREMENT_PROTOCOL_GUID;
>  
>  static grub_efi_handle_t *grub_tpm_handle;
>  static grub_uint8_t grub_tpm_version;
> diff --git a/grub-core/commands/probe.c b/grub-core/commands/probe.c
> index cc8c05586..9a80ea54f 100644
> --- a/grub-core/commands/probe.c
> +++ b/grub-core/commands/probe.c
> @@ -119,7 +119,7 @@ grub_cmd_probe (grub_extcmd_context_t ctxt, int argc, char **args)
>  	  if (grub_strcmp(dev->disk->partition->partmap->name, "gpt") == 0)
>  	    {
>  	      struct grub_gpt_partentry entry;
> -	      grub_guid_t *guid;
> +	      grub_gpt_part_guid_t *guid;
>  
>  	      if (grub_disk_read(disk, p->offset, p->index, sizeof(entry), &entry))
>  		{
> diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c
> index 3b5ed5691..ad025010a 100644
> --- a/grub-core/disk/efi/efidisk.c
> +++ b/grub-core/disk/efi/efidisk.c
> @@ -37,7 +37,7 @@ struct grub_efidisk_data
>  };
>  
>  /* GUID.  */
> -static grub_guid_t block_io_guid = GRUB_EFI_BLOCK_IO_GUID;
> +static grub_efi_guid_t block_io_guid = GRUB_EFI_BLOCK_IO_GUID;
>  
>  static struct grub_efidisk_data *fd_devices;
>  static struct grub_efidisk_data *hd_devices;
> @@ -319,7 +319,7 @@ name_devices (struct grub_efidisk_data *devices)
>  	  == GRUB_EFI_VENDOR_MEDIA_DEVICE_PATH_SUBTYPE)
>  	{
>  	  grub_efi_vendor_device_path_t *vendor = (grub_efi_vendor_device_path_t *) dp;
> -	  static const grub_guid_t apple = GRUB_EFI_VENDOR_APPLE_GUID;
> +	  const struct grub_efi_guid apple = GRUB_EFI_VENDOR_APPLE_GUID;
>  
>  	  if (vendor->header.length == sizeof (*vendor)
>  	      && grub_memcmp (&vendor->vendor_guid, &apple,
> diff --git a/grub-core/disk/ldm.c b/grub-core/disk/ldm.c
> index 34bfe6bd1..9632bc489 100644
> --- a/grub-core/disk/ldm.c
> +++ b/grub-core/disk/ldm.c
> @@ -136,7 +136,7 @@ msdos_has_ldm_partition (grub_disk_t dsk)
>    return has_ldm;
>  }
>  
> -static const grub_guid_t ldm_type = GRUB_GPT_PARTITION_TYPE_LDM;
> +static const grub_gpt_part_guid_t ldm_type = GRUB_GPT_PARTITION_TYPE_LDM;
>  
>  /* Helper for gpt_ldm_sector.  */
>  static int
> diff --git a/grub-core/efiemu/i386/pc/cfgtables.c b/grub-core/efiemu/i386/pc/cfgtables.c
> index 056ec0bc9..1098f0b79 100644
> --- a/grub-core/efiemu/i386/pc/cfgtables.c
> +++ b/grub-core/efiemu/i386/pc/cfgtables.c
> @@ -29,9 +29,9 @@ grub_machine_efiemu_init_tables (void)
>  {
>    void *table;
>    grub_err_t err;
> -  static grub_guid_t smbios = GRUB_EFI_SMBIOS_TABLE_GUID;
> -  static grub_guid_t acpi20 = GRUB_EFI_ACPI_20_TABLE_GUID;
> -  static grub_guid_t acpi = GRUB_EFI_ACPI_TABLE_GUID;
> +  static grub_efi_guid_t smbios = GRUB_EFI_SMBIOS_TABLE_GUID;
> +  static grub_efi_guid_t acpi20 = GRUB_EFI_ACPI_20_TABLE_GUID;
> +  static grub_efi_guid_t acpi = GRUB_EFI_ACPI_TABLE_GUID;
>  
>    err = grub_efiemu_unregister_configuration_table (smbios);
>    if (err)
> diff --git a/grub-core/efiemu/main.c b/grub-core/efiemu/main.c
> index e7037f4ed..a81934725 100644
> --- a/grub-core/efiemu/main.c
> +++ b/grub-core/efiemu/main.c
> @@ -80,7 +80,7 @@ grub_efiemu_unload (void)
>  
>  /* Remove previously registered table from the list */
>  grub_err_t
> -grub_efiemu_unregister_configuration_table (grub_guid_t guid)
> +grub_efiemu_unregister_configuration_table (grub_efi_guid_t guid)
>  {
>    struct grub_efiemu_configuration_table *cur, *prev;
>  
> @@ -136,7 +136,7 @@ grub_efiemu_register_prepare_hook (grub_err_t (*hook) (void *data),
>     or with a hook
>  */
>  grub_err_t
> -grub_efiemu_register_configuration_table (grub_guid_t guid,
> +grub_efiemu_register_configuration_table (grub_efi_guid_t guid,
>  					  void * (*get_table) (void *data),
>  					  void (*unload) (void *data),
>  					  void *data)
> diff --git a/grub-core/efiemu/runtime/efiemu.c b/grub-core/efiemu/runtime/efiemu.c
> index c84b30652..53b3cce7b 100644
> --- a/grub-core/efiemu/runtime/efiemu.c
> +++ b/grub-core/efiemu/runtime/efiemu.c
> @@ -66,7 +66,7 @@ efiemu_convert_pointer (grub_efi_uintn_t debug_disposition,
>  
>  grub_efi_status_t __grub_efi_api
>  efiemu_get_variable (grub_efi_char16_t *variable_name,
> -		     const grub_guid_t *vendor_guid,
> +		     const grub_efi_guid_t *vendor_guid,
>  		     grub_efi_uint32_t *attributes,
>  		     grub_efi_uintn_t *data_size,
>  		     void *data);
> @@ -74,11 +74,11 @@ efiemu_get_variable (grub_efi_char16_t *variable_name,
>  grub_efi_status_t __grub_efi_api
>  efiemu_get_next_variable_name (grub_efi_uintn_t *variable_name_size,
>  			       grub_efi_char16_t *variable_name,
> -			       grub_guid_t *vendor_guid);
> +			       grub_efi_guid_t *vendor_guid);
>  
>  grub_efi_status_t __grub_efi_api
>  efiemu_set_variable (grub_efi_char16_t *variable_name,
> -		     const grub_guid_t *vendor_guid,
> +		     const grub_efi_guid_t *vendor_guid,
>  		     grub_efi_uint32_t attributes,
>  		     grub_efi_uintn_t data_size,
>  		     void *data);
> @@ -416,7 +416,7 @@ EFI_FUNC (efiemu_convert_pointer) (grub_efi_uintn_t debug_disposition,
>  
>  /* Find variable by name and GUID. */
>  static struct efi_variable *
> -find_variable (const grub_guid_t *vendor_guid,
> +find_variable (const grub_efi_guid_t *vendor_guid,
>  	       grub_efi_char16_t *variable_name)
>  {
>    grub_uint8_t *ptr;
> @@ -438,7 +438,7 @@ find_variable (const grub_guid_t *vendor_guid,
>  
>  grub_efi_status_t __grub_efi_api
>  EFI_FUNC (efiemu_get_variable) (grub_efi_char16_t *variable_name,
> -				const grub_guid_t *vendor_guid,
> +				const grub_efi_guid_t *vendor_guid,
>  				grub_efi_uint32_t *attributes,
>  				grub_efi_uintn_t *data_size,
>  				void *data)
> @@ -464,7 +464,7 @@ EFI_FUNC (efiemu_get_variable) (grub_efi_char16_t *variable_name,
>  grub_efi_status_t __grub_efi_api EFI_FUNC
>  (efiemu_get_next_variable_name) (grub_efi_uintn_t *variable_name_size,
>  				 grub_efi_char16_t *variable_name,
> -				 grub_guid_t *vendor_guid)
> +				 grub_efi_guid_t *vendor_guid)
>  {
>    struct efi_variable *efivar;
>    LOG ('l');
> @@ -503,7 +503,7 @@ grub_efi_status_t __grub_efi_api EFI_FUNC
>  
>  grub_efi_status_t __grub_efi_api
>  EFI_FUNC (efiemu_set_variable) (grub_efi_char16_t *variable_name,
> -				const grub_guid_t *vendor_guid,
> +				const grub_efi_guid_t *vendor_guid,
>  				grub_efi_uint32_t attributes,
>  				grub_efi_uintn_t data_size,
>  				void *data)
> diff --git a/grub-core/kern/efi/acpi.c b/grub-core/kern/efi/acpi.c
> index 461c77c33..74f8cd1a9 100644
> --- a/grub-core/kern/efi/acpi.c
> +++ b/grub-core/kern/efi/acpi.c
> @@ -26,14 +26,14 @@ struct grub_acpi_rsdp_v10 *
>  grub_machine_acpi_get_rsdpv1 (void)
>  {
>    unsigned i;
> -  static grub_guid_t acpi_guid = GRUB_EFI_ACPI_TABLE_GUID;
> +  static grub_efi_packed_guid_t acpi_guid = GRUB_EFI_ACPI_TABLE_GUID;
>  
>    for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
>      {
> -      grub_guid_t *guid =
> +      grub_efi_packed_guid_t *guid =
>  	&grub_efi_system_table->configuration_table[i].vendor_guid;
>  
> -      if (! grub_memcmp (guid, &acpi_guid, sizeof (grub_guid_t)))
> +      if (! grub_memcmp (guid, &acpi_guid, sizeof (grub_efi_packed_guid_t)))
>  	return (struct grub_acpi_rsdp_v10 *)
>  	  grub_efi_system_table->configuration_table[i].vendor_table;
>      }
> @@ -44,14 +44,14 @@ struct grub_acpi_rsdp_v20 *
>  grub_machine_acpi_get_rsdpv2 (void)
>  {
>    unsigned i;
> -  static grub_guid_t acpi20_guid = GRUB_EFI_ACPI_20_TABLE_GUID;
> +  static grub_efi_packed_guid_t acpi20_guid = GRUB_EFI_ACPI_20_TABLE_GUID;
>  
>    for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
>      {
> -      grub_guid_t *guid =
> +      grub_efi_packed_guid_t *guid =
>  	&grub_efi_system_table->configuration_table[i].vendor_guid;
>  
> -      if (! grub_memcmp (guid, &acpi20_guid, sizeof (grub_guid_t)))
> +      if (! grub_memcmp (guid, &acpi20_guid, sizeof (grub_efi_packed_guid_t)))
>  	return (struct grub_acpi_rsdp_v20 *)
>  	  grub_efi_system_table->configuration_table[i].vendor_table;
>      }
> diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c
> index 5e1c147a5..629ccb7b7 100644
> --- a/grub-core/kern/efi/efi.c
> +++ b/grub-core/kern/efi/efi.c
> @@ -35,12 +35,12 @@ grub_efi_handle_t grub_efi_image_handle;
>  /* The pointer to a system table. Filled in by the startup code.  */
>  grub_efi_system_table_t *grub_efi_system_table;
>  
> -static grub_guid_t console_control_guid = GRUB_EFI_CONSOLE_CONTROL_GUID;
> -static grub_guid_t loaded_image_guid = GRUB_EFI_LOADED_IMAGE_GUID;
> -static grub_guid_t device_path_guid = GRUB_EFI_DEVICE_PATH_GUID;
> +static grub_efi_guid_t console_control_guid = GRUB_EFI_CONSOLE_CONTROL_GUID;
> +static grub_efi_guid_t loaded_image_guid = GRUB_EFI_LOADED_IMAGE_GUID;
> +static grub_efi_guid_t device_path_guid = GRUB_EFI_DEVICE_PATH_GUID;
>  
>  void *
> -grub_efi_locate_protocol (grub_guid_t *protocol, void *registration)
> +grub_efi_locate_protocol (grub_efi_guid_t *protocol, void *registration)
>  {
>    void *interface;
>    grub_efi_status_t status;
> @@ -59,7 +59,7 @@ grub_efi_locate_protocol (grub_guid_t *protocol, void *registration)
>     from the heap.  */
>  grub_efi_handle_t *
>  grub_efi_locate_handle (grub_efi_locate_search_type_t search_type,
> -			grub_guid_t *protocol,
> +			grub_efi_guid_t *protocol,
>  			void *search_key,
>  			grub_efi_uintn_t *num_handles)
>  {
> @@ -98,7 +98,7 @@ grub_efi_locate_handle (grub_efi_locate_search_type_t search_type,
>  
>  void *
>  grub_efi_open_protocol (grub_efi_handle_t handle,
> -			grub_guid_t *protocol,
> +			grub_efi_guid_t *protocol,
>  			grub_efi_uint32_t attributes)
>  {
>    grub_efi_boot_services_t *b;
> @@ -119,7 +119,7 @@ grub_efi_open_protocol (grub_efi_handle_t handle,
>  }
>  
>  grub_efi_status_t
> -grub_efi_close_protocol (grub_efi_handle_t handle, grub_guid_t *protocol)
> +grub_efi_close_protocol (grub_efi_handle_t handle, grub_efi_guid_t *protocol)
>  {
>    grub_efi_boot_services_t *b = grub_efi_system_table->boot_services;
>  
> @@ -203,7 +203,7 @@ grub_efi_set_virtual_address_map (grub_efi_uintn_t memory_map_size,
>  }
>  
>  grub_err_t
> -grub_efi_set_variable_with_attributes (const char *var, const grub_guid_t *guid,
> +grub_efi_set_variable_with_attributes (const char *var, const grub_efi_guid_t *guid,
>  		      void *data, grub_size_t datasize, grub_efi_uint32_t attributes)
>  {
>    grub_efi_status_t status;
> @@ -226,7 +226,7 @@ grub_efi_set_variable_with_attributes (const char *var, const grub_guid_t *guid,
>  }
>  
>  grub_err_t
> -grub_efi_set_variable (const char *var, const grub_guid_t *guid,
> +grub_efi_set_variable (const char *var, const grub_efi_guid_t *guid,
>  		      void *data, grub_size_t datasize)
>  {
>    return grub_efi_set_variable_with_attributes (var, guid, data, datasize,
> @@ -237,7 +237,7 @@ grub_efi_set_variable (const char *var, const grub_guid_t *guid,
>  
>  grub_efi_status_t
>  grub_efi_get_variable_with_attributes (const char *var,
> -				       const grub_guid_t *guid,
> +				       const grub_efi_guid_t *guid,
>  				       grub_size_t *datasize_out,
>  				       void **data_out,
>  				       grub_efi_uint32_t *attributes)
> @@ -287,7 +287,7 @@ grub_efi_get_variable_with_attributes (const char *var,
>  }
>  
>  grub_err_t
> -grub_efi_set_variable_to_string (const char *name, const grub_guid_t *guid,
> +grub_efi_set_variable_to_string (const char *name, const grub_efi_guid_t *guid,
>  			         const char *value, grub_efi_uint32_t attributes)
>  {
>    grub_efi_char16_t *value_16;
> @@ -309,7 +309,7 @@ grub_efi_set_variable_to_string (const char *name, const grub_guid_t *guid,
>  }
>  
>  grub_efi_status_t
> -grub_efi_get_variable (const char *var, const grub_guid_t *guid,
> +grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid,
>  		       grub_size_t *datasize_out, void **data_out)
>  {
>    return grub_efi_get_variable_with_attributes (var, guid, datasize_out, data_out, NULL);
> diff --git a/grub-core/kern/efi/fdt.c b/grub-core/kern/efi/fdt.c
> index 8fcf43f1b..24f955289 100644
> --- a/grub-core/kern/efi/fdt.c
> +++ b/grub-core/kern/efi/fdt.c
> @@ -24,7 +24,7 @@ void *
>  grub_efi_get_firmware_fdt (void)
>  {
>    grub_efi_configuration_table_t *tables;
> -  static grub_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID;
> +  static grub_efi_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID;
>    void *firmware_fdt = NULL;
>    unsigned int i;
>  
> diff --git a/grub-core/kern/efi/init.c b/grub-core/kern/efi/init.c
> index 6fe1ff8c8..ae8c2e1e4 100644
> --- a/grub-core/kern/efi/init.c
> +++ b/grub-core/kern/efi/init.c
> @@ -37,7 +37,7 @@ static grub_efi_char16_t stack_chk_fail_msg[] =
>    L"* GRUB: ABORTED!!! *\r\n"
>    L"* GRUB: REBOOTING IN 5 SECONDS... *\r\n";
>  
> -static grub_guid_t rng_protocol_guid = GRUB_EFI_RNG_PROTOCOL_GUID;
> +static grub_efi_guid_t rng_protocol_guid = GRUB_EFI_RNG_PROTOCOL_GUID;
>  
>  /*
>   * Don't put this on grub_efi_init()'s local stack to avoid it
> diff --git a/grub-core/kern/efi/sb.c b/grub-core/kern/efi/sb.c
> index 60550a6da..583002ae4 100644
> --- a/grub-core/kern/efi/sb.c
> +++ b/grub-core/kern/efi/sb.c
> @@ -30,7 +30,7 @@
>  #include <grub/types.h>
>  #include <grub/verify.h>
>  
> -static grub_guid_t shim_lock_guid = GRUB_EFI_SHIM_LOCK_GUID;
> +static grub_efi_guid_t shim_lock_guid = GRUB_EFI_SHIM_LOCK_GUID;
>  
>  static bool shim_lock_enabled = false;
>  
> @@ -43,7 +43,7 @@ static bool shim_lock_enabled = false;
>  grub_uint8_t
>  grub_efi_get_secureboot (void)
>  {
> -  static grub_guid_t efi_variable_guid = GRUB_EFI_GLOBAL_VARIABLE_GUID;
> +  static grub_efi_guid_t efi_variable_guid = GRUB_EFI_GLOBAL_VARIABLE_GUID;
>    grub_efi_status_t status;
>    grub_efi_uint32_t attr = 0;
>    grub_size_t size = 0;
> diff --git a/grub-core/loader/efi/fdt.c b/grub-core/loader/efi/fdt.c
> index 439964b9c..35a3be2e5 100644
> --- a/grub-core/loader/efi/fdt.c
> +++ b/grub-core/loader/efi/fdt.c
> @@ -86,7 +86,7 @@ grub_err_t
>  grub_fdt_install (void)
>  {
>    grub_efi_boot_services_t *b;
> -  static grub_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID;
> +  static grub_efi_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID;
>    grub_efi_status_t status;
>  
>    if (fdt == NULL && loaded_fdt == NULL)
> diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c
> index bfbd95aee..ca69f4350 100644
> --- a/grub-core/loader/efi/linux.c
> +++ b/grub-core/loader/efi/linux.c
> @@ -52,8 +52,8 @@ static struct grub_linux_initrd_context initrd_ctx = {0, 0, 0};
>  static grub_efi_handle_t initrd_lf2_handle = NULL;
>  static bool initrd_use_loadfile2 = false;
>  
> -static grub_guid_t load_file2_guid = GRUB_EFI_LOAD_FILE2_PROTOCOL_GUID;
> -static grub_guid_t device_path_guid = GRUB_EFI_DEVICE_PATH_GUID;
> +static grub_efi_guid_t load_file2_guid = GRUB_EFI_LOAD_FILE2_PROTOCOL_GUID;
> +static grub_efi_guid_t device_path_guid = GRUB_EFI_DEVICE_PATH_GUID;
>  
>  static initrd_media_device_path_t initrd_lf2_device_path = {
>    {
> diff --git a/grub-core/loader/i386/xnu.c b/grub-core/loader/i386/xnu.c
> index 93ba4476d..4c88ce5e0 100644
> --- a/grub-core/loader/i386/xnu.c
> +++ b/grub-core/loader/i386/xnu.c
> @@ -48,7 +48,7 @@ grub_uint32_t grub_xnu_entry_point, grub_xnu_arg1, grub_xnu_stack;
>  /* Aliases set for some tables. */
>  struct tbl_alias
>  {
> -  grub_guid_t guid;
> +  grub_efi_guid_t guid;
>    const char *name;
>  };
>  
> @@ -694,7 +694,7 @@ grub_cpu_xnu_fill_devicetree (grub_uint64_t *fsbfreq_out)
>      {
>        void *ptr;
>        struct grub_xnu_devtree_key *curkey;
> -      grub_guid_t guid;
> +      grub_efi_packed_guid_t guid;
>        char guidbuf[64];
>  
>        /* Retrieve current key. */
> diff --git a/grub-core/loader/ia64/efi/linux.c b/grub-core/loader/ia64/efi/linux.c
> index 3dd2e8236..fb9b961f7 100644
> --- a/grub-core/loader/ia64/efi/linux.c
> +++ b/grub-core/loader/ia64/efi/linux.c
> @@ -106,7 +106,7 @@ query_fpswa (void)
>    grub_efi_boot_services_t *bs;
>    grub_efi_status_t status;
>    grub_efi_uintn_t size;
> -  static const grub_guid_t fpswa_protocol =
> +  static const grub_efi_guid_t fpswa_protocol =
>      { 0xc41b6531, 0x97b9, 0x11d3,
>        {0x9a, 0x29, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} };
>  
> diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c
> index 3ea25cf98..56a179709 100644
> --- a/grub-core/net/drivers/efi/efinet.c
> +++ b/grub-core/net/drivers/efi/efinet.c
> @@ -27,8 +27,8 @@
>  GRUB_MOD_LICENSE ("GPLv3+");
>  
>  /* GUID.  */
> -static grub_guid_t net_io_guid = GRUB_EFI_SIMPLE_NETWORK_GUID;
> -static grub_guid_t pxe_io_guid = GRUB_EFI_PXE_GUID;
> +static grub_efi_guid_t net_io_guid = GRUB_EFI_SIMPLE_NETWORK_GUID;
> +static grub_efi_guid_t pxe_io_guid = GRUB_EFI_PXE_GUID;
>  
>  static grub_err_t
>  send_card_buffer (struct grub_net_card *dev,
> diff --git a/grub-core/partmap/gpt.c b/grub-core/partmap/gpt.c
> index 877ceefc3..075cc96f1 100644
> --- a/grub-core/partmap/gpt.c
> +++ b/grub-core/partmap/gpt.c
> @@ -36,10 +36,10 @@ static grub_uint8_t grub_gpt_magic[8] =
>      0x45, 0x46, 0x49, 0x20, 0x50, 0x41, 0x52, 0x54
>    };
>  
> -static const grub_guid_t grub_gpt_partition_type_empty = GRUB_GPT_PARTITION_TYPE_EMPTY;
> +static const grub_gpt_part_guid_t grub_gpt_partition_type_empty = GRUB_GPT_PARTITION_TYPE_EMPTY;
>  
>  #ifdef GRUB_UTIL
> -static const grub_guid_t grub_gpt_partition_type_bios_boot = GRUB_GPT_PARTITION_TYPE_BIOS_BOOT;
> +static const grub_gpt_part_guid_t grub_gpt_partition_type_bios_boot = GRUB_GPT_PARTITION_TYPE_BIOS_BOOT;
>  #endif
>  
>  /* 512 << 7 = 65536 byte sectors.  */
> diff --git a/grub-core/term/efi/console.c b/grub-core/term/efi/console.c
> index bb587f39d..9a7bc0fcf 100644
> --- a/grub-core/term/efi/console.c
> +++ b/grub-core/term/efi/console.c
> @@ -352,7 +352,7 @@ grub_console_getkeystatus (struct grub_term_input *term)
>  static grub_err_t
>  grub_efi_console_input_init (struct grub_term_input *term)
>  {
> -  static grub_guid_t text_input_ex_guid =
> +  static grub_efi_guid_t text_input_ex_guid =
>      GRUB_EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID;
>  
>    if (grub_efi_is_finished)
> diff --git a/grub-core/term/efi/serial.c b/grub-core/term/efi/serial.c
> index 5dfd2d86c..e86ebce3f 100644
> --- a/grub-core/term/efi/serial.c
> +++ b/grub-core/term/efi/serial.c
> @@ -31,7 +31,7 @@
>  #include <grub/i18n.h>
>  
>  /* GUID.  */
> -static grub_guid_t serial_io_guid = GRUB_EFI_SERIAL_IO_GUID;
> +static grub_efi_guid_t serial_io_guid = GRUB_EFI_SERIAL_IO_GUID;
>  
>  static void
>  do_real_config (struct grub_serial_port *port)
> diff --git a/grub-core/video/efi_gop.c b/grub-core/video/efi_gop.c
> index 9452f5e58..68c9d58f9 100644
> --- a/grub-core/video/efi_gop.c
> +++ b/grub-core/video/efi_gop.c
> @@ -32,10 +32,10 @@
>  
>  GRUB_MOD_LICENSE ("GPLv3+");
>  
> -static grub_guid_t graphics_output_guid = GRUB_EFI_GOP_GUID;
> -static grub_guid_t active_edid_guid = GRUB_EFI_EDID_ACTIVE_GUID;
> -static grub_guid_t discovered_edid_guid = GRUB_EFI_EDID_DISCOVERED_GUID;
> -static grub_guid_t efi_var_guid = GRUB_EFI_GLOBAL_VARIABLE_GUID;
> +static grub_efi_guid_t graphics_output_guid = GRUB_EFI_GOP_GUID;
> +static grub_efi_guid_t active_edid_guid = GRUB_EFI_EDID_ACTIVE_GUID;
> +static grub_efi_guid_t discovered_edid_guid = GRUB_EFI_EDID_DISCOVERED_GUID;
> +static grub_efi_guid_t efi_var_guid = GRUB_EFI_GLOBAL_VARIABLE_GUID;
>  static struct grub_efi_gop *gop;
>  static unsigned old_mode;
>  static int restore_needed;
> diff --git a/grub-core/video/efi_uga.c b/grub-core/video/efi_uga.c
> index d53079e0b..aa4659b8e 100644
> --- a/grub-core/video/efi_uga.c
> +++ b/grub-core/video/efi_uga.c
> @@ -32,7 +32,7 @@
>  
>  GRUB_MOD_LICENSE ("GPLv3+");
>  
> -static grub_guid_t uga_draw_guid = GRUB_EFI_UGA_DRAW_GUID;
> +static grub_efi_guid_t uga_draw_guid = GRUB_EFI_UGA_DRAW_GUID;
>  static struct grub_efi_uga_draw_protocol *uga;
>  static grub_uint64_t uga_fb;
>  static grub_uint32_t uga_pitch;
> diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h
> index d3eaef3fb..b846c2e5d 100644
> --- a/include/grub/efi/api.h
> +++ b/include/grub/efi/api.h
> @@ -644,6 +644,24 @@ typedef grub_uint8_t grub_efi_ip_address_t[8] __attribute__ ((aligned(4)));
>  typedef grub_efi_uint64_t grub_efi_physical_address_t;
>  typedef grub_efi_uint64_t grub_efi_virtual_address_t;
>  
> +struct grub_efi_guid
> +{
> +  grub_uint32_t data1;
> +  grub_uint16_t data2;
> +  grub_uint16_t data3;
> +  grub_uint8_t data4[8];
> +} __attribute__ ((aligned(8)));
> +typedef struct grub_efi_guid grub_efi_guid_t;
> +
> +struct grub_efi_packed_guid
> +{
> +  grub_uint32_t data1;
> +  grub_uint16_t data2;
> +  grub_uint16_t data3;
> +  grub_uint8_t data4[8];
> +} GRUB_PACKED;
> +typedef struct grub_efi_packed_guid grub_efi_packed_guid_t;
> +
>  /* XXX although the spec does not specify the padding, this actually
>     must have the padding!  */
>  struct grub_efi_memory_descriptor
> @@ -730,7 +748,7 @@ typedef struct grub_efi_memory_mapped_device_path grub_efi_memory_mapped_device_
>  struct grub_efi_vendor_device_path
>  {
>    grub_efi_device_path_t header;
> -  grub_guid_t vendor_guid;
> +  grub_efi_packed_guid_t vendor_guid;
>    grub_efi_uint8_t vendor_defined_data[0];
>  } GRUB_PACKED;
>  typedef struct grub_efi_vendor_device_path grub_efi_vendor_device_path_t;
> @@ -974,7 +992,7 @@ typedef struct grub_efi_cdrom_device_path grub_efi_cdrom_device_path_t;
>  struct grub_efi_vendor_media_device_path
>  {
>    grub_efi_device_path_t header;
> -  grub_guid_t vendor_guid;
> +  grub_efi_packed_guid_t vendor_guid;
>    grub_efi_uint8_t vendor_defined_data[0];
>  } GRUB_PACKED;
>  typedef struct grub_efi_vendor_media_device_path grub_efi_vendor_media_device_path_t;
> @@ -993,7 +1011,7 @@ typedef struct grub_efi_file_path_device_path grub_efi_file_path_device_path_t;
>  struct grub_efi_protocol_device_path
>  {
>    grub_efi_device_path_t header;
> -  grub_guid_t guid;
> +  grub_efi_packed_guid_t guid;
>  } GRUB_PACKED;
>  typedef struct grub_efi_protocol_device_path grub_efi_protocol_device_path_t;
>  
> @@ -1002,7 +1020,7 @@ typedef struct grub_efi_protocol_device_path grub_efi_protocol_device_path_t;
>  struct grub_efi_piwg_device_path
>  {
>    grub_efi_device_path_t header;
> -  grub_guid_t guid;
> +  grub_efi_packed_guid_t guid;
>  } GRUB_PACKED;
>  typedef struct grub_efi_piwg_device_path grub_efi_piwg_device_path_t;
>  
> @@ -1173,47 +1191,47 @@ struct grub_efi_boot_services
>  
>    grub_efi_status_t
>    (__grub_efi_api *install_protocol_interface) (grub_efi_handle_t *handle,
> -						grub_guid_t *protocol,
> +						grub_efi_guid_t *protocol,
>  						grub_efi_interface_type_t protocol_interface_type,
>  						void *protocol_interface);
>  
>    grub_efi_status_t
>    (__grub_efi_api *reinstall_protocol_interface) (grub_efi_handle_t handle,
> -						  grub_guid_t *protocol,
> +						  grub_efi_guid_t *protocol,
>  						  void *old_interface,
>  						  void *new_interface);
>  
>    grub_efi_status_t
>    (__grub_efi_api *uninstall_protocol_interface) (grub_efi_handle_t handle,
> -						  grub_guid_t *protocol,
> +						  grub_efi_guid_t *protocol,
>  						  void *protocol_interface);
>  
>    grub_efi_status_t
>    (__grub_efi_api *handle_protocol) (grub_efi_handle_t handle,
> -				     grub_guid_t *protocol,
> +				     grub_efi_guid_t *protocol,
>  				     void **protocol_interface);
>  
>    void *reserved;
>  
>    grub_efi_status_t
> -  (__grub_efi_api *register_protocol_notify) (grub_guid_t *protocol,
> +  (__grub_efi_api *register_protocol_notify) (grub_efi_guid_t *protocol,
>  					      grub_efi_event_t event,
>  					      void **registration);
>  
>    grub_efi_status_t
>    (__grub_efi_api *locate_handle) (grub_efi_locate_search_type_t search_type,
> -				   grub_guid_t *protocol,
> +				   grub_efi_guid_t *protocol,
>  				   void *search_key,
>  				   grub_efi_uintn_t *buffer_size,
>  				   grub_efi_handle_t *buffer);
>  
>    grub_efi_status_t
> -  (__grub_efi_api *locate_device_path) (grub_guid_t *protocol,
> +  (__grub_efi_api *locate_device_path) (grub_efi_guid_t *protocol,
>  					grub_efi_device_path_t **device_path,
>  					grub_efi_handle_t *device);
>  
>    grub_efi_status_t
> -  (__grub_efi_api *install_configuration_table) (grub_guid_t *guid,
> +  (__grub_efi_api *install_configuration_table) (grub_efi_guid_t *guid,
>  						 void *table);
>  
>    grub_efi_status_t
> @@ -1267,7 +1285,7 @@ struct grub_efi_boot_services
>  
>    grub_efi_status_t
>    (__grub_efi_api *open_protocol) (grub_efi_handle_t handle,
> -				   grub_guid_t *protocol,
> +				   grub_efi_guid_t *protocol,
>  				   void **protocol_interface,
>  				   grub_efi_handle_t agent_handle,
>  				   grub_efi_handle_t controller_handle,
> @@ -1275,30 +1293,30 @@ struct grub_efi_boot_services
>  
>    grub_efi_status_t
>    (__grub_efi_api *close_protocol) (grub_efi_handle_t handle,
> -				    grub_guid_t *protocol,
> +				    grub_efi_guid_t *protocol,
>  				    grub_efi_handle_t agent_handle,
>  				    grub_efi_handle_t controller_handle);
>  
>    grub_efi_status_t
>    (__grub_efi_api *open_protocol_information) (grub_efi_handle_t handle,
> -					       grub_guid_t *protocol,
> +					       grub_efi_guid_t *protocol,
>  					       grub_efi_open_protocol_information_entry_t **entry_buffer,
>  					       grub_efi_uintn_t *entry_count);
>  
>    grub_efi_status_t
>    (__grub_efi_api *protocols_per_handle) (grub_efi_handle_t handle,
> -					  grub_guid_t ***protocol_buffer,
> +					  grub_efi_packed_guid_t ***protocol_buffer,
>  					  grub_efi_uintn_t *protocol_buffer_count);
>  
>    grub_efi_status_t
>    (__grub_efi_api *locate_handle_buffer) (grub_efi_locate_search_type_t search_type,
> -					  grub_guid_t *protocol,
> +					  grub_efi_guid_t *protocol,
>  					  void *search_key,
>  					  grub_efi_uintn_t *no_handles,
>  					  grub_efi_handle_t **buffer);
>  
>    grub_efi_status_t
> -  (__grub_efi_api *locate_protocol) (grub_guid_t *protocol,
> +  (__grub_efi_api *locate_protocol) (grub_efi_guid_t *protocol,
>  				     void *registration,
>  				     void **protocol_interface);
>  
> @@ -1356,7 +1374,7 @@ struct grub_efi_runtime_services
>  
>    grub_efi_status_t
>    (__grub_efi_api *get_variable) (grub_efi_char16_t *variable_name,
> -				  const grub_guid_t *vendor_guid,
> +				  const grub_efi_guid_t *vendor_guid,
>  				  grub_efi_uint32_t *attributes,
>  				  grub_efi_uintn_t *data_size,
>  				  void *data);
> @@ -1364,11 +1382,11 @@ struct grub_efi_runtime_services
>    grub_efi_status_t
>    (__grub_efi_api *get_next_variable_name) (grub_efi_uintn_t *variable_name_size,
>  					    grub_efi_char16_t *variable_name,
> -					    grub_guid_t *vendor_guid);
> +					    grub_efi_guid_t *vendor_guid);
>  
>    grub_efi_status_t
>    (__grub_efi_api *set_variable) (grub_efi_char16_t *variable_name,
> -				  const grub_guid_t *vendor_guid,
> +				  const grub_efi_guid_t *vendor_guid,
>  				  grub_efi_uint32_t attributes,
>  				  grub_efi_uintn_t data_size,
>  				  void *data);
> @@ -1386,7 +1404,7 @@ typedef struct grub_efi_runtime_services grub_efi_runtime_services_t;
>  
>  struct grub_efi_configuration_table
>  {
> -  grub_guid_t vendor_guid;
> +  grub_efi_packed_guid_t vendor_guid;
>    void *vendor_table;
>  } GRUB_PACKED;
>  typedef struct grub_efi_configuration_table grub_efi_configuration_table_t;
> @@ -1785,7 +1803,7 @@ struct grub_efi_shim_lock_protocol
>  };
>  typedef struct grub_efi_shim_lock_protocol grub_efi_shim_lock_protocol_t;
>  
> -typedef grub_guid_t grub_efi_rng_algorithm_t;
> +typedef grub_efi_guid_t grub_efi_rng_algorithm_t;
>  
>  struct grub_efi_rng_protocol
>  {
> diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h
> index 572f7135f..bf9e7f275 100644
> --- a/include/grub/efi/efi.h
> +++ b/include/grub/efi/efi.h
> @@ -37,18 +37,18 @@ struct linux_arch_kernel_header {
>  };
>  
>  /* Functions.  */
> -void *EXPORT_FUNC(grub_efi_locate_protocol) (grub_guid_t *protocol,
> +void *EXPORT_FUNC(grub_efi_locate_protocol) (grub_efi_guid_t *protocol,
>  					     void *registration);
>  grub_efi_handle_t *
>  EXPORT_FUNC(grub_efi_locate_handle) (grub_efi_locate_search_type_t search_type,
> -				     grub_guid_t *protocol,
> +				     grub_efi_guid_t *protocol,
>  				     void *search_key,
>  				     grub_efi_uintn_t *num_handles);
>  void *EXPORT_FUNC(grub_efi_open_protocol) (grub_efi_handle_t handle,
> -					   grub_guid_t *protocol,
> +					   grub_efi_guid_t *protocol,
>  					   grub_efi_uint32_t attributes);
>  grub_efi_status_t
> -EXPORT_FUNC(grub_efi_close_protocol) (grub_efi_handle_t handle, grub_guid_t *protocol);
> +EXPORT_FUNC(grub_efi_close_protocol) (grub_efi_handle_t handle, grub_efi_guid_t *protocol);
>  int EXPORT_FUNC(grub_efi_set_text_mode) (int on);
>  void EXPORT_FUNC(grub_efi_stall) (grub_efi_uintn_t microseconds);
>  void *
> @@ -89,27 +89,27 @@ grub_err_t EXPORT_FUNC (grub_efi_set_virtual_address_map) (grub_efi_uintn_t memo
>  							   grub_efi_uint32_t descriptor_version,
>  							   grub_efi_memory_descriptor_t *virtual_map);
>  grub_efi_status_t EXPORT_FUNC (grub_efi_get_variable_with_attributes) (const char *variable,
> -								       const grub_guid_t *guid,
> +								       const grub_efi_guid_t *guid,
>  								       grub_size_t *datasize_out,
>  								       void **data_out,
>  								       grub_efi_uint32_t *attributes);
>  grub_efi_status_t EXPORT_FUNC (grub_efi_get_variable) (const char *variable,
> -						       const grub_guid_t *guid,
> +						       const grub_efi_guid_t *guid,
>  						       grub_size_t *datasize_out,
>  						       void **data_out);
>  grub_err_t
>  EXPORT_FUNC (grub_efi_set_variable_with_attributes) (const char *var,
> -				     const grub_guid_t *guid,
> +				     const grub_efi_guid_t *guid,
>  				     void *data,
>  				     grub_size_t datasize,
>  				     grub_efi_uint32_t attributes);
>  grub_err_t
>  EXPORT_FUNC (grub_efi_set_variable) (const char *var,
> -				     const grub_guid_t *guid,
> +				     const grub_efi_guid_t *guid,
>  				     void *data,
>  				     grub_size_t datasize);
>  grub_err_t
> -EXPORT_FUNC (grub_efi_set_variable_to_string) (const char *name, const grub_guid_t *guid,
> +EXPORT_FUNC (grub_efi_set_variable_to_string) (const char *name, const grub_efi_guid_t *guid,
>  					       const char *value, grub_efi_uint32_t attributes);
>  int
>  EXPORT_FUNC (grub_efi_compare_device_paths) (const grub_efi_device_path_t *dp1,
> diff --git a/include/grub/efiemu/efiemu.h b/include/grub/efiemu/efiemu.h
> index caf0b505f..5325e5839 100644
> --- a/include/grub/efiemu/efiemu.h
> +++ b/include/grub/efiemu/efiemu.h
> @@ -176,26 +176,26 @@ grub_err_t grub_efiemu_loadcore_load (void);
>  struct grub_efiemu_configuration_table
>  {
>    struct grub_efiemu_configuration_table *next;
> -  grub_guid_t guid;
> +  grub_efi_guid_t guid;
>    void * (*get_table) (void *data);
>    void (*unload) (void *data);
>    void *data;
>  };
>  struct grub_efiemu_configuration_table32
>  {
> -  grub_guid_t vendor_guid;
> +  grub_efi_packed_guid_t vendor_guid;
>    grub_efi_uint32_t vendor_table;
>  } GRUB_PACKED;
>  typedef struct grub_efiemu_configuration_table32 grub_efiemu_configuration_table32_t;
>  struct grub_efiemu_configuration_table64
>  {
> -  grub_guid_t vendor_guid;
> +  grub_efi_packed_guid_t vendor_guid;
>    grub_efi_uint64_t vendor_table;
>  } GRUB_PACKED;
>  typedef struct grub_efiemu_configuration_table64 grub_efiemu_configuration_table64_t;
> -grub_err_t grub_efiemu_unregister_configuration_table (grub_guid_t guid);
> +grub_err_t grub_efiemu_unregister_configuration_table (grub_efi_guid_t guid);
>  grub_err_t
> -grub_efiemu_register_configuration_table (grub_guid_t guid,
> +grub_efiemu_register_configuration_table (grub_efi_guid_t guid,
>  					  void * (*get_table) (void *data),
>  					  void (*unload) (void *data),
>  					  void *data);
> diff --git a/include/grub/efiemu/runtime.h b/include/grub/efiemu/runtime.h
> index c9ad9fdfa..36d2dedf4 100644
> --- a/include/grub/efiemu/runtime.h
> +++ b/include/grub/efiemu/runtime.h
> @@ -29,7 +29,7 @@ struct grub_efiemu_ptv_rel
>  
>  struct efi_variable
>  {
> -  grub_guid_t guid;
> +  grub_efi_packed_guid_t guid;
>    grub_uint32_t namelen;
>    grub_uint32_t size;
>    grub_efi_uint32_t attributes;
> diff --git a/include/grub/gpt_partition.h b/include/grub/gpt_partition.h
> index 020e71920..7a93f4329 100644
> --- a/include/grub/gpt_partition.h
> +++ b/include/grub/gpt_partition.h
> @@ -22,6 +22,15 @@
>  #include <grub/types.h>
>  #include <grub/partition.h>
>  
> +struct grub_gpt_part_guid
> +{
> +  grub_uint32_t data1;
> +  grub_uint16_t data2;
> +  grub_uint16_t data3;
> +  grub_uint8_t data4[8];
> +} GRUB_PACKED;
> +typedef struct grub_gpt_part_guid grub_gpt_part_guid_t;
> +
>  #define GRUB_GPT_PARTITION_TYPE_EMPTY \
>    { 0x0, 0x0, 0x0, \
>      { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } \
> @@ -61,8 +70,8 @@ struct grub_gpt_header
>  
>  struct grub_gpt_partentry
>  {
> -  grub_guid_t type;
> -  grub_guid_t guid;
> +  grub_gpt_part_guid_t type;
> +  grub_gpt_part_guid_t guid;
>    grub_uint64_t start;
>    grub_uint64_t end;
>    grub_uint64_t attrib;
> diff --git a/include/grub/types.h b/include/grub/types.h
> index 0d96006fe..756a29a08 100644
> --- a/include/grub/types.h
> +++ b/include/grub/types.h
> @@ -370,13 +370,4 @@ static inline void grub_set_unaligned64 (void *ptr, grub_uint64_t val)
>  # define grub_absolute_pointer(val) ((void *) (val))
>  #endif
>  
> -struct grub_guid
> -{
> -  grub_uint32_t data1;
> -  grub_uint16_t data2;
> -  grub_uint16_t data3;
> -  grub_uint8_t data4[8];
> -} GRUB_PACKED;
> -typedef struct grub_guid grub_guid_t;
> -
>  #endif /* ! GRUB_TYPES_HEADER */
> diff --git a/util/grub-install.c b/util/grub-install.c
> index 1ad04db36..e20820d9e 100644
> --- a/util/grub-install.c
> +++ b/util/grub-install.c
> @@ -728,7 +728,7 @@ is_prep_partition (grub_device_t dev)
>        if (grub_disk_read (dev->disk, p->offset, p->index,
>  			  sizeof (gptdata), &gptdata) == 0)
>  	{
> -	  const grub_guid_t template = {
> +	  const grub_gpt_part_guid_t template = {
>  	    grub_cpu_to_le32_compile_time (0x9e1a2d38),
>  	    grub_cpu_to_le16_compile_time (0xc612),
>  	    grub_cpu_to_le16_compile_time (0x4316),
> diff --git a/util/grub-probe.c b/util/grub-probe.c
> index 65c1ca3f8..446bd2553 100644
> --- a/util/grub-probe.c
> +++ b/util/grub-probe.c
> @@ -133,7 +133,7 @@ get_targets_string (void)
>  }
>  
>  static int
> -print_gpt_guid (grub_guid_t guid)
> +print_gpt_guid (grub_gpt_part_guid_t guid)
>  {
>    guid.data1 = grub_le_to_cpu32 (guid.data1);
>    guid.data2 = grub_le_to_cpu16 (guid.data2);


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

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

* Re: [PATCH 0/4] Revert unified GUID struct
  2023-10-05 10:47 [PATCH 0/4] Revert unified GUID struct Oliver Steffen
                   ` (3 preceding siblings ...)
  2023-10-05 10:47 ` [PATCH 4/4] guid: un-unifiy GUID types Oliver Steffen
@ 2023-10-05 16:26 ` Vladimir 'phcoder' Serbinenko
  4 siblings, 0 replies; 10+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2023-10-05 16:26 UTC (permalink / raw)
  To: Oliver Steffen
  Cc: The development of GRUB 2, Daniel Kiper, Gerd Hoffmann,
	Tobias Powalowski, Pedro Miguel Justo, Laszlo Ersek,
	Frank Scheiner, John Paul Adrian Glaubitz, Ard Biesheuvel


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

I have a proper solution and should be able to test it today. I'll send it
in tomorrow

Le jeu. 5 oct. 2023, 12:48, Oliver Steffen <osteffen@redhat.com> a écrit :

> The introduction of the new grub_guid struct which unified the three
> previously existing guid structs [1,2] causes regressions on some
> architectures [3..7].
>
> Since there is no satisfactory solution yet and I am too short on time
> to properly solve this quickly, and not to delay the release of Grub
> 2.12 any further, I propose to undo these changes and revisit the topic
> of guid data types and related functions at a later point. This would
> also give us more time for testing, on a wider set of architectures.
>
> This series reverts the unified guid struct and the introduction of the
> %pG printf format specifier, introduced by these commits:
>
>   6ad116e5f guid: Make use of GUID printf format specifier
>   f82dbf2bd kern/misc: Add a format specifier GUIDs
>   06edd40db guid: Unify GUID types
>
> It also fixes code introduced by these commits, since it makes use of
> the unified GUID struct:
>
>   e83a88f6e efi: Add grub_efi_set_variable_to_string()
>   e0fa7dc84 bli: Add a module for the Boot Loader Interface
>
> This restores the guid handling to the state from before 06edd40db,
> which has been working on all platforms for many years.
>
> Oliver
>
> bli patch series:
> [1] https://mail.gnu.org/archive/html/grub-devel/2023-05/msg00156.html
>
> GUID unification:
> [2] https://mail.gnu.org/archive/html/grub-devel/2023-05/msg00142.html
>
> Itanium trap issue:
> [3] https://mail.gnu.org/archive/html/grub-devel/2023-08/msg00019.html
>
> bli blank screen issue:
> [4] https://mail.gnu.org/archive/html/grub-devel/2023-07/msg00077.html
> [5] https://mail.gnu.org/archive/html/grub-devel/2023-08/msg00030.html
> [6] https://mail.gnu.org/archive/html/grub-devel/2023-09/msg00093.html
> [7] https://mail.gnu.org/archive/html/grub-devel/2023-10/msg00000.html
>
> Oliver Steffen (4):
>   bli: don't use %pG format specifier
>   Revert "guid: Make use of GUID printf format specifier"
>   Revert "kern/misc: Add a format specifier GUIDs"
>   guid: un-unifiy GUID types
>
>  grub-core/commands/acpi.c            |  4 +-
>  grub-core/commands/bli.c             | 11 +++-
>  grub-core/commands/efi/efifwsetup.c  |  4 +-
>  grub-core/commands/efi/loadbios.c    | 14 ++---
>  grub-core/commands/efi/lsefi.c       | 17 ++++--
>  grub-core/commands/efi/lsefisystab.c | 10 ++--
>  grub-core/commands/efi/lssal.c       |  4 +-
>  grub-core/commands/efi/smbios.c      | 12 ++---
>  grub-core/commands/efi/tpm.c         |  6 +--
>  grub-core/commands/probe.c           | 14 +++--
>  grub-core/disk/efi/efidisk.c         |  4 +-
>  grub-core/disk/ldm.c                 |  2 +-
>  grub-core/efiemu/i386/pc/cfgtables.c |  6 +--
>  grub-core/efiemu/main.c              |  4 +-
>  grub-core/efiemu/runtime/efiemu.c    | 14 ++---
>  grub-core/kern/efi/acpi.c            | 12 ++---
>  grub-core/kern/efi/efi.c             | 52 +++++++++++++-----
>  grub-core/kern/efi/fdt.c             |  2 +-
>  grub-core/kern/efi/init.c            |  2 +-
>  grub-core/kern/efi/sb.c              |  4 +-
>  grub-core/kern/misc.c                | 81 ++++++++--------------------
>  grub-core/loader/efi/fdt.c           |  2 +-
>  grub-core/loader/efi/linux.c         |  4 +-
>  grub-core/loader/i386/xnu.c          | 13 +++--
>  grub-core/loader/ia64/efi/linux.c    |  2 +-
>  grub-core/net/drivers/efi/efinet.c   |  4 +-
>  grub-core/partmap/gpt.c              |  4 +-
>  grub-core/term/efi/console.c         |  2 +-
>  grub-core/term/efi/serial.c          |  2 +-
>  grub-core/video/efi_gop.c            |  8 +--
>  grub-core/video/efi_uga.c            |  2 +-
>  include/grub/efi/api.h               | 64 ++++++++++++++--------
>  include/grub/efi/efi.h               | 18 +++----
>  include/grub/efiemu/efiemu.h         | 10 ++--
>  include/grub/efiemu/runtime.h        |  2 +-
>  include/grub/gpt_partition.h         | 13 ++++-
>  include/grub/types.h                 |  9 ----
>  util/grub-install.c                  |  2 +-
>  util/grub-probe.c                    |  2 +-
>  39 files changed, 238 insertions(+), 204 deletions(-)
>
> --
> 2.41.0
>
>

[-- Attachment #1.2: Type: text/html, Size: 5955 bytes --]

[-- Attachment #2: Type: text/plain, Size: 141 bytes --]

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

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

end of thread, other threads:[~2023-10-05 16:27 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-05 10:47 [PATCH 0/4] Revert unified GUID struct Oliver Steffen
2023-10-05 10:47 ` [PATCH 1/4] bli: don't use %pG format specifier Oliver Steffen
2023-10-05 14:24   ` Laszlo Ersek
2023-10-05 10:47 ` [PATCH 2/4] Revert "guid: Make use of GUID printf format specifier" Oliver Steffen
2023-10-05 14:28   ` Laszlo Ersek
2023-10-05 10:47 ` [PATCH 3/4] Revert "kern/misc: Add a format specifier GUIDs" Oliver Steffen
2023-10-05 14:29   ` Laszlo Ersek
2023-10-05 10:47 ` [PATCH 4/4] guid: un-unifiy GUID types Oliver Steffen
2023-10-05 14:38   ` Laszlo Ersek
2023-10-05 16:26 ` [PATCH 0/4] Revert unified GUID struct Vladimir 'phcoder' Serbinenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.