Skip to content

Commit 790d8a5

Browse files
mingqiangchiwenlingz
authored andcommitted
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>
1 parent 3c57532 commit 790d8a5

File tree

7 files changed

+5
-127
lines changed

7 files changed

+5
-127
lines changed

hypervisor/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ C_SRCS += $(wildcard partition/*.c)
182182
C_SRCS += dm/vrtc.c
183183
endif
184184

185-
C_SRCS += bsp/$(CONFIG_PLATFORM)/vm_description.c
186185
C_SRCS += bsp/$(CONFIG_PLATFORM)/$(CONFIG_PLATFORM).c
187186
C_SRCS += bsp/$(CONFIG_PLATFORM)/platform_acpi_info.c
188187

hypervisor/arch/x86/guest/vm.c

Lines changed: 5 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,8 @@ static void init_vm(struct vm_description *vm_desc,
4444
struct vm *vm_handle)
4545
{
4646
/* Populate VM attributes from VM description */
47-
#ifdef CONFIG_VM0_DESC
48-
if (is_vm0(vm_handle)) {
49-
/* Allocate all cpus to vm0 at the beginning */
50-
vm_handle->hw.num_vcpus = phys_cpu_num;
51-
vm_handle->hw.exp_num_vcpus = vm_desc->vm_hw_num_cores;
52-
} else {
53-
vm_handle->hw.num_vcpus = vm_desc->vm_hw_num_cores;
54-
vm_handle->hw.exp_num_vcpus = vm_desc->vm_hw_num_cores;
55-
}
56-
#else
5747
vm_handle->hw.num_vcpus = vm_desc->vm_hw_num_cores;
58-
#endif
48+
5949
#ifdef CONFIG_PARTITION_MODE
6050
vm_handle->vm_desc = vm_desc;
6151
#endif
@@ -433,13 +423,12 @@ int prepare_vm0(void)
433423
int err;
434424
uint16_t i;
435425
struct vm *vm = NULL;
436-
struct vm_description *vm_desc = &vm0_desc;
426+
struct vm_description vm0_desc;
437427

438-
#ifndef CONFIG_VM0_DESC
439-
vm_desc->vm_hw_num_cores = phys_cpu_num;
440-
#endif
428+
(void)memset((void *)&vm0_desc, 0U, sizeof(vm0_desc));
429+
vm0_desc.vm_hw_num_cores = phys_cpu_num;
441430

442-
err = create_vm(vm_desc, &vm);
431+
err = create_vm(&vm0_desc, &vm);
443432
if (err != 0) {
444433
return err;
445434
}
@@ -472,50 +461,3 @@ int prepare_vm(uint16_t pcpu_id)
472461
return err;
473462
}
474463
#endif
475-
476-
#ifdef CONFIG_VM0_DESC
477-
static inline bool vcpu_in_vm_desc(struct vcpu *vcpu,
478-
struct vm_description *vm_desc)
479-
{
480-
int i;
481-
482-
for (i = 0; i < vm_desc->vm_hw_num_cores; i++) {
483-
if (vcpu->pcpu_id == vm_desc->vm_pcpu_ids[i]) {
484-
return true;
485-
}
486-
}
487-
488-
return false;
489-
}
490-
491-
/*
492-
* fixup vm0 for expected vcpu:
493-
* vm0 is starting with all physical cpus, it's mainly for UEFI boot to
494-
* handle all physical mapped APs wakeup during boot service exit.
495-
* this fixup is used to pause then destroy non-expect-enabled vcpus from VM0.
496-
*
497-
* NOTE: if you want to enable mult-vpucs for vm0, please make sure the pcpu_id
498-
* is in order, for example:
499-
* - one vcpu: VM0_CPUS[VM0_NUM_CPUS] = {0};
500-
* - two vcpus: VM0_CPUS[VM0_NUM_CPUS] = {0, 1};
501-
* - three vcpus: VM0_CPUS[VM0_NUM_CPUS] = {0, 1, 2};
502-
*/
503-
void vm_fixup(struct vm *vm)
504-
{
505-
if (is_vm0(vm) && (vm->hw.exp_num_vcpus < vm->hw.num_vcpus)) {
506-
struct vm_description *vm_desc = &vm0_desc;
507-
struct vcpu *vcpu;
508-
uint16_t i;
509-
510-
foreach_vcpu(i, vm, vcpu) {
511-
if (!vcpu_in_vm_desc(vcpu, vm_desc)) {
512-
pause_vcpu(vcpu, VCPU_ZOMBIE);
513-
reset_vcpu(vcpu);
514-
destroy_vcpu(vcpu);
515-
}
516-
}
517-
518-
vm->hw.num_vcpus = vm->hw.exp_num_vcpus;
519-
}
520-
}
521-
#endif

hypervisor/arch/x86/guest/vmcall.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,6 @@ int vmcall_vmexit_handler(struct vcpu *vcpu)
4141
ret = hcall_sos_offline_cpu(vm, param1);
4242
break;
4343
case HC_GET_API_VERSION:
44-
#ifdef CONFIG_VM0_DESC
45-
/* vm0 will call HC_GET_API_VERSION as first hypercall, fixup
46-
* vm0 vcpu here.
47-
*/
48-
vm_fixup(vm);
49-
#endif
5044
ret = hcall_get_api_version(vm, param1);
5145
break;
5246

hypervisor/bsp/include/bsp_extern.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ struct acpi_info {
3030
/**********************************/
3131
/* EXTERNAL VARIABLES */
3232
/**********************************/
33-
extern struct vm_description vm0_desc;
3433
extern struct acpi_info host_acpi_info;
3534

3635
/* BSP Interfaces */

hypervisor/bsp/sbl/vm_description.c

Lines changed: 0 additions & 26 deletions
This file was deleted.

hypervisor/bsp/uefi/vm_description.c

Lines changed: 0 additions & 26 deletions
This file was deleted.

hypervisor/include/arch/x86/guest/vm.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ enum vm_privilege_level {
2222

2323
struct vm_hw_info {
2424
uint16_t num_vcpus; /* Number of total virtual cores */
25-
uint16_t exp_num_vcpus; /* Number of real expected virtual cores */
2625
uint16_t created_vcpus; /* Number of created vcpus */
2726
struct vcpu **vcpu_array; /* vcpu array of this VM */
2827
uint64_t gpa_lowtop; /* top lowmem gpa of this VM */
@@ -268,9 +267,6 @@ int start_vm(struct vm *vm);
268267
int reset_vm(struct vm *vm);
269268
int create_vm(struct vm_description *vm_desc, struct vm **rtn_vm);
270269
int prepare_vm(uint16_t pcpu_id);
271-
#ifdef CONFIG_VM0_DESC
272-
void vm_fixup(struct vm *vm);
273-
#endif
274270

275271
#ifdef CONFIG_PARTITION_MODE
276272
const struct vm_description_array *get_vm_desc_base(void);

0 commit comments

Comments
 (0)