HV: remove cpu_num from vm configurations

The vcpu num could be calculated based on pcpu_bitmap when prepare_vcpu()
is done, so remove this redundant configuration item;

Tracked-On: #3214

Signed-off-by: Victor Sun <victor.sun@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
This commit is contained in:
Victor Sun 2019-06-03 00:43:29 +08:00 committed by ACRN System Integration
parent f4e976ab38
commit 50e09c41b4
5 changed files with 5 additions and 11 deletions

View File

@ -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); err = create_vm(vm_id, vm_config, &vm);
if (err == 0) { if (err == 0) {
if (is_prelaunched_vm(vm)) {
(void)mptable_build(vm);
}
for (i = 0U; i < get_pcpu_nums(); i++) { for (i = 0U; i < get_pcpu_nums(); i++) {
if (bitmap_test(i, &vm_config->pcpu_bitmap)) { if (bitmap_test(i, &vm_config->pcpu_bitmap)) {
err = prepare_vcpu(vm, i); 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 (err == 0) {
if (is_prelaunched_vm(vm)) {
(void)mptable_build(vm);
}
(void )vm_sw_loader(vm); (void )vm_sw_loader(vm);
/* start vm BSP automatically */ /* start vm BSP automatically */

View File

@ -98,7 +98,7 @@ int32_t mptable_build(struct acrn_vm *vm)
vm_config = get_vm_config(vm->vm_id); vm_config = get_vm_config(vm->vm_id);
mptable = &vm_mptables[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; pcpu_bitmap = vm_config->pcpu_bitmap;
(void *)memcpy_s((void *)mptable, sizeof(struct mptable_info), (void *)memcpy_s((void *)mptable, sizeof(struct mptable_info),
(const void *)&mptable_template, sizeof(struct mptable_info)); (const void *)&mptable_template, sizeof(struct mptable_info));

View File

@ -89,7 +89,6 @@ struct acrn_vm_config {
char name[MAX_VM_OS_NAME_LEN]; /* VM name identifier, useful for debug. */ char name[MAX_VM_OS_NAME_LEN]; /* VM name identifier, useful for debug. */
const uint8_t uuid[16]; /* UUID of the VM */ const uint8_t uuid[16]; /* UUID of the VM */
uint64_t pcpu_bitmap; /* from pcpu bitmap, we could know VM core number */ 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 uint64_t guest_flags; /* VM flags that we want to configure for guest
* Now we have two flags: * Now we have two flags:
* GUEST_FLAG_SECURE_WORLD_ENABLED * GUEST_FLAG_SECURE_WORLD_ENABLED

View File

@ -18,7 +18,6 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
0x81U, 0x09U, 0xf2U, 0x01U, 0xebU, 0xd6U, 0x1aU, 0x5eU}, 0x81U, 0x09U, 0xf2U, 0x01U, 0xebU, 0xd6U, 0x1aU, 0x5eU},
/* 26c5e0d8-8f8a-47d8-8109-f201ebd61a5e */ /* 26c5e0d8-8f8a-47d8-8109-f201ebd61a5e */
.pcpu_bitmap = VM0_CONFIG_PCPU_BITMAP, .pcpu_bitmap = VM0_CONFIG_PCPU_BITMAP,
.cpu_num = VM0_CONFIG_NUM_CPUS,
.clos = 0U, .clos = 0U,
.memory = { .memory = {
.start_hpa = VM0_CONFIG_MEM_START_HPA, .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}, 0xbcU, 0x58U, 0x76U, 0x05U, 0x83U, 0x7fU, 0x93U, 0x5eU},
/* dd87ce08-66f9-473d-bc58-7605837f935e */ /* dd87ce08-66f9-473d-bc58-7605837f935e */
.pcpu_bitmap = VM1_CONFIG_PCPU_BITMAP, .pcpu_bitmap = VM1_CONFIG_PCPU_BITMAP,
.cpu_num = VM1_CONFIG_NUM_CPUS,
.guest_flags = (GUEST_FLAG_RT | GUEST_FLAG_LAPIC_PASSTHROUGH), .guest_flags = (GUEST_FLAG_RT | GUEST_FLAG_LAPIC_PASSTHROUGH),
.clos = 0U, .clos = 0U,
.memory = { .memory = {

View File

@ -26,7 +26,6 @@
*/ */
#define VM0_CONFIG_PCPU_BITMAP (PLUG_CPU(0) | PLUG_CPU(2)) #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_START_HPA 0x100000000UL
#define VM0_CONFIG_MEM_SIZE 0x20000000UL #define VM0_CONFIG_MEM_SIZE 0x20000000UL
#define VM0_CONFIG_OS_BOOTARG_ROOT ROOTFS_0 #define VM0_CONFIG_OS_BOOTARG_ROOT ROOTFS_0
@ -34,7 +33,6 @@
#define VM0_CONFIG_OS_BOOTARG_CONSOLE "console=ttyS0 " #define VM0_CONFIG_OS_BOOTARG_CONSOLE "console=ttyS0 "
#define VM1_CONFIG_PCPU_BITMAP (PLUG_CPU(1) | PLUG_CPU(3)) #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_START_HPA 0x120000000UL
#define VM1_CONFIG_MEM_SIZE 0x20000000UL #define VM1_CONFIG_MEM_SIZE 0x20000000UL
#define VM1_CONFIG_OS_BOOTARG_ROOT ROOTFS_0 #define VM1_CONFIG_OS_BOOTARG_ROOT ROOTFS_0