Hi Ilias, On Mon, 26 May 2025 at 15:01, Ilias Apalodimas <ilias.apalodi...@linaro.org> wrote:
> Hi Paul, > > [...] > > > > bool > > > > +config EFI_DEBUG_SUPPORT_TABLE > > + bool "EFI Debug Support Table" > > + help > > + Select this option if you want to setup the EFI Debug Support > > + Table which is used by the debug agent or an external debugger > to > > + determine loaded image information in a quiescent manner. > > + > > menu "UEFI services" > > > > config EFI_GET_TIME > > diff --git a/lib/efi_loader/efi_boottime.c > b/lib/efi_loader/efi_boottime.c > > index dbebb37dc04..5a4349f8679 100644 > > --- a/lib/efi_loader/efi_boottime.c > > +++ b/lib/efi_loader/efi_boottime.c > > @@ -4001,6 +4001,8 @@ struct efi_system_table __efi_runtime_data systab > = { > > .tables = NULL, > > }; > > > > +struct efi_system_table_pointer __efi_runtime_data * systab_pointer = > NULL; > > + > > /** > > * efi_initialize_system_table() - Initialize system table > > * > > @@ -4035,3 +4037,47 @@ efi_status_t efi_initialize_system_table(void) > > > > return ret; > > } > > + > > +/** > > + * efi_initialize_system_table() - Initialize system table pointer > > + * > > + * Return: status code > > + */ > > +efi_status_t efi_initialize_system_table_pointer(void) > > +{ > > + efi_status_t ret; > > + const int size_4MB = 0x00400000; > > + int pages = efi_size_in_pages(sizeof(struct > efi_system_table_pointer)); > > + int alignment_mask = size_4MB - 1; > > + int real_pages = pages + efi_size_in_pages(size_4MB); > > + u64 addr; > > + u64 aligned_addr; > > + u32 crc32_value; > > + > > + /* Allocate configuration table array */ > > + ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES, > > + EFI_RUNTIME_SERVICES_DATA, > > + real_pages, > > + &addr); > > + > > + if (ret != EFI_SUCCESS) { > > + log_err("Installing EFI system table pointer failed\n"); > > + return ret; > > + } > > + > > + /* alignment to 4MB boundary */ > > + aligned_addr = (addr + alignment_mask) & ~alignment_mask; > > efi_alloc_aligned_pages() does that for you. > But I have similar questions to Heinrich here. Why do you need 4MB? The alignment of this structure is 4MB. Is there a way not to allocate a full page but still fulfill this? The spec said. "A check-summed structure containing the physical address of the EFI system table is created and located on a 4M aligned memory address. A hardware debugger can search memory for this structure to determine the location of the EFI system table." So that's why I need a page aligned with 4MB. This code is actually copied from edk2. So I should replace it with efi_alloc_aligned_pages() right? > > > + > > + systab_pointer = (struct efi_system_table_pointer *)aligned_addr; > > + memset(systab_pointer, 0, sizeof(struct > efi_system_table_pointer)); > > + > > + systab_pointer->signature = EFI_SYSTEM_TABLE_SIGNATURE; > > + systab_pointer->efi_system_table_base = > (efi_physical_addr_t)&systab; > > + systab_pointer->crc32 = 0; > > You are assigning this at the end regardless, so I guess you can skip it > here. > > Will remove. > > + crc32_value = crc32(0, > > + (const unsigned char *)systab_pointer, > > + sizeof(struct efi_system_table_pointer)); > > + systab_pointer->crc32 = crc32_value; > > + > > + return ret; > > +} > > diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c > > index 48f91da5df7..a6b37d994f6 100644 > > --- a/lib/efi_loader/efi_setup.c > > +++ b/lib/efi_loader/efi_setup.c > > @@ -278,6 +278,14 @@ efi_status_t efi_init_obj_list(void) > > if (ret != EFI_SUCCESS) > > goto out; > > > > + /* Initialize system table pointer */ > > + if (IS_ENABLED(CONFIG_EFI_DEBUG_SUPPORT_TABLE)) { > > + ret = efi_initialize_system_table_pointer(); > > + if (ret != EFI_SUCCESS) { > > + goto out; > > + } > > + } > > + > > if (IS_ENABLED(CONFIG_EFI_ECPT)) { > > ret = efi_ecpt_register(); > > if (ret != EFI_SUCCESS) > > -- > > 2.39.5 > > > > Thanks > /Ilias >