From 56c193851a26f50d5da21b295cbe21f0859b5158 Mon Sep 17 00:00:00 2001 From: Victor Sun Date: Tue, 2 Apr 2019 11:04:36 +0800 Subject: [PATCH] HV: introduce scenario Kconfig for sharing mode Previously the vm_configs[] is defined separately for sharing mode and partition mode, but the concept of hypervisor mode will be removed. Instead we will introduce scenario Kconfig for hypervisor to load different vm configurations. SDC(Software Defined Cockpit) is a typical scenario that ACRN supported so we introduce this scenario for previously sharing mode and move its configurations to scenarios/sdc folder. The configuration could be used for all boards reference. Tracked-On: #2291 Signed-off-by: Victor Sun Acked-by: Eddie Dong --- hypervisor/Makefile | 8 ++++++ hypervisor/arch/x86/Kconfig | 14 ++++++++++ hypervisor/arch/x86/configs/apl-mrb/sos_vm.h | 1 - hypervisor/arch/x86/configs/apl-up2/sos_vm.h | 1 - hypervisor/arch/x86/configs/dnv-cb2/sos_vm.h | 1 - hypervisor/arch/x86/configs/nuc6cayh/sos_vm.h | 1 - .../arch/x86/configs/nuc7i7bnh/sos_vm.h | 1 - hypervisor/arch/x86/configs/sos_vm.h | 21 -------------- hypervisor/arch/x86/configs/vm_config.c | 19 ++----------- hypervisor/include/arch/x86/vm_config.h | 2 -- hypervisor/scenarios/sdc/pt_dev.c | 10 +++++++ hypervisor/scenarios/sdc/vm_configurations.h | 28 +++++++++++++++++++ 12 files changed, 62 insertions(+), 45 deletions(-) delete mode 120000 hypervisor/arch/x86/configs/apl-mrb/sos_vm.h delete mode 120000 hypervisor/arch/x86/configs/apl-up2/sos_vm.h delete mode 120000 hypervisor/arch/x86/configs/dnv-cb2/sos_vm.h delete mode 120000 hypervisor/arch/x86/configs/nuc6cayh/sos_vm.h delete mode 120000 hypervisor/arch/x86/configs/nuc7i7bnh/sos_vm.h delete mode 100644 hypervisor/arch/x86/configs/sos_vm.h create mode 100644 hypervisor/scenarios/sdc/pt_dev.c create mode 100644 hypervisor/scenarios/sdc/vm_configurations.h diff --git a/hypervisor/Makefile b/hypervisor/Makefile index c0d5a6fed..9aea1ef05 100644 --- a/hypervisor/Makefile +++ b/hypervisor/Makefile @@ -39,6 +39,11 @@ include $(BASEDIR)/../scripts/deps.mk include scripts/kconfig/kconfig.mk +#initialize scenarios name +ifeq ($(CONFIG_SDC),y) +SCENARIO_NAME := sdc +endif + LD_IN_TOOL = scripts/genld.sh BASH = $(shell which bash) @@ -110,6 +115,7 @@ INCLUDE_PATH += bsp/include INCLUDE_PATH += boot/include INCLUDE_PATH += $(HV_OBJDIR)/include INCLUDE_PATH += arch/x86/configs/$(CONFIG_BOARD) +INCLUDE_PATH += scenarios/$(SCENARIO_NAME) CC ?= gcc AS ?= as @@ -140,6 +146,8 @@ C_SRCS += arch/x86/configs/vm_config.c C_SRCS += arch/x86/configs/$(CONFIG_BOARD)/ve820.c ifeq ($(CONFIG_PARTITION_MODE),y) C_SRCS += arch/x86/configs/$(CONFIG_BOARD)/pt_dev.c +else +C_SRCS += scenarios/$(SCENARIO_NAME)/pt_dev.c endif C_SRCS += arch/x86/configs/$(CONFIG_BOARD)/board.c diff --git a/hypervisor/arch/x86/Kconfig b/hypervisor/arch/x86/Kconfig index 8a04ea1c2..373d4ac57 100644 --- a/hypervisor/arch/x86/Kconfig +++ b/hypervisor/arch/x86/Kconfig @@ -1,3 +1,17 @@ +choice + prompt "ACRN Scenario" + default SDC + help + Select the scenario name to load corresponding VM configuration. + +config SDC + bool "Software Defined Cockpit" + help + SDC (Software Defined Cockpit) is a typical scenario that ACRN supported. + SDC will have one pre-launched SOS VM and one post-launched NORMAL VM. + +endchoice + choice prompt "Hypervisor mode" default SHARING_MODE diff --git a/hypervisor/arch/x86/configs/apl-mrb/sos_vm.h b/hypervisor/arch/x86/configs/apl-mrb/sos_vm.h deleted file mode 120000 index 86d830213..000000000 --- a/hypervisor/arch/x86/configs/apl-mrb/sos_vm.h +++ /dev/null @@ -1 +0,0 @@ -../sos_vm.h \ No newline at end of file diff --git a/hypervisor/arch/x86/configs/apl-up2/sos_vm.h b/hypervisor/arch/x86/configs/apl-up2/sos_vm.h deleted file mode 120000 index 86d830213..000000000 --- a/hypervisor/arch/x86/configs/apl-up2/sos_vm.h +++ /dev/null @@ -1 +0,0 @@ -../sos_vm.h \ No newline at end of file diff --git a/hypervisor/arch/x86/configs/dnv-cb2/sos_vm.h b/hypervisor/arch/x86/configs/dnv-cb2/sos_vm.h deleted file mode 120000 index 86d830213..000000000 --- a/hypervisor/arch/x86/configs/dnv-cb2/sos_vm.h +++ /dev/null @@ -1 +0,0 @@ -../sos_vm.h \ No newline at end of file diff --git a/hypervisor/arch/x86/configs/nuc6cayh/sos_vm.h b/hypervisor/arch/x86/configs/nuc6cayh/sos_vm.h deleted file mode 120000 index 86d830213..000000000 --- a/hypervisor/arch/x86/configs/nuc6cayh/sos_vm.h +++ /dev/null @@ -1 +0,0 @@ -../sos_vm.h \ No newline at end of file diff --git a/hypervisor/arch/x86/configs/nuc7i7bnh/sos_vm.h b/hypervisor/arch/x86/configs/nuc7i7bnh/sos_vm.h deleted file mode 120000 index 86d830213..000000000 --- a/hypervisor/arch/x86/configs/nuc7i7bnh/sos_vm.h +++ /dev/null @@ -1 +0,0 @@ -../sos_vm.h \ No newline at end of file diff --git a/hypervisor/arch/x86/configs/sos_vm.h b/hypervisor/arch/x86/configs/sos_vm.h deleted file mode 100644 index 063db3565..000000000 --- a/hypervisor/arch/x86/configs/sos_vm.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2018 Intel Corporation. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/* - * This is a template of sos_vm.h and is linked to ./$(CONFIG_BOARD)/sos_vm.h, - * If you need a board specific sos_vm.h, make a copy in ./$(CONFIG_BOARD)/ - * and replace the original symbol link. - */ - -#ifndef SOS_VM_CONFIG_H -#define SOS_VM_CONFIG_H - -#define SOS_VM_CONFIG_NAME "ACRN SOS VM" -#define SOS_VM_CONFIG_GUEST_FLAGS GUEST_FLAG_IO_COMPLETION_POLLING - -#define SOS_VM_CONFIG_OS_NAME "ACRN Service OS" - -#endif /* SOS_VM_CONFIG_H */ diff --git a/hypervisor/arch/x86/configs/vm_config.c b/hypervisor/arch/x86/configs/vm_config.c index 02ea82c37..dee0c1a6c 100644 --- a/hypervisor/arch/x86/configs/vm_config.c +++ b/hypervisor/arch/x86/configs/vm_config.c @@ -12,24 +12,10 @@ #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, - }, - }, -}; +#include #else #include +#endif #define INIT_VM_CONFIG(idx) \ { \ @@ -67,7 +53,6 @@ static struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] __aligned(PAGE_SIZE) INIT_VM_CONFIG(3), #endif }; -#endif /* * @pre vm_id < CONFIG_MAX_VM_NUM diff --git a/hypervisor/include/arch/x86/vm_config.h b/hypervisor/include/arch/x86/vm_config.h index 2142082b2..776a6bcb6 100644 --- a/hypervisor/include/arch/x86/vm_config.h +++ b/hypervisor/include/arch/x86/vm_config.h @@ -58,9 +58,7 @@ struct acrn_vm_config { struct acrn_vm_os_config os_config; /* OS information the VM */ uint16_t clos; /* if guest_flags has GUEST_FLAG_CLOS_REQUIRED, then VM use this CLOS */ -#ifdef CONFIG_PARTITION_MODE bool vm_vuart; -#endif } __aligned(8); struct acrn_vm_config *get_vm_config(uint16_t vm_id); diff --git a/hypervisor/scenarios/sdc/pt_dev.c b/hypervisor/scenarios/sdc/pt_dev.c new file mode 100644 index 000000000..c103a3a13 --- /dev/null +++ b/hypervisor/scenarios/sdc/pt_dev.c @@ -0,0 +1,10 @@ +/* + * Copyright (C) 2019 Intel Corporation. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include + +__unused struct acrn_vm_pci_ptdev_config vm0_pci_ptdevs[VM0_CONFIG_PCI_PTDEV_NUM]; diff --git a/hypervisor/scenarios/sdc/vm_configurations.h b/hypervisor/scenarios/sdc/vm_configurations.h new file mode 100644 index 000000000..f32df091f --- /dev/null +++ b/hypervisor/scenarios/sdc/vm_configurations.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2018 Intel Corporation. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/* + * This is a template of vm_configurations.h for sharing mode; + */ + +#ifndef VM_CONFIGURATIONS_H +#define VM_CONFIGURATIONS_H + +#define VM0_CONFIGURED + +#define VM0_CONFIG_NAME "ACRN SOS VM" +#define VM0_CONFIG_TYPE SOS_VM +#define VM0_CONFIG_PCPU_BITMAP 0UL /* PCPU Bitmap is reserved in SOS_VM */ +#define VM0_CONFIG_FLAGS GUEST_FLAG_IO_COMPLETION_POLLING +#define VM0_CONFIG_MEM_START_HPA 0UL +#define VM0_CONFIG_MEM_SIZE CONFIG_SOS_RAM_SIZE +#define VM0_CONFIG_OS_NAME "ACRN Service OS" +#define VM0_CONFIG_OS_BOOTARGS "configured in devicemodel/samples/apl-mrb/sos_bootargs_xxxx.txt" + +#define VM0_CONFIG_PCI_PTDEV_NUM 0U /* PTDEV is reserved in SOS_VM */ +extern struct acrn_vm_pci_ptdev_config vm0_pci_ptdevs[VM0_CONFIG_PCI_PTDEV_NUM]; + +#endif /* VM_CONFIGURATIONS_H */