On Wed, Sep 13, 2023 at 12:20 PM John Paul Adrian Glaubitz <glaub...@physik.fu-berlin.de> wrote: > > Hi Oliver! > > On Wed, 2023-09-13 at 12:14 +0200, Oliver Steffen wrote: > > On Wed, Sep 13, 2023 at 6:10 AM Pedro Miguel Justo <pm...@texair.net> wrote: > > > > > > > > > I can confirm that, taking [1][2] and making [3] on top of it, my > > > Montvale-based rx2660 machine still boots fine. > > > > Wonderful! Thanks for testing! > > Are you going to submit a patch to fix the issue with the new information? >
We could use Vladimir's patches, if he wants to contribute those. With the change to 32bit alignment, as Pedro tested, of course. They apply nicely on top of the current branch, if this patch from this github repo is also applied: bf7f056b "efi: Deduplicate configuration table search function" Vladimir said that he wanted to work on these patches before they go in. I attached them to this email, for reference, incl. the change to 32bit alignment. Oliver
From c4e4417d3e37d0254390baaf7acb24dfc37c8dd3 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko <phco...@gmail.com> Date: Sun, 13 Aug 2023 09:18:23 +0200 Subject: [PATCH 3/6] types: Split aligned and packed guids Signed-off-by: Vladimir Serbinenko <phco...@gmail.com> --- grub-core/commands/efi/lsefi.c | 2 +- grub-core/efiemu/runtime/efiemu.c | 33 +++++++++++++++++++++---------- grub-core/kern/efi/efi.c | 2 +- grub-core/kern/misc.c | 2 +- grub-core/loader/i386/xnu.c | 2 +- include/grub/efi/api.h | 12 +++++------ include/grub/efiemu/efiemu.h | 4 ++-- include/grub/efiemu/runtime.h | 2 +- include/grub/types.h | 11 ++++++++++- 9 files changed, 46 insertions(+), 24 deletions(-) diff --git a/grub-core/commands/efi/lsefi.c b/grub-core/commands/efi/lsefi.c index 05e2e511e..3ea278a82 100644 --- a/grub-core/commands/efi/lsefi.c +++ b/grub-core/commands/efi/lsefi.c @@ -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_packed_guid_t **protocols; grub_efi_device_path_t *dp; grub_printf ("Handle %p\n", handle); diff --git a/grub-core/efiemu/runtime/efiemu.c b/grub-core/efiemu/runtime/efiemu.c index c84b30652..f6b6d19f7 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_packed_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_packed_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_packed_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_packed_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_packed_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_packed_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_packed_guid_t *vendor_guid, grub_efi_uint32_t attributes, grub_efi_uintn_t data_size, void *data) @@ -597,9 +597,22 @@ struct grub_efi_runtime_services efiemu_runtime_services = .set_virtual_address_map = efiemu_set_virtual_address_map, .convert_pointer = efiemu_convert_pointer, - .get_variable = efiemu_get_variable, - .get_next_variable_name = efiemu_get_next_variable_name, - .set_variable = efiemu_set_variable, + .get_variable = (grub_efi_status_t + (__grub_efi_api *) (grub_efi_char16_t *variable_name, + const grub_guid_t *vendor_guid, + grub_efi_uint32_t *attributes, + grub_efi_uintn_t *data_size, + void *data)) efiemu_get_variable, + .get_next_variable_name = (grub_efi_status_t + (__grub_efi_api *) (grub_efi_uintn_t *variable_name_size, + grub_efi_char16_t *variable_name, + grub_guid_t *vendor_guid)) efiemu_get_next_variable_name, + .set_variable = (grub_efi_status_t + (__grub_efi_api *) (grub_efi_char16_t *variable_name, + const grub_guid_t *vendor_guid, + grub_efi_uint32_t attributes, + grub_efi_uintn_t data_size, + void *data)) efiemu_set_variable, .get_next_high_monotonic_count = efiemu_get_next_high_monotonic_count, .reset_system = efiemu_reset_system diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c index 9bf4f571c..20728af6b 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c @@ -1039,7 +1039,7 @@ grub_efi_find_configuration_table(const grub_guid_t *target_guid) for (i = 0; i < grub_efi_system_table->num_table_entries; i++) { - grub_guid_t *guid = + grub_packed_guid_t *guid = &grub_efi_system_table->configuration_table[i].vendor_guid; if (! grub_memcmp (guid, target_guid, sizeof (grub_guid_t))) diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c index b57249acb..7cee5d75c 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -1068,7 +1068,7 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0, if (*(fmt) == 'G') { ++fmt; - grub_guid_t *guid = (grub_guid_t *)(grub_addr_t) curarg; + grub_packed_guid_t *guid = (grub_packed_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); diff --git a/grub-core/loader/i386/xnu.c b/grub-core/loader/i386/xnu.c index 4e31ce99a..b91e2f840 100644 --- a/grub-core/loader/i386/xnu.c +++ b/grub-core/loader/i386/xnu.c @@ -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_packed_guid_t guid; char guidbuf[64]; /* Retrieve current key. */ diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h index d3eaef3fb..d44d00ad7 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h @@ -730,7 +730,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_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 +974,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_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 +993,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_packed_guid_t guid; } GRUB_PACKED; typedef struct grub_efi_protocol_device_path grub_efi_protocol_device_path_t; @@ -1002,7 +1002,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_packed_guid_t guid; } GRUB_PACKED; typedef struct grub_efi_piwg_device_path grub_efi_piwg_device_path_t; @@ -1287,7 +1287,7 @@ struct grub_efi_boot_services grub_efi_status_t (__grub_efi_api *protocols_per_handle) (grub_efi_handle_t handle, - grub_guid_t ***protocol_buffer, + grub_packed_guid_t ***protocol_buffer, grub_efi_uintn_t *protocol_buffer_count); grub_efi_status_t @@ -1386,7 +1386,7 @@ typedef struct grub_efi_runtime_services grub_efi_runtime_services_t; struct grub_efi_configuration_table { - grub_guid_t vendor_guid; + grub_packed_guid_t vendor_guid; void *vendor_table; } GRUB_PACKED; typedef struct grub_efi_configuration_table grub_efi_configuration_table_t; diff --git a/include/grub/efiemu/efiemu.h b/include/grub/efiemu/efiemu.h index caf0b505f..d6a868e94 100644 --- a/include/grub/efiemu/efiemu.h +++ b/include/grub/efiemu/efiemu.h @@ -183,13 +183,13 @@ struct grub_efiemu_configuration_table }; struct grub_efiemu_configuration_table32 { - grub_guid_t vendor_guid; + grub_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_packed_guid_t vendor_guid; grub_efi_uint64_t vendor_table; } GRUB_PACKED; typedef struct grub_efiemu_configuration_table64 grub_efiemu_configuration_table64_t; diff --git a/include/grub/efiemu/runtime.h b/include/grub/efiemu/runtime.h index c9ad9fdfa..2ff429845 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_packed_guid_t guid; grub_uint32_t namelen; grub_uint32_t size; grub_efi_uint32_t attributes; diff --git a/include/grub/types.h b/include/grub/types.h index 0d96006fe..4028c32bf 100644 --- a/include/grub/types.h +++ b/include/grub/types.h @@ -376,7 +376,16 @@ struct grub_guid grub_uint16_t data2; grub_uint16_t data3; grub_uint8_t data4[8]; -} GRUB_PACKED; +} __attribute__ ((aligned(8))); typedef struct grub_guid grub_guid_t; +struct grub_packed_guid +{ + grub_uint32_t data1; + grub_uint16_t data2; + grub_uint16_t data3; + grub_uint8_t data4[8]; +} __attribute__ ((packed)); +typedef struct grub_packed_guid grub_packed_guid_t; + #endif /* ! GRUB_TYPES_HEADER */ -- 2.41.0
From 61071bac8481a6a3b43a1435674c3835dc9664af Mon Sep 17 00:00:00 2001 From: Oliver Steffen <ostef...@redhat.com> Date: Wed, 13 Sep 2023 20:58:46 +0200 Subject: [PATCH 5/6] types: Use 32bit alignment for guids Signed-off-by: Oliver Steffen <ostef...@redhat.com> --- include/grub/types.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/grub/types.h b/include/grub/types.h index 4028c32bf..1d0e25de3 100644 --- a/include/grub/types.h +++ b/include/grub/types.h @@ -376,7 +376,7 @@ struct grub_guid grub_uint16_t data2; grub_uint16_t data3; grub_uint8_t data4[8]; -} __attribute__ ((aligned(8))); +} __attribute__ ((aligned(4))); typedef struct grub_guid grub_guid_t; struct grub_packed_guid @@ -385,7 +385,7 @@ struct grub_packed_guid grub_uint16_t data2; grub_uint16_t data3; grub_uint8_t data4[8]; -} __attribute__ ((packed)); +} GRUB_PACKED; typedef struct grub_packed_guid grub_packed_guid_t; #endif /* ! GRUB_TYPES_HEADER */ -- 2.41.0
From 3a4ad7847f982f567ae7b4ed8971d412926f8722 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko <phco...@gmail.com> Date: Sun, 13 Aug 2023 09:17:22 +0200 Subject: [PATCH 2/6] gpt: Mark grub_gpt_partentry as aligned to 8 bytes Signed-off-by: Vladimir Serbinenko <phco...@gmail.com> --- include/grub/gpt_partition.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/grub/gpt_partition.h b/include/grub/gpt_partition.h index 020e71920..e271ea9fa 100644 --- a/include/grub/gpt_partition.h +++ b/include/grub/gpt_partition.h @@ -67,7 +67,7 @@ struct grub_gpt_partentry grub_uint64_t end; grub_uint64_t attrib; char name[72]; -} GRUB_PACKED; +} __attribute__((aligned(8))); grub_err_t grub_gpt_partition_map_iterate (grub_disk_t disk, -- 2.41.0
From 6c924bfe65c49328dfa995357139e676fa241536 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko <phco...@gmail.com> Date: Sun, 13 Aug 2023 09:18:53 +0200 Subject: [PATCH 4/6] gpt: Add compile time asserts for guid and gpt_partentry sizes Signed-off-by: Vladimir Serbinenko <phco...@gmail.com> --- grub-core/partmap/gpt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/grub-core/partmap/gpt.c b/grub-core/partmap/gpt.c index 877ceefc3..426f616ae 100644 --- a/grub-core/partmap/gpt.c +++ b/grub-core/partmap/gpt.c @@ -229,6 +229,9 @@ static struct grub_partition_map grub_gpt_partition_map = GRUB_MOD_INIT(part_gpt) { + COMPILE_TIME_ASSERT(sizeof(grub_guid_t) == 16); + COMPILE_TIME_ASSERT(sizeof(grub_packed_guid_t) == 16); + COMPILE_TIME_ASSERT(sizeof(struct grub_gpt_partentry) == 128); grub_partition_map_register (&grub_gpt_partition_map); } -- 2.41.0
From 76b4b607f3da7332d600f130b1110f421a2a1feb Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko <phco...@gmail.com> Date: Sun, 13 Aug 2023 09:15:02 +0200 Subject: [PATCH 1/6] efi: Deduplicate configuration table search function Signed-off-by: Vladimir Serbinenko <phco...@gmail.com> --- grub-core/commands/efi/loadbios.c | 37 ++++++++----------------------- grub-core/commands/efi/lssal.c | 18 +++++---------- grub-core/commands/efi/smbios.c | 30 ++----------------------- grub-core/kern/efi/acpi.c | 28 ++--------------------- grub-core/kern/efi/efi.c | 18 +++++++++++++++ grub-core/kern/efi/fdt.c | 21 +++++------------- include/grub/efi/efi.h | 3 +++ 7 files changed, 46 insertions(+), 109 deletions(-) diff --git a/grub-core/commands/efi/loadbios.c b/grub-core/commands/efi/loadbios.c index 8f6b0ecfc..916633631 100644 --- a/grub-core/commands/efi/loadbios.c +++ b/grub-core/commands/efi/loadbios.c @@ -92,7 +92,6 @@ lock_rom_area (void) static void fake_bios_data (int use_rom) { - unsigned i; void *acpi, *smbios; grub_uint16_t *ebda_seg_ptr, *low_mem_ptr; @@ -101,33 +100,15 @@ fake_bios_data (int use_rom) if ((*ebda_seg_ptr) || (*low_mem_ptr)) return; - acpi = 0; - smbios = 0; - for (i = 0; i < grub_efi_system_table->num_table_entries; i++) - { - grub_guid_t *guid = - &grub_efi_system_table->configuration_table[i].vendor_guid; - - if (! grub_memcmp (guid, &acpi2_guid, sizeof (grub_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))) - { - void *t; - - t = grub_efi_system_table->configuration_table[i].vendor_table; - if (! acpi) - acpi = t; - grub_dprintf ("efi", "ACPI: %p\n", t); - } - else if (! grub_memcmp (guid, &smbios_guid, sizeof (grub_guid_t))) - { - smbios = grub_efi_system_table->configuration_table[i].vendor_table; - grub_dprintf ("efi", "SMBIOS: %p\n", smbios); - } - } + acpi = grub_efi_find_configuration_table(&acpi2_guid); + grub_dprintf ("efi", "ACPI2: %p\n", acpi); + if (!acpi) { + acpi = grub_efi_find_configuration_table(&acpi_guid); + grub_dprintf ("efi", "ACPI1: %p\n", acpi); + } + + smbios = grub_efi_find_configuration_table(&smbios_guid); + grub_dprintf ("efi", "SMBIOS: %p\n", smbios); *ebda_seg_ptr = FAKE_EBDA_SEG; *low_mem_ptr = (FAKE_EBDA_SEG >> 6); diff --git a/grub-core/commands/efi/lssal.c b/grub-core/commands/efi/lssal.c index fd6085f1b..0e36bfcdc 100644 --- a/grub-core/commands/efi/lssal.c +++ b/grub-core/commands/efi/lssal.c @@ -136,22 +136,16 @@ grub_cmd_lssal (struct grub_command *cmd __attribute__ ((unused)), int argc __attribute__ ((unused)), char **args __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; + void *table = grub_efi_find_configuration_table(&guid); - for (i = 0; i < st->num_table_entries; i++) + if (!table) { - if (grub_memcmp (&guid, &t->vendor_guid, - sizeof (grub_guid_t)) == 0) - { - disp_sal (t->vendor_table); - return GRUB_ERR_NONE; - } - t++; + grub_printf ("SAL not found\n"); + return GRUB_ERR_NONE; } - grub_printf ("SAL not found\n"); + + disp_sal (table); return GRUB_ERR_NONE; } diff --git a/grub-core/commands/efi/smbios.c b/grub-core/commands/efi/smbios.c index d77239732..296bedf7b 100644 --- a/grub-core/commands/efi/smbios.c +++ b/grub-core/commands/efi/smbios.c @@ -18,44 +18,18 @@ */ #include <grub/smbios.h> -#include <grub/misc.h> #include <grub/efi/efi.h> -#include <grub/efi/api.h> struct grub_smbios_eps * grub_machine_smbios_get_eps (void) { - unsigned i; static grub_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_system_table->configuration_table[i].vendor_guid; - - if (! grub_memcmp (guid, &smbios_guid, sizeof (grub_guid_t))) - return (struct grub_smbios_eps *) - grub_efi_system_table->configuration_table[i].vendor_table; - } - - return 0; + return (struct grub_smbios_eps *) grub_efi_find_configuration_table(&smbios_guid); } struct grub_smbios_eps3 * grub_machine_smbios_get_eps3 (void) { - unsigned i; static grub_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_system_table->configuration_table[i].vendor_guid; - - if (! grub_memcmp (guid, &smbios3_guid, sizeof (grub_guid_t))) - return (struct grub_smbios_eps3 *) - grub_efi_system_table->configuration_table[i].vendor_table; - } - - return 0; + return (struct grub_smbios_eps3 *) grub_efi_find_configuration_table(&smbios3_guid); } diff --git a/grub-core/kern/efi/acpi.c b/grub-core/kern/efi/acpi.c index 461c77c33..640ba172f 100644 --- a/grub-core/kern/efi/acpi.c +++ b/grub-core/kern/efi/acpi.c @@ -18,42 +18,18 @@ */ #include <grub/acpi.h> -#include <grub/misc.h> #include <grub/efi/efi.h> -#include <grub/efi/api.h> struct grub_acpi_rsdp_v10 * grub_machine_acpi_get_rsdpv1 (void) { - unsigned i; static grub_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_system_table->configuration_table[i].vendor_guid; - - if (! grub_memcmp (guid, &acpi_guid, sizeof (grub_guid_t))) - return (struct grub_acpi_rsdp_v10 *) - grub_efi_system_table->configuration_table[i].vendor_table; - } - return 0; + return (struct grub_acpi_rsdp_v10 *) grub_efi_find_configuration_table(&acpi_guid); } 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; - - for (i = 0; i < grub_efi_system_table->num_table_entries; i++) - { - grub_guid_t *guid = - &grub_efi_system_table->configuration_table[i].vendor_guid; - - if (! grub_memcmp (guid, &acpi20_guid, sizeof (grub_guid_t))) - return (struct grub_acpi_rsdp_v20 *) - grub_efi_system_table->configuration_table[i].vendor_table; - } - return 0; + return (struct grub_acpi_rsdp_v20 *) grub_efi_find_configuration_table(&acpi20_guid); } diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c index a2afd8de9..9bf4f571c 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c @@ -1031,3 +1031,21 @@ grub_efi_compare_device_paths (const grub_efi_device_path_t *dp1, return 0; } + +void * +grub_efi_find_configuration_table(const grub_guid_t *target_guid) +{ + unsigned i; + + for (i = 0; i < grub_efi_system_table->num_table_entries; i++) + { + grub_guid_t *guid = + &grub_efi_system_table->configuration_table[i].vendor_guid; + + if (! grub_memcmp (guid, target_guid, sizeof (grub_guid_t))) + return (void *) + grub_efi_system_table->configuration_table[i].vendor_table; + } + + return 0; +} diff --git a/grub-core/kern/efi/fdt.c b/grub-core/kern/efi/fdt.c index 8fcf43f1b..99e95d34e 100644 --- a/grub-core/kern/efi/fdt.c +++ b/grub-core/kern/efi/fdt.c @@ -23,21 +23,12 @@ void * grub_efi_get_firmware_fdt (void) { - grub_efi_configuration_table_t *tables; static grub_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID; - void *firmware_fdt = NULL; - unsigned int i; - - /* Look for FDT in UEFI config tables. */ - tables = grub_efi_system_table->configuration_table; - - for (i = 0; i < grub_efi_system_table->num_table_entries; i++) - if (grub_memcmp (&tables[i].vendor_guid, &fdt_guid, sizeof (fdt_guid)) == 0) - { - firmware_fdt = tables[i].vendor_table; - grub_dprintf ("linux", "found registered FDT @ %p\n", firmware_fdt); - break; - } - + void *firmware_fdt = grub_efi_find_configuration_table(&fdt_guid); + if (firmware_fdt) { + grub_dprintf ("linux", "found registered FDT @ %p\n", firmware_fdt); + } else { + grub_dprintf ("linux", "not found registered FDT\n"); + } return firmware_fdt; } diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h index 572f7135f..a5cd99e5a 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -119,6 +119,9 @@ extern void (*EXPORT_VAR(grub_efi_net_config)) (grub_efi_handle_t hnd, char **device, char **path); +void * +EXPORT_FUNC (grub_efi_find_configuration_table) (const grub_guid_t *target_guid); + #if defined(__arm__) || defined(__aarch64__) || defined(__riscv) || defined(__loongarch__) void *EXPORT_FUNC(grub_efi_get_firmware_fdt)(void); grub_err_t EXPORT_FUNC(grub_efi_get_ram_base)(grub_addr_t *); -- 2.41.0
From 42c04927e05d59e3a8920bff16db8b6b54f6f9c0 Mon Sep 17 00:00:00 2001 From: Oliver Steffen <ostef...@redhat.com> Date: Wed, 13 Sep 2023 21:03:46 +0200 Subject: [PATCH 6/6] gpt: use 32bit alignment for grub_gpt_partentry Signed-off-by: Oliver Steffen <ostef...@redhat.com> --- include/grub/gpt_partition.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/grub/gpt_partition.h b/include/grub/gpt_partition.h index e271ea9fa..7defd731a 100644 --- a/include/grub/gpt_partition.h +++ b/include/grub/gpt_partition.h @@ -67,7 +67,7 @@ struct grub_gpt_partentry grub_uint64_t end; grub_uint64_t attrib; char name[72]; -} __attribute__((aligned(8))); +} __attribute__((aligned(4))); grub_err_t grub_gpt_partition_map_iterate (grub_disk_t disk, -- 2.41.0
_______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel