Skip to content

Commit 5793973

Browse files
jsun26intelwenlingz
authored andcommitted
HV: search rsdp from e820 acpi reclaim region
Per ACPI 6.2 spec, chapter 5.2.5.2 "Finding the RSDP on UEFI Enabled Systems": In Unified Extensible Firmware Interface (UEFI) enabled systems, a pointer to the RSDP structure exists within the EFI System Table. The OS loader is provided a pointer to the EFI System Table at invocation. The OS loader must retrieve the pointer to the RSDP structure from the EFI System Table and convey the pointer to OSPM, using an OS dependent data structure, as part of the hand off of control from the OS loader to the OS. So when ACRN boot from direct mode on a UEFI enabled system, hypervisor might be failed to get rsdp by seaching rsdp in legacy EBDA or 0xe0000~0xfffff region, but it still have chance to get rsdp by seaching it in e820 ACPI reclaimable region with some edk2 based BIOS. The patch will search rsdp from e820 ACPI reclaim region When failed to get rsdp from legacy region. Tracked-On: #4301 Signed-off-by: Victor Sun <victor.sun@intel.com> Reviewed-by: Fei Li <fei1.li@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent fc78013 commit 5793973

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

hypervisor/boot/acpi_base.c

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,17 @@
3535
#include <logmsg.h>
3636
#include <acrn_common.h>
3737
#include <util.h>
38+
#include <e820.h>
3839

3940
static struct acpi_table_rsdp *acpi_rsdp;
4041

41-
static struct acpi_table_rsdp *found_rsdp(char *base, int32_t length)
42+
static struct acpi_table_rsdp *found_rsdp(char *base, uint64_t length)
4243
{
4344
struct acpi_table_rsdp *rsdp, *ret = NULL;
44-
int32_t ofs;
45+
uint64_t ofs;
4546

4647
/* search on 16-byte boundaries */
47-
for (ofs = 0; ofs < length; ofs += 16) {
48+
for (ofs = 0UL; ofs < length; ofs += 16UL) {
4849
rsdp = (struct acpi_table_rsdp *)(base + ofs);
4950

5051
/* compare signature, validate checksum */
@@ -76,11 +77,27 @@ static struct acpi_table_rsdp *get_rsdp(void)
7677
/* EBDA is addressed by the 16 bit pointer at 0x40E */
7778
addr = (uint16_t *)hpa2hva(0x40eUL);
7879

79-
rsdp = found_rsdp((char *)hpa2hva((uint64_t)(*addr) << 4U), 0x400);
80+
rsdp = found_rsdp((char *)hpa2hva((uint64_t)(*addr) << 4U), 0x400UL);
8081
}
8182
if (rsdp == NULL) {
8283
/* Check the upper memory BIOS space, 0xe0000 - 0xfffff. */
83-
rsdp = found_rsdp((char *)hpa2hva(0xe0000UL), 0x20000);
84+
rsdp = found_rsdp((char *)hpa2hva(0xe0000UL), 0x20000UL);
85+
}
86+
87+
if (rsdp == NULL) {
88+
/* Check ACPI RECLAIM region, there might be multiple ACPI reclaimable regions. */
89+
uint32_t i;
90+
const struct e820_entry *entry = get_e820_entry();
91+
uint32_t entries_count = get_e820_entries_count();
92+
93+
for (i = 0U; i < entries_count; i++) {
94+
if (entry[i].type == E820_TYPE_ACPI_RECLAIM) {
95+
rsdp = found_rsdp((char *)hpa2hva(entry[i].baseaddr), entry[i].length);
96+
if (rsdp != NULL) {
97+
break;
98+
}
99+
}
100+
}
84101
}
85102

86103
if (rsdp == NULL) {

0 commit comments

Comments
 (0)