From 298044d95b20bf4a8732862e4e825797ee9e8b46 Mon Sep 17 00:00:00 2001 From: Mingqiang Chi Date: Wed, 24 Oct 2018 13:28:13 +0800 Subject: [PATCH] hv: Add MAX_PCPU_NUM in Kconfig --Removed MAX_PCPU_NUM in cpu.h --Changed the default value from 128 to 8 for MAX_PCPU_NUM Tracked-On: #861 Signed-off-by: Mingqiang Chi Reviewed-by: Li, Fei1 Acked-by: Eddie Dong --- hypervisor/arch/x86/Kconfig | 5 +++++ hypervisor/arch/x86/cpu.c | 4 ++-- hypervisor/boot/acpi.c | 6 +++--- hypervisor/boot/include/acpi.h | 2 +- hypervisor/include/arch/x86/cpu.h | 3 --- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/hypervisor/arch/x86/Kconfig b/hypervisor/arch/x86/Kconfig index 478194286..c2dcff41d 100644 --- a/hypervisor/arch/x86/Kconfig +++ b/hypervisor/arch/x86/Kconfig @@ -42,6 +42,11 @@ config MAX_VCPUS_PER_VM range 1 8 default 4 +config MAX_PCPU_NUM + int "Maximum number of PCPU" + range 1 8 + default 8 + config MAX_IOMMU_NUM int "Maximum number of iommu dev" range 1 2 diff --git a/hypervisor/arch/x86/cpu.c b/hypervisor/arch/x86/cpu.c index 33bc107cc..ace52d3b7 100644 --- a/hypervisor/arch/x86/cpu.c +++ b/hypervisor/arch/x86/cpu.c @@ -276,7 +276,7 @@ static void alloc_phy_cpu_data(uint16_t pcpu_num) ASSERT(per_cpu_data_base_ptr != NULL, ""); } -uint16_t __attribute__((weak)) parse_madt(uint32_t lapic_id_array[MAX_PCPU_NUM]) +uint16_t __attribute__((weak)) parse_madt(uint32_t lapic_id_array[CONFIG_MAX_PCPU_NUM]) { static const uint32_t lapic_id[] = {0U, 2U, 4U, 6U}; uint32_t i; @@ -292,7 +292,7 @@ static void init_percpu_data_area(void) { uint16_t i; uint16_t pcpu_num = 0U; - uint32_t lapic_id_array[MAX_PCPU_NUM]; + uint32_t lapic_id_array[CONFIG_MAX_PCPU_NUM]; /* Save all lapic_id detected via parse_mdt in lapic_id_array */ pcpu_num = parse_madt(lapic_id_array); diff --git a/hypervisor/boot/acpi.c b/hypervisor/boot/acpi.c index 145b9a78d..046a03da6 100644 --- a/hypervisor/boot/acpi.c +++ b/hypervisor/boot/acpi.c @@ -227,7 +227,7 @@ static void *get_acpi_tbl(const char *sig) * of Type 0 */ static uint16_t -local_parse_madt(void *madt, uint32_t lapic_id_array[MAX_PCPU_NUM]) +local_parse_madt(void *madt, uint32_t lapic_id_array[CONFIG_MAX_PCPU_NUM]) { uint16_t pcpu_id = 0U; struct acpi_madt_local_apic *processor; @@ -255,7 +255,7 @@ local_parse_madt(void *madt, uint32_t lapic_id_array[MAX_PCPU_NUM]) * set the pcpu_num as 0U to indicate the * potential overflow */ - if (pcpu_id >= MAX_PCPU_NUM) { + if (pcpu_id >= CONFIG_MAX_PCPU_NUM) { pcpu_id = 0U; break; } @@ -270,7 +270,7 @@ local_parse_madt(void *madt, uint32_t lapic_id_array[MAX_PCPU_NUM]) } /* The lapic_id info gotten from madt will be returned in lapic_id_array */ -uint16_t parse_madt(uint32_t lapic_id_array[MAX_PCPU_NUM]) +uint16_t parse_madt(uint32_t lapic_id_array[CONFIG_MAX_PCPU_NUM]) { void *madt; diff --git a/hypervisor/boot/include/acpi.h b/hypervisor/boot/include/acpi.h index a88a423af..4e8125ca0 100644 --- a/hypervisor/boot/include/acpi.h +++ b/hypervisor/boot/include/acpi.h @@ -28,7 +28,7 @@ struct acpi_table_header { uint32_t asl_compiler_revision; }; -uint16_t parse_madt(uint32_t lapic_id_array[MAX_PCPU_NUM]); +uint16_t parse_madt(uint32_t lapic_id_array[CONFIG_MAX_PCPU_NUM]); void *get_dmar_table(void); #endif /* !ACPI_H */ diff --git a/hypervisor/include/arch/x86/cpu.h b/hypervisor/include/arch/x86/cpu.h index 5415c9498..ca2fb6a3a 100644 --- a/hypervisor/include/arch/x86/cpu.h +++ b/hypervisor/include/arch/x86/cpu.h @@ -43,9 +43,6 @@ #define CPU_PAGE_SIZE 0x1000U #define CPU_PAGE_MASK 0xFFFFFFFFFFFFF000UL -/* Assume the max physcial cpu number is 128 */ -#define MAX_PCPU_NUM 128U - #define MMU_PTE_PAGE_SHIFT CPU_PAGE_SHIFT #define MMU_PDE_PAGE_SHIFT 21U