From 790d8a5ce7d6fbf1fa549ef791a54d783658d85a Mon Sep 17 00:00:00 2001 From: Mingqiang Chi Date: Wed, 10 Oct 2018 18:24:56 +0800 Subject: [PATCH] hv:Remove CONFIG_VM0_DESC If defined CONFIG_VM0_DESC, HV will use predefined vm0_desc to config VM0,now it is unneccessary, then remove these code. Tracked-On: #861 Signed-off-by: Mingqiang Chi Reviewed-by: Li, Fei1 Acked-by: Eddie Dong --- hypervisor/Makefile | 1 - hypervisor/arch/x86/guest/vm.c | 68 ++------------------------ hypervisor/arch/x86/guest/vmcall.c | 6 --- hypervisor/bsp/include/bsp_extern.h | 1 - hypervisor/bsp/sbl/vm_description.c | 26 ---------- hypervisor/bsp/uefi/vm_description.c | 26 ---------- hypervisor/include/arch/x86/guest/vm.h | 4 -- 7 files changed, 5 insertions(+), 127 deletions(-) delete mode 100644 hypervisor/bsp/sbl/vm_description.c delete mode 100644 hypervisor/bsp/uefi/vm_description.c diff --git a/hypervisor/Makefile b/hypervisor/Makefile index 7495565c9..3e8dec1a7 100644 --- a/hypervisor/Makefile +++ b/hypervisor/Makefile @@ -182,7 +182,6 @@ C_SRCS += $(wildcard partition/*.c) C_SRCS += dm/vrtc.c endif -C_SRCS += bsp/$(CONFIG_PLATFORM)/vm_description.c C_SRCS += bsp/$(CONFIG_PLATFORM)/$(CONFIG_PLATFORM).c C_SRCS += bsp/$(CONFIG_PLATFORM)/platform_acpi_info.c diff --git a/hypervisor/arch/x86/guest/vm.c b/hypervisor/arch/x86/guest/vm.c index 0fdb71ab0..0527ec8eb 100644 --- a/hypervisor/arch/x86/guest/vm.c +++ b/hypervisor/arch/x86/guest/vm.c @@ -44,18 +44,8 @@ static void init_vm(struct vm_description *vm_desc, struct vm *vm_handle) { /* Populate VM attributes from VM description */ -#ifdef CONFIG_VM0_DESC - if (is_vm0(vm_handle)) { - /* Allocate all cpus to vm0 at the beginning */ - vm_handle->hw.num_vcpus = phys_cpu_num; - vm_handle->hw.exp_num_vcpus = vm_desc->vm_hw_num_cores; - } else { - vm_handle->hw.num_vcpus = vm_desc->vm_hw_num_cores; - vm_handle->hw.exp_num_vcpus = vm_desc->vm_hw_num_cores; - } -#else vm_handle->hw.num_vcpus = vm_desc->vm_hw_num_cores; -#endif + #ifdef CONFIG_PARTITION_MODE vm_handle->vm_desc = vm_desc; #endif @@ -433,13 +423,12 @@ int prepare_vm0(void) int err; uint16_t i; struct vm *vm = NULL; - struct vm_description *vm_desc = &vm0_desc; + struct vm_description vm0_desc; -#ifndef CONFIG_VM0_DESC - vm_desc->vm_hw_num_cores = phys_cpu_num; -#endif + (void)memset((void *)&vm0_desc, 0U, sizeof(vm0_desc)); + vm0_desc.vm_hw_num_cores = phys_cpu_num; - err = create_vm(vm_desc, &vm); + err = create_vm(&vm0_desc, &vm); if (err != 0) { return err; } @@ -472,50 +461,3 @@ int prepare_vm(uint16_t pcpu_id) return err; } #endif - -#ifdef CONFIG_VM0_DESC -static inline bool vcpu_in_vm_desc(struct vcpu *vcpu, - struct vm_description *vm_desc) -{ - int i; - - for (i = 0; i < vm_desc->vm_hw_num_cores; i++) { - if (vcpu->pcpu_id == vm_desc->vm_pcpu_ids[i]) { - return true; - } - } - - return false; -} - -/* - * fixup vm0 for expected vcpu: - * vm0 is starting with all physical cpus, it's mainly for UEFI boot to - * handle all physical mapped APs wakeup during boot service exit. - * this fixup is used to pause then destroy non-expect-enabled vcpus from VM0. - * - * NOTE: if you want to enable mult-vpucs for vm0, please make sure the pcpu_id - * is in order, for example: - * - one vcpu: VM0_CPUS[VM0_NUM_CPUS] = {0}; - * - two vcpus: VM0_CPUS[VM0_NUM_CPUS] = {0, 1}; - * - three vcpus: VM0_CPUS[VM0_NUM_CPUS] = {0, 1, 2}; - */ -void vm_fixup(struct vm *vm) -{ - if (is_vm0(vm) && (vm->hw.exp_num_vcpus < vm->hw.num_vcpus)) { - struct vm_description *vm_desc = &vm0_desc; - struct vcpu *vcpu; - uint16_t i; - - foreach_vcpu(i, vm, vcpu) { - if (!vcpu_in_vm_desc(vcpu, vm_desc)) { - pause_vcpu(vcpu, VCPU_ZOMBIE); - reset_vcpu(vcpu); - destroy_vcpu(vcpu); - } - } - - vm->hw.num_vcpus = vm->hw.exp_num_vcpus; - } -} -#endif diff --git a/hypervisor/arch/x86/guest/vmcall.c b/hypervisor/arch/x86/guest/vmcall.c index b47aa51dc..f0a36199b 100644 --- a/hypervisor/arch/x86/guest/vmcall.c +++ b/hypervisor/arch/x86/guest/vmcall.c @@ -41,12 +41,6 @@ int vmcall_vmexit_handler(struct vcpu *vcpu) ret = hcall_sos_offline_cpu(vm, param1); break; case HC_GET_API_VERSION: -#ifdef CONFIG_VM0_DESC - /* vm0 will call HC_GET_API_VERSION as first hypercall, fixup - * vm0 vcpu here. - */ - vm_fixup(vm); -#endif ret = hcall_get_api_version(vm, param1); break; diff --git a/hypervisor/bsp/include/bsp_extern.h b/hypervisor/bsp/include/bsp_extern.h index ae4ae1d3c..6ade87570 100644 --- a/hypervisor/bsp/include/bsp_extern.h +++ b/hypervisor/bsp/include/bsp_extern.h @@ -30,7 +30,6 @@ struct acpi_info { /**********************************/ /* EXTERNAL VARIABLES */ /**********************************/ -extern struct vm_description vm0_desc; extern struct acpi_info host_acpi_info; /* BSP Interfaces */ diff --git a/hypervisor/bsp/sbl/vm_description.c b/hypervisor/bsp/sbl/vm_description.c deleted file mode 100644 index 8558293e1..000000000 --- a/hypervisor/bsp/sbl/vm_description.c +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2018 Intel Corporation. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include - -#if defined(CONFIG_VM0_DESC) && !defined(CONFIG_PARTITION_MODE) - -/* Number of CPUs in VM0 */ -#define VM0_NUM_CPUS 1 - -/* Logical CPU IDs assigned to VM0 */ -uint16_t VM0_CPUS[VM0_NUM_CPUS] = {0U}; - -struct vm_description vm0_desc = { - .vm_hw_num_cores = VM0_NUM_CPUS, - .vm_pcpu_ids = &VM0_CPUS[0], -}; - -#else - -struct vm_description vm0_desc; - -#endif // CONFIG_VM0_DESC diff --git a/hypervisor/bsp/uefi/vm_description.c b/hypervisor/bsp/uefi/vm_description.c deleted file mode 100644 index c3db2cff2..000000000 --- a/hypervisor/bsp/uefi/vm_description.c +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2018 Intel Corporation. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include - -#ifdef CONFIG_VM0_DESC - -/* Number of CPUs in VM0 */ -#define VM0_NUM_CPUS 1 - -/* Logical CPU IDs assigned to VM0 */ -uint16_t VM0_CPUS[VM0_NUM_CPUS] = {0U}; - -struct vm_description vm0_desc = { - .vm_hw_num_cores = VM0_NUM_CPUS, - .vm_pcpu_ids = &VM0_CPUS[0], -}; - -#else - -struct vm_description vm0_desc; - -#endif // CONFIG_VM0_DESC diff --git a/hypervisor/include/arch/x86/guest/vm.h b/hypervisor/include/arch/x86/guest/vm.h index b7e52eb20..0764d86bd 100644 --- a/hypervisor/include/arch/x86/guest/vm.h +++ b/hypervisor/include/arch/x86/guest/vm.h @@ -22,7 +22,6 @@ enum vm_privilege_level { struct vm_hw_info { uint16_t num_vcpus; /* Number of total virtual cores */ - uint16_t exp_num_vcpus; /* Number of real expected virtual cores */ uint16_t created_vcpus; /* Number of created vcpus */ struct vcpu **vcpu_array; /* vcpu array of this VM */ uint64_t gpa_lowtop; /* top lowmem gpa of this VM */ @@ -268,9 +267,6 @@ int start_vm(struct vm *vm); int reset_vm(struct vm *vm); int create_vm(struct vm_description *vm_desc, struct vm **rtn_vm); int prepare_vm(uint16_t pcpu_id); -#ifdef CONFIG_VM0_DESC -void vm_fixup(struct vm *vm); -#endif #ifdef CONFIG_PARTITION_MODE const struct vm_description_array *get_vm_desc_base(void);