efi_loader: Install the ACPI table from the bloblist
authorSimon Glass <sjg@chromium.org>
Thu, 6 Mar 2025 14:31:24 +0000 (07:31 -0700)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Fri, 11 Apr 2025 11:20:37 +0000 (13:20 +0200)
When BLOBLIST_TABLES is used, the ACPI tables are not currently added to
the list of EFI tables. While we don't want to create a new memory
region, we do want to tell EFI about the tables.

Fix this by covering this case. At some point the non-bloblist code can
likely be removed.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 3da59ee9579 ("efi_loader: Avoid mapping the ACPI tables twice")
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
lib/efi_loader/efi_acpi.c

index 4422b31..046986a 100644 (file)
@@ -7,6 +7,7 @@
 
 #define LOG_CATEGORY LOGC_EFI
 
+#include <bloblist.h>
 #include <efi_loader.h>
 #include <log.h>
 #include <mapmem.h>
@@ -34,25 +35,38 @@ efi_status_t efi_acpi_register(void)
         * add_u_boot_and_runtime(). At some point that function could create a
         * more detailed map.
         */
-       if (IS_ENABLED(CONFIG_BLOBLIST_TABLES))
-               return EFI_SUCCESS;
-
-       /* Mark space used for tables */
-       start = ALIGN_DOWN(gd->arch.table_start, EFI_PAGE_MASK);
-       end = ALIGN(gd->arch.table_end, EFI_PAGE_MASK);
-       ret = efi_add_memory_map(start, end - start, EFI_ACPI_RECLAIM_MEMORY);
-       if (ret != EFI_SUCCESS)
-               return ret;
-       if (gd->arch.table_start_high) {
-               start = ALIGN_DOWN(gd->arch.table_start_high, EFI_PAGE_MASK);
-               end = ALIGN(gd->arch.table_end_high, EFI_PAGE_MASK);
+       if (IS_ENABLED(CONFIG_BLOBLIST_TABLES)) {
+               int size;
+               void *tab = bloblist_get_blob(BLOBLISTT_ACPI_TABLES, &size);
+
+               if (!tab)
+                       return EFI_NOT_FOUND;
+               addr = map_to_sysmem(tab);
+
+               ret = efi_add_memory_map(addr, size,
+                                        EFI_ACPI_RECLAIM_MEMORY);
+               if (ret != EFI_SUCCESS)
+                       return ret;
+       } else {
+               /* Mark space used for tables */
+               start = ALIGN_DOWN(gd->arch.table_start, EFI_PAGE_MASK);
+               end = ALIGN(gd->arch.table_end, EFI_PAGE_MASK);
                ret = efi_add_memory_map(start, end - start,
                                         EFI_ACPI_RECLAIM_MEMORY);
                if (ret != EFI_SUCCESS)
                        return ret;
-       }
+               if (gd->arch.table_start_high) {
+                       start = ALIGN_DOWN(gd->arch.table_start_high,
+                                          EFI_PAGE_MASK);
+                       end = ALIGN(gd->arch.table_end_high, EFI_PAGE_MASK);
+                       ret = efi_add_memory_map(start, end - start,
+                                                EFI_ACPI_RECLAIM_MEMORY);
+                       if (ret != EFI_SUCCESS)
+                               return ret;
+               }
 
-       addr = gd_acpi_start();
+               addr = gd_acpi_start();
+       }
        log_debug("EFI using ACPI tables at %lx\n", addr);
 
        /* And expose them to our EFI payload */