From: Sergiu Moga Date: Mon, 24 Apr 2023 17:13:18 +0000 (+0300) Subject: plat/common/acpi: Allow getting `RSDP` through `UEFI` System Table X-Git-Tag: RELEASE-0.14.0~56 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=b81f13cf8514195c901c9a0b668c0905c544e152;p=unikraft%2Funikraft.git plat/common/acpi: Allow getting `RSDP` through `UEFI` System Table 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 Reviewed-by: Dragos Petre Reviewed-by: Marco Schlumpp Approved-by: Razvan Deaconescu Tested-by: Unikraft CI GitHub-Closes: #911 --- diff --git a/plat/common/x86/acpi.c b/plat/common/x86/acpi.c index a9648e5da..68432b628 100644 --- a/plat/common/x86/acpi.c +++ b/plat/common/x86/acpi.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #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(); } diff --git a/plat/kvm/include/kvm/efi.h b/plat/kvm/include/kvm/efi.h index 0ca3c829a..88570d97c 100644 --- a/plat/kvm/include/kvm/efi.h +++ b/plat/kvm/include/kvm/efi.h @@ -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;