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 <mingqiang.chi@intel.com>
Reviewed-by: Li, Fei1 <fei1.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Mingqiang Chi 2018-10-10 18:24:56 +08:00 committed by wenlingz
parent 3c57532598
commit 790d8a5ce7
7 changed files with 5 additions and 127 deletions

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -30,7 +30,6 @@ struct acpi_info {
/**********************************/
/* EXTERNAL VARIABLES */
/**********************************/
extern struct vm_description vm0_desc;
extern struct acpi_info host_acpi_info;
/* BSP Interfaces */

View File

@ -1,26 +0,0 @@
/*
* Copyright (C) 2018 Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <hypervisor.h>
#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

View File

@ -1,26 +0,0 @@
/*
* Copyright (C) 2018 Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <hypervisor.h>
#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

View File

@ -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);