From ff65a103917a4766d65174ae4ee7d4eac83d698a Mon Sep 17 00:00:00 2001 From: Victor Sun Date: Thu, 28 Feb 2019 15:06:43 +0800 Subject: [PATCH] HV: vm_configs array refinement - merge sharing_config.c and partition_config.c to vm_config.c; - make vm_configs[] static; Tracked-On: #2291 Signed-off-by: Victor Sun Acked-by: Eddie Dong --- hypervisor/Makefile | 5 +- .../arch/x86/configs/partition_config.c | 45 ------------- hypervisor/arch/x86/configs/sharing_config.c | 22 ------- hypervisor/arch/x86/configs/vm_config.c | 66 +++++++++++++++++++ hypervisor/include/arch/x86/vm_config.h | 11 +--- 5 files changed, 68 insertions(+), 81 deletions(-) delete mode 100644 hypervisor/arch/x86/configs/partition_config.c delete mode 100644 hypervisor/arch/x86/configs/sharing_config.c diff --git a/hypervisor/Makefile b/hypervisor/Makefile index d663a02ea..d522ac90c 100644 --- a/hypervisor/Makefile +++ b/hypervisor/Makefile @@ -133,10 +133,7 @@ C_SRCS += arch/x86/init.c # configuration component C_SRCS += arch/x86/configs/vm_config.c -ifeq ($(CONFIG_SHARING_MODE),y) -C_SRCS += arch/x86/configs/sharing_config.c -else ifeq ($(CONFIG_PARTITION_MODE),y) -C_SRCS += arch/x86/configs/partition_config.c +ifeq ($(CONFIG_PARTITION_MODE),y) C_SRCS += arch/x86/configs/$(CONFIG_BOARD)/ve820.c C_SRCS += arch/x86/configs/$(CONFIG_BOARD)/pt_dev.c endif diff --git a/hypervisor/arch/x86/configs/partition_config.c b/hypervisor/arch/x86/configs/partition_config.c deleted file mode 100644 index 5ba3e4087..000000000 --- a/hypervisor/arch/x86/configs/partition_config.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2019 Intel Corporation. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include -#include - -#define INIT_VM_CONFIG(idx) \ - { \ - .type = VM##idx##_CONFIG_TYPE, \ - .name = VM##idx##_CONFIG_NAME, \ - .pcpu_bitmap = VM##idx##_CONFIG_PCPU_BITMAP, \ - .guest_flags = VM##idx##_CONFIG_FLAGS, \ - .memory = { \ - .start_hpa = VM##idx##_CONFIG_MEM_START_HPA, \ - .size = VM##idx##_CONFIG_MEM_SIZE, \ - }, \ - .os_config = { \ - .name = VM##idx##_CONFIG_OS_NAME, \ - .bootargs = VM##idx##_CONFIG_OS_BOOTARGS, \ - }, \ - .vm_vuart = true, \ - .pci_ptdev_num = VM##idx##_CONFIG_PCI_PTDEV_NUM, \ - .pci_ptdevs = vm##idx##_pci_ptdevs, \ - }, - -struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] __aligned(PAGE_SIZE) = { -#ifdef VM0_CONFIGURED - INIT_VM_CONFIG(0) -#endif - -#ifdef VM1_CONFIGURED - INIT_VM_CONFIG(1) -#endif - -#ifdef VM2_CONFIGURED - INIT_VM_CONFIG(2) -#endif - -#ifdef VM3_CONFIGURED - INIT_VM_CONFIG(3) -#endif -}; diff --git a/hypervisor/arch/x86/configs/sharing_config.c b/hypervisor/arch/x86/configs/sharing_config.c deleted file mode 100644 index 0668fa859..000000000 --- a/hypervisor/arch/x86/configs/sharing_config.c +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 2018 Intel Corporation. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ -#include -#include - -struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] __aligned(PAGE_SIZE) = { - { - .type = SOS_VM, - .name = SOS_VM_CONFIG_NAME, - .guest_flags = SOS_VM_CONFIG_GUEST_FLAGS, - .memory = { - .start_hpa = 0x0UL, - .size = CONFIG_SOS_RAM_SIZE, - }, - .os_config = { - .name = SOS_VM_CONFIG_OS_NAME, - }, - }, -}; diff --git a/hypervisor/arch/x86/configs/vm_config.c b/hypervisor/arch/x86/configs/vm_config.c index f5d8f3093..b1c742712 100644 --- a/hypervisor/arch/x86/configs/vm_config.c +++ b/hypervisor/arch/x86/configs/vm_config.c @@ -8,6 +8,72 @@ #include #include #include +#include +#ifndef CONFIG_PARTITION_MODE +#include + +static struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] __aligned(PAGE_SIZE) = { + { + .type = SOS_VM, + .name = SOS_VM_CONFIG_NAME, + .guest_flags = SOS_VM_CONFIG_GUEST_FLAGS, + .memory = { + .start_hpa = 0x0UL, + .size = CONFIG_SOS_RAM_SIZE, + }, + .os_config = { + .name = SOS_VM_CONFIG_OS_NAME, + }, + }, +}; +#else +#include + +#define INIT_VM_CONFIG(idx) \ + { \ + .type = VM##idx##_CONFIG_TYPE, \ + .name = VM##idx##_CONFIG_NAME, \ + .pcpu_bitmap = VM##idx##_CONFIG_PCPU_BITMAP, \ + .guest_flags = VM##idx##_CONFIG_FLAGS, \ + .memory = { \ + .start_hpa = VM##idx##_CONFIG_MEM_START_HPA, \ + .size = VM##idx##_CONFIG_MEM_SIZE, \ + }, \ + .os_config = { \ + .name = VM##idx##_CONFIG_OS_NAME, \ + .bootargs = VM##idx##_CONFIG_OS_BOOTARGS, \ + }, \ + .vm_vuart = true, \ + .pci_ptdev_num = VM##idx##_CONFIG_PCI_PTDEV_NUM, \ + .pci_ptdevs = vm##idx##_pci_ptdevs, \ + } + +static struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] __aligned(PAGE_SIZE) = { +#ifdef VM0_CONFIGURED + INIT_VM_CONFIG(0), +#endif + +#ifdef VM1_CONFIGURED + INIT_VM_CONFIG(1), +#endif + +#ifdef VM2_CONFIGURED + INIT_VM_CONFIG(2), +#endif + +#ifdef VM3_CONFIGURED + INIT_VM_CONFIG(3), +#endif +}; +#endif + +/* + * @pre vm_id < CONFIG_MAX_VM_NUM + */ +struct acrn_vm_config *get_vm_config(uint16_t vm_id) +{ + return &vm_configs[vm_id]; +} /** * @pre vm_config != NULL diff --git a/hypervisor/include/arch/x86/vm_config.h b/hypervisor/include/arch/x86/vm_config.h index 5085faf07..a6a4614d3 100644 --- a/hypervisor/include/arch/x86/vm_config.h +++ b/hypervisor/include/arch/x86/vm_config.h @@ -64,16 +64,7 @@ struct acrn_vm_config { #endif } __aligned(8); -extern struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM]; - -/* - * @pre vm_id < CONFIG_MAX_VM_NUM - */ -static inline struct acrn_vm_config *get_vm_config(uint16_t vm_id) -{ - return &vm_configs[vm_id]; -} - +struct acrn_vm_config *get_vm_config(uint16_t vm_id); int32_t sanitize_vm_config(void); #endif /* VM_CONFIG_H_ */