From 5214a60bbf5b1f5cd44928b29a2b77354a299a43 Mon Sep 17 00:00:00 2001 From: "Li, Fei1" Date: Wed, 30 Jan 2019 20:04:16 +0800 Subject: [PATCH] hv: replace improper use of ASSERT with panic for parse_madt ASSERT could be used in some situations, such as, there are some pre-assumption for some code, using ASSERT here for debug. It could not be used for detect error when system booting where panic should be used. Tracked-On: #861 Signed-off-by: Li, Fei1 Acked-by: Eddie Dong --- hypervisor/arch/x86/cpu.c | 2 +- hypervisor/boot/acpi.c | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/hypervisor/arch/x86/cpu.c b/hypervisor/arch/x86/cpu.c index d4655a352..8349c4c7f 100644 --- a/hypervisor/arch/x86/cpu.c +++ b/hypervisor/arch/x86/cpu.c @@ -39,7 +39,7 @@ static void init_percpu_lapic_id(void) pcpu_num = parse_madt(lapic_id_array); if (pcpu_num == 0U) { /* failed to get the physcial cpu number */ - ASSERT(false); + panic("failed to get the physcial cpu number"); } phys_cpu_num = pcpu_num; diff --git a/hypervisor/boot/acpi.c b/hypervisor/boot/acpi.c index 5f8673c5b..24c357158 100644 --- a/hypervisor/boot/acpi.c +++ b/hypervisor/boot/acpi.c @@ -248,15 +248,17 @@ local_parse_madt(struct acpi_table_madt *madt, uint32_t lapic_id_array[CONFIG_MA /* The lapic_id info gotten from madt will be returned in lapic_id_array */ uint16_t parse_madt(uint32_t lapic_id_array[CONFIG_MAX_PCPU_NUM]) { - struct acpi_table_madt *madt; + uint16_t ret = 0U; acpi_rsdp = get_rsdp(); - ASSERT(acpi_rsdp != NULL, "fail to get rsdp"); + if (acpi_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); + } + } - madt = (struct acpi_table_madt *)get_acpi_tbl(ACPI_SIG_MADT); - ASSERT(madt != NULL, "fail to get madt"); - - return local_parse_madt(madt, lapic_id_array); + return ret; } void *get_dmar_table(void)