diff --git a/hypervisor/arch/x86/guest/vm.c b/hypervisor/arch/x86/guest/vm.c index 034d71d79..0604f2da7 100644 --- a/hypervisor/arch/x86/guest/vm.c +++ b/hypervisor/arch/x86/guest/vm.c @@ -703,10 +703,6 @@ void prepare_vm(uint16_t vm_id, struct acrn_vm_config *vm_config) err = create_vm(vm_id, vm_config, &vm); if (err == 0) { - if (is_prelaunched_vm(vm)) { - (void)mptable_build(vm); - } - for (i = 0U; i < get_pcpu_nums(); i++) { if (bitmap_test(i, &vm_config->pcpu_bitmap)) { err = prepare_vcpu(vm, i); @@ -715,10 +711,13 @@ void prepare_vm(uint16_t vm_id, struct acrn_vm_config *vm_config) } } } - } if (err == 0) { + if (is_prelaunched_vm(vm)) { + (void)mptable_build(vm); + } + (void )vm_sw_loader(vm); /* start vm BSP automatically */ diff --git a/hypervisor/dm/vmptable.c b/hypervisor/dm/vmptable.c index 8f628495b..888876f60 100644 --- a/hypervisor/dm/vmptable.c +++ b/hypervisor/dm/vmptable.c @@ -98,7 +98,7 @@ int32_t mptable_build(struct acrn_vm *vm) vm_config = get_vm_config(vm->vm_id); mptable = &vm_mptables[vm->vm_id]; - vcpu_num = vm_config->cpu_num; + vcpu_num = vm->hw.created_vcpus; pcpu_bitmap = vm_config->pcpu_bitmap; (void *)memcpy_s((void *)mptable, sizeof(struct mptable_info), (const void *)&mptable_template, sizeof(struct mptable_info)); diff --git a/hypervisor/include/arch/x86/vm_config.h b/hypervisor/include/arch/x86/vm_config.h index bf79a911d..24c7b877c 100644 --- a/hypervisor/include/arch/x86/vm_config.h +++ b/hypervisor/include/arch/x86/vm_config.h @@ -89,7 +89,6 @@ struct acrn_vm_config { char name[MAX_VM_OS_NAME_LEN]; /* VM name identifier, useful for debug. */ const uint8_t uuid[16]; /* UUID of the VM */ uint64_t pcpu_bitmap; /* from pcpu bitmap, we could know VM core number */ - uint16_t cpu_num; /* Number of vCPUs for the VM */ uint64_t guest_flags; /* VM flags that we want to configure for guest * Now we have two flags: * GUEST_FLAG_SECURE_WORLD_ENABLED diff --git a/hypervisor/scenarios/logical_partition/vm_configurations.c b/hypervisor/scenarios/logical_partition/vm_configurations.c index 0d4edfea5..beb768c12 100644 --- a/hypervisor/scenarios/logical_partition/vm_configurations.c +++ b/hypervisor/scenarios/logical_partition/vm_configurations.c @@ -18,7 +18,6 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = { 0x81U, 0x09U, 0xf2U, 0x01U, 0xebU, 0xd6U, 0x1aU, 0x5eU}, /* 26c5e0d8-8f8a-47d8-8109-f201ebd61a5e */ .pcpu_bitmap = VM0_CONFIG_PCPU_BITMAP, - .cpu_num = VM0_CONFIG_NUM_CPUS, .clos = 0U, .memory = { .start_hpa = VM0_CONFIG_MEM_START_HPA, @@ -57,7 +56,6 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = { 0xbcU, 0x58U, 0x76U, 0x05U, 0x83U, 0x7fU, 0x93U, 0x5eU}, /* dd87ce08-66f9-473d-bc58-7605837f935e */ .pcpu_bitmap = VM1_CONFIG_PCPU_BITMAP, - .cpu_num = VM1_CONFIG_NUM_CPUS, .guest_flags = (GUEST_FLAG_RT | GUEST_FLAG_LAPIC_PASSTHROUGH), .clos = 0U, .memory = { diff --git a/hypervisor/scenarios/logical_partition/vm_configurations.h b/hypervisor/scenarios/logical_partition/vm_configurations.h index 4336b99ee..c0f8d90c4 100644 --- a/hypervisor/scenarios/logical_partition/vm_configurations.h +++ b/hypervisor/scenarios/logical_partition/vm_configurations.h @@ -26,7 +26,6 @@ */ #define VM0_CONFIG_PCPU_BITMAP (PLUG_CPU(0) | PLUG_CPU(2)) -#define VM0_CONFIG_NUM_CPUS 2U #define VM0_CONFIG_MEM_START_HPA 0x100000000UL #define VM0_CONFIG_MEM_SIZE 0x20000000UL #define VM0_CONFIG_OS_BOOTARG_ROOT ROOTFS_0 @@ -34,7 +33,6 @@ #define VM0_CONFIG_OS_BOOTARG_CONSOLE "console=ttyS0 " #define VM1_CONFIG_PCPU_BITMAP (PLUG_CPU(1) | PLUG_CPU(3)) -#define VM1_CONFIG_NUM_CPUS 2U #define VM1_CONFIG_MEM_START_HPA 0x120000000UL #define VM1_CONFIG_MEM_SIZE 0x20000000UL #define VM1_CONFIG_OS_BOOTARG_ROOT ROOTFS_0