]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
plat/common/acpi: Allow getting `RSDP` through `UEFI` System Table
authorSergiu Moga <sergiu.moga@protonmail.com>
Mon, 24 Apr 2023 17:13:18 +0000 (20:13 +0300)
committerUnikraft <monkey@unikraft.io>
Fri, 11 Aug 2023 15:57:48 +0000 (15:57 +0000)
First check for the presence of `RSDP` in the `UEFI` System Table's
Configuration Tables. If it does not exist, fallback on the legacy
BIOS ROM Area.

Signed-off-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Dragos Petre <dragos.petre27@gmail.com>
Reviewed-by: Marco Schlumpp <marco@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #911

plat/common/x86/acpi.c
plat/kvm/include/kvm/efi.h

index a9648e5dae520075833d7a7e60e4c1147708c507..68432b6282a8bc908d90565225e9045944f62a42 100644 (file)
@@ -37,6 +37,7 @@
 #include <x86/acpi/acpi.h>
 #include <string.h>
 #include <errno.h>
+#include <kvm/efi.h>
 #include <uk/plat/common/bootinfo.h>
 
 #define RSDP10_LEN             20
@@ -137,6 +138,41 @@ static void acpi_list_tables(void)
 }
 #endif /* UK_DEBUG */
 
+static struct acpi_rsdp *acpi_get_efi_st_rsdp(void)
+{
+       struct ukplat_bootinfo *bi = ukplat_bootinfo_get();
+       uk_efi_uintn_t ct_count, i;
+       struct uk_efi_cfg_tbl *ct;
+       struct acpi_rsdp *rsdp;
+
+       UK_ASSERT(bi);
+
+       if (!bi->efi_st)
+               return NULL;
+
+       ct = ((struct uk_efi_sys_tbl *)bi->efi_st)->configuration_table;
+       ct_count = ((struct uk_efi_sys_tbl *)bi->efi_st)->number_of_table_entries;
+
+       UK_ASSERT(ct);
+       UK_ASSERT(ct_count);
+
+       rsdp = NULL;
+       for (i = 0; i < ct_count; i++)
+               if (!memcmp(&ct[i].vendor_guid, UK_EFI_ACPI20_TABLE_GUID,
+                           sizeof(ct[i].vendor_guid))) {
+                       rsdp = ct[i].vendor_table;
+
+                       break;
+               } else if (!memcmp(&ct[i].vendor_guid, UK_EFI_ACPI10_TABLE_GUID,
+                                sizeof(ct[i].vendor_guid))) {
+                       rsdp = ct[i].vendor_table;
+               }
+
+       uk_pr_debug("ACPI RSDP present at %p\n", rsdp);
+
+       return rsdp;
+}
+
 #if defined(__X86_64__)
 static struct acpi_rsdp *acpi_get_bios_rom_rsdp(void)
 {
@@ -155,6 +191,12 @@ static struct acpi_rsdp *acpi_get_bios_rom_rsdp(void)
 
 static struct acpi_rsdp *acpi_get_rsdp(void)
 {
+       struct acpi_rsdp *rsdp;
+
+       rsdp = acpi_get_efi_st_rsdp();
+       if (rsdp)
+               return rsdp;
+
        return acpi_get_bios_rom_rsdp();
 }
 
index 0ca3c829a28eac1cfa4484eb7028ed018951ef88..88570d97cf7011444324b5346562af3d89e2ccc8 100644 (file)
@@ -516,6 +516,22 @@ struct uk_efi_mem_attr_tbl {
        struct uk_efi_mem_desc entry[1];
 };
 
+#define UK_EFI_ACPI10_TABLE_GUID                                       \
+       (&(struct uk_efi_guid){                                         \
+               .b0_3 = 0xeb9d2d30,                                     \
+               .b4_5 = 0x2d88,                                         \
+               .b6_7 = 0x11d3,                                         \
+               .b8_15 = {0x9a, 0x16, 0x00, 0x90,                       \
+                         0x27, 0x3f, 0xc1, 0x4d},                      \
+       })
+#define UK_EFI_ACPI20_TABLE_GUID                                       \
+       (&(struct uk_efi_guid){                                         \
+               .b0_3 = 0x8868e871,                                     \
+               .b4_5 = 0xe4f1,                                         \
+               .b6_7 = 0x11d3,                                         \
+               .b8_15 = {0xbc, 0x22, 0x00, 0x80,                       \
+                         0xc7, 0x3c, 0x88, 0x81},                      \
+       })
 struct uk_efi_cfg_tbl {
        struct uk_efi_guid vendor_guid;
        void *vendor_table;