Skip to content

Commit 50e09c4

Browse files
jsun26intelacrnsi
authored andcommitted
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>
1 parent f4e976a commit 50e09c4

File tree

5 files changed

+5
-11
lines changed

5 files changed

+5
-11
lines changed

hypervisor/arch/x86/guest/vm.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -703,10 +703,6 @@ void prepare_vm(uint16_t vm_id, struct acrn_vm_config *vm_config)
703703
err = create_vm(vm_id, vm_config, &vm);
704704

705705
if (err == 0) {
706-
if (is_prelaunched_vm(vm)) {
707-
(void)mptable_build(vm);
708-
}
709-
710706
for (i = 0U; i < get_pcpu_nums(); i++) {
711707
if (bitmap_test(i, &vm_config->pcpu_bitmap)) {
712708
err = prepare_vcpu(vm, i);
@@ -715,10 +711,13 @@ void prepare_vm(uint16_t vm_id, struct acrn_vm_config *vm_config)
715711
}
716712
}
717713
}
718-
719714
}
720715

721716
if (err == 0) {
717+
if (is_prelaunched_vm(vm)) {
718+
(void)mptable_build(vm);
719+
}
720+
722721
(void )vm_sw_loader(vm);
723722

724723
/* start vm BSP automatically */

hypervisor/dm/vmptable.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ int32_t mptable_build(struct acrn_vm *vm)
9898

9999
vm_config = get_vm_config(vm->vm_id);
100100
mptable = &vm_mptables[vm->vm_id];
101-
vcpu_num = vm_config->cpu_num;
101+
vcpu_num = vm->hw.created_vcpus;
102102
pcpu_bitmap = vm_config->pcpu_bitmap;
103103
(void *)memcpy_s((void *)mptable, sizeof(struct mptable_info),
104104
(const void *)&mptable_template, sizeof(struct mptable_info));

hypervisor/include/arch/x86/vm_config.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ struct acrn_vm_config {
8989
char name[MAX_VM_OS_NAME_LEN]; /* VM name identifier, useful for debug. */
9090
const uint8_t uuid[16]; /* UUID of the VM */
9191
uint64_t pcpu_bitmap; /* from pcpu bitmap, we could know VM core number */
92-
uint16_t cpu_num; /* Number of vCPUs for the VM */
9392
uint64_t guest_flags; /* VM flags that we want to configure for guest
9493
* Now we have two flags:
9594
* GUEST_FLAG_SECURE_WORLD_ENABLED

hypervisor/scenarios/logical_partition/vm_configurations.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
1818
0x81U, 0x09U, 0xf2U, 0x01U, 0xebU, 0xd6U, 0x1aU, 0x5eU},
1919
/* 26c5e0d8-8f8a-47d8-8109-f201ebd61a5e */
2020
.pcpu_bitmap = VM0_CONFIG_PCPU_BITMAP,
21-
.cpu_num = VM0_CONFIG_NUM_CPUS,
2221
.clos = 0U,
2322
.memory = {
2423
.start_hpa = VM0_CONFIG_MEM_START_HPA,
@@ -57,7 +56,6 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
5756
0xbcU, 0x58U, 0x76U, 0x05U, 0x83U, 0x7fU, 0x93U, 0x5eU},
5857
/* dd87ce08-66f9-473d-bc58-7605837f935e */
5958
.pcpu_bitmap = VM1_CONFIG_PCPU_BITMAP,
60-
.cpu_num = VM1_CONFIG_NUM_CPUS,
6159
.guest_flags = (GUEST_FLAG_RT | GUEST_FLAG_LAPIC_PASSTHROUGH),
6260
.clos = 0U,
6361
.memory = {

hypervisor/scenarios/logical_partition/vm_configurations.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,13 @@
2626
*/
2727

2828
#define VM0_CONFIG_PCPU_BITMAP (PLUG_CPU(0) | PLUG_CPU(2))
29-
#define VM0_CONFIG_NUM_CPUS 2U
3029
#define VM0_CONFIG_MEM_START_HPA 0x100000000UL
3130
#define VM0_CONFIG_MEM_SIZE 0x20000000UL
3231
#define VM0_CONFIG_OS_BOOTARG_ROOT ROOTFS_0
3332
#define VM0_CONFIG_OS_BOOTARG_MAXCPUS "maxcpus=2 "
3433
#define VM0_CONFIG_OS_BOOTARG_CONSOLE "console=ttyS0 "
3534

3635
#define VM1_CONFIG_PCPU_BITMAP (PLUG_CPU(1) | PLUG_CPU(3))
37-
#define VM1_CONFIG_NUM_CPUS 2U
3836
#define VM1_CONFIG_MEM_START_HPA 0x120000000UL
3937
#define VM1_CONFIG_MEM_SIZE 0x20000000UL
4038
#define VM1_CONFIG_OS_BOOTARG_ROOT ROOTFS_0

0 commit comments

Comments
 (0)