HV: refine acpi rsdp initialize interface

In previous code, the rsdp initialization is done in get_rsdp() api implicitly.
The function is called multiple times in following acpi table parsing functions
and the condition (rsdp == NULL) need to be added in each parsing function.
This is not needed since the panic would occur if rsdp is NULL when do acpi
initialization.

Tracked-On: #5626

Signed-off-by: Victor Sun <victor.sun@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
This commit is contained in:
Victor Sun 2021-02-24 11:08:50 +08:00 committed by wenlingz
parent 59de88d6bc
commit ff1f6bc975
3 changed files with 47 additions and 57 deletions

View File

@ -148,6 +148,7 @@ void init_pcpu_pre(bool is_bsp)
early_init_lapic();
init_acpi();
#ifdef CONFIG_ACPI_PARSE_ENABLED
ret = acpi_fixup();
if (ret != 0) {

View File

@ -63,13 +63,14 @@ static struct acpi_table_rsdp *found_rsdp(char *base, uint64_t length)
* If it is NULL, the hypervisor can't be booted
*/
static struct acpi_table_rsdp *get_rsdp(void)
{
return acpi_rsdp;
}
void init_acpi(void)
{
struct acpi_table_rsdp *rsdp = NULL;
/* If acpi_rsdp is already parsed, it will be returned directly */
if (acpi_rsdp != NULL) {
rsdp = acpi_rsdp;
} else {
rsdp = (struct acpi_table_rsdp *)(get_acrn_multiboot_info()->mi_acpi_rsdp_va);
if (rsdp == NULL) {
uint16_t *addr;
@ -106,10 +107,6 @@ static struct acpi_table_rsdp *get_rsdp(void)
/* After RSDP is parsed, it will be assigned to acpi_rsdp */
acpi_rsdp = rsdp;
}
return rsdp;
}
static bool probe_table(uint64_t address, const char *signature)
@ -213,16 +210,11 @@ local_parse_madt(struct acpi_table_madt *madt, uint32_t lapic_id_array[MAX_PCPU_
uint16_t parse_madt(uint32_t lapic_id_array[MAX_PCPU_NUM])
{
uint16_t ret = 0U;
struct acpi_table_rsdp *rsdp = NULL;
rsdp = get_rsdp();
if (rsdp != NULL) {
struct acpi_table_madt *madt = (struct acpi_table_madt *)get_acpi_tbl(ACPI_SIG_MADT);
if (madt != NULL) {
ret = local_parse_madt(madt, lapic_id_array);
}
}
return ret;
}
@ -232,10 +224,7 @@ uint8_t parse_madt_ioapic(struct ioapic_info *ioapic_id_array)
uint8_t ioapic_idx = 0U;
uint64_t entry, end;
const struct acpi_madt_ioapic *ioapic;
const struct acpi_table_madt *madt;
if (get_rsdp() != NULL) {
madt = (const struct acpi_table_madt *)get_acpi_tbl(ACPI_SIG_MADT);
const struct acpi_table_madt *madt = (const struct acpi_table_madt *)get_acpi_tbl(ACPI_SIG_MADT);
if (madt != NULL) {
end = (uint64_t)madt + madt->header.length;
@ -253,7 +242,6 @@ uint8_t parse_madt_ioapic(struct ioapic_info *ioapic_id_array)
}
}
}
}
return ioapic_idx;
}

View File

@ -236,6 +236,7 @@ struct acpi_table_tpm2 {
uint32_t start_method;
} __packed;
void init_acpi(void);
void *get_acpi_tbl(const char *signature);
struct ioapic_info;