
Eddie Dong
Acked-by: Eddie Dong <eddie.dong>
toggle quoted messageShow quoted text
-----Original Message----- From: acrn-dev@... [mailto:acrn-dev@...] On Behalf Of Dongsheng Zhang Sent: Friday, December 21, 2018 12:21 PM To: acrn-dev@... Subject: [acrn-dev] [PATCH 2/9] HV: define vm_pcpu_ids as inline array to simplify code
From: dongshen <dongsheng.x.zhang@...>
Tracked-On: #2143 Signed-off-by: dongshen <dongsheng.x.zhang@...> --- hypervisor/include/arch/x86/guest/vm.h | 6 +- hypervisor/partition/apl-mrb/vm_description.c | 83 ++++++++++-------------- hypervisor/partition/cb2_dnv/vm_description.c | 91 +++++++++++---------------- 3 files changed, 72 insertions(+), 108 deletions(-)
diff --git a/hypervisor/include/arch/x86/guest/vm.h b/hypervisor/include/arch/x86/guest/vm.h index 44630be..852f78e 100644 --- a/hypervisor/include/arch/x86/guest/vm.h +++ b/hypervisor/include/arch/x86/guest/vm.h @@ -170,11 +170,11 @@ struct vm_description { /* The physical CPU IDs associated with this VM - The first CPU listed * will be the VM's BSP */ - uint16_t *vm_pcpu_ids; + uint16_t vm_pcpu_ids[CONFIG_MAX_PCPU_NUM]; uint8_t GUID[16]; /* GUID of the vm will be created */ - uint16_t vm_hw_num_cores; /* Number of virtual cores */ + uint16_t vm_hw_num_cores; /* Number of virtual cores */ /* Whether secure world is supported for current VM. */ - bool sworld_supported; + bool sworld_supported; #ifdef CONFIG_PARTITION_MODE uint8_t vm_id; struct mptable_info *mptable; diff --git a/hypervisor/partition/apl-mrb/vm_description.c b/hypervisor/partition/apl-mrb/vm_description.c index 9718d55..9c6a37b 100644 --- a/hypervisor/partition/apl-mrb/vm_description.c +++ b/hypervisor/partition/apl-mrb/vm_description.c @@ -7,20 +7,12 @@ #include <hypervisor.h> #include <e820.h>
-#define NUM_USER_VMS 2U - /* Number of CPUs in VM1 */ #define VM1_NUM_CPUS 2U
-/* Logical CPU IDs assigned to this VM */ -uint16_t VM1_CPUS[VM1_NUM_CPUS] = {0U, 2U}; - /* Number of CPUs in VM2 */ #define VM2_NUM_CPUS 2U
-/* Logical CPU IDs assigned with this VM */ -uint16_t VM2_CPUS[VM2_NUM_CPUS] = {3U, 1U}; - static struct vpci_vdev_array vpci_vdev_array1 = { .num_pci_vdev = 2,
@@ -147,63 +139,52 @@ static struct vpci_vdev_array vpci_vdev_array2 = { } };
-/*******************************/ -/* User Defined VM definitions */ -/*******************************/ -struct vm_description_array vm_desc_partition = { - /* Number of user virtual machines */ - .num_vm_desc = NUM_USER_VMS, - - /* Virtual Machine descriptions */ - .vm_desc_array = { - { - /* Internal variable, MUSTBE init to -1 */ - .vm_hw_num_cores = VM1_NUM_CPUS, - .vm_pcpu_ids = &VM1_CPUS[0], - .vm_id = 1U, - .start_hpa = 0x100000000UL, - .mem_size = 0x20000000UL, /* uses contiguous memory from host */ - .vm_vuart = true, - .bootargs = "root=/dev/sda3 rw rootwait noxsave maxcpus=2 nohpet console=hvc0 \ - console=ttyS2 no_timer_check ignore_loglevel log_buf_len=16M \ - consoleblank=0 tsc=reliable xapic_phys", - .vpci_vdev_array = &vpci_vdev_array1, - .mptable = &mptable_vm1, - }, +struct vm_description vm1_desc = { + /* Internal variable, MUSTBE init to -1 */ + .vm_hw_num_cores = VM1_NUM_CPUS, + .vm_pcpu_ids = {0U, 2U}, + .vm_id = 1U, + .start_hpa = 0x100000000UL, + .mem_size = 0x20000000UL, /* uses contiguous memory from host */ + .vm_vuart = true, + .bootargs = "root=/dev/sda3 rw rootwait noxsave maxcpus=2 nohpet console=hvc0 \ + console=ttyS2 no_timer_check ignore_loglevel log_buf_len=16M \ + consoleblank=0 tsc=reliable xapic_phys", + .vpci_vdev_array = &vpci_vdev_array1, + .mptable = &mptable_vm1, +};
- { - /* Internal variable, MUSTBE init to -1 */ - .vm_hw_num_cores = VM2_NUM_CPUS, - .vm_pcpu_ids = &VM2_CPUS[0], - .vm_id = 2U, - .start_hpa = 0x120000000UL, - .mem_size = 0x20000000UL, /* uses contiguous memory from host */ - .vm_vuart = true, - .bootargs = "root=/dev/sda3 rw rootwait noxsave maxcpus=2 nohpet console=hvc0 \ - console=ttyS2 no_timer_check ignore_loglevel log_buf_len=16M \ - consoleblank=0 tsc=reliable xapic_phys", - .vpci_vdev_array = &vpci_vdev_array2, - .mptable = &mptable_vm2, - .lapic_pt = true, - }, - } +struct vm_description vm2_desc = { + /* Internal variable, MUSTBE init to -1 */ + .vm_hw_num_cores = VM2_NUM_CPUS, + .vm_pcpu_ids = {3U, 1U}, + .vm_id = 2U, + .start_hpa = 0x120000000UL, + .mem_size = 0x20000000UL, /* uses contiguous memory from host */ + .vm_vuart = true, + .bootargs = "root=/dev/sda3 rw rootwait noxsave maxcpus=2 nohpet console=hvc0 \ + console=ttyS2 no_timer_check ignore_loglevel log_buf_len=16M \ + consoleblank=0 tsc=reliable xapic_phys", + .vpci_vdev_array = &vpci_vdev_array2, + .mptable = &mptable_vm2, + .lapic_pt = true };
const struct pcpu_vm_desc_mapping pcpu_vm_desc_map[] = { { - .vm_desc_ptr = &vm_desc_partition.vm_desc_array[0], + .vm_desc_ptr = &vm1_desc, .is_bsp = true, }, { - .vm_desc_ptr = &vm_desc_partition.vm_desc_array[1], + .vm_desc_ptr = &vm2_desc, .is_bsp = false, }, { - .vm_desc_ptr = &vm_desc_partition.vm_desc_array[0], + .vm_desc_ptr = &vm1_desc, .is_bsp = false, }, { - .vm_desc_ptr = &vm_desc_partition.vm_desc_array[1], + .vm_desc_ptr = &vm2_desc, .is_bsp = true, }, }; diff --git a/hypervisor/partition/cb2_dnv/vm_description.c b/hypervisor/partition/cb2_dnv/vm_description.c index 998f53b..55e0f8c 100644 --- a/hypervisor/partition/cb2_dnv/vm_description.c +++ b/hypervisor/partition/cb2_dnv/vm_description.c @@ -12,15 +12,9 @@ /* Number of CPUs in VM1*/ #define VM1_NUM_CPUS 4U
-/* Logical CPU IDs assigned to this VM */ -uint16_t VM1_CPUS[VM1_NUM_CPUS] = {0U, 2U, 4U, 6U}; - /* Number of CPUs in VM2*/ #define VM2_NUM_CPUS 4U
-/* Logical CPU IDs assigned with this VM */ -uint16_t VM2_CPUS[VM2_NUM_CPUS] = {7U, 5U, 3U, 1U}; - static struct vpci_vdev_array vpci_vdev_array1 = { .num_pci_vdev = 3, .vpci_vdev_list = { @@ -181,80 +175,69 @@ static struct vpci_vdev_array vpci_vdev_array2 = { } };
-/*******************************/ -/* User Defined VM definitions */ -/*******************************/ -struct vm_description_array vm_desc_partition = { - /* Number of user virtual machines */ - .num_vm_desc = NUM_USER_VMS, - - /* Virtual Machine descriptions */ - .vm_desc_array = { - { - /* Internal variable, MUSTBE init to -1 */ - .vm_hw_num_cores = VM1_NUM_CPUS, - .vm_pcpu_ids = &VM1_CPUS[0], - .vm_id = 1U, - .start_hpa = 0x100000000UL, - .mem_size = 0x80000000UL, /* uses contiguous memory from host */ - .vm_vuart = true, - .bootargs = "root=/dev/sda rw rootwait noxsave maxcpus=4 nohpet console=hvc0 " \ - "console=ttyS0 no_timer_check ignore_loglevel log_buf_len=16M "\ - "consoleblank=0 tsc=reliable xapic_phys apic_debug", - .vpci_vdev_array = &vpci_vdev_array1, - .mptable = &mptable_vm1, - .lapic_pt = true, - }, +struct vm_description vm1_desc = { + /* Internal variable, MUSTBE init to -1 */ + .vm_hw_num_cores = VM1_NUM_CPUS, + .vm_pcpu_ids = {0U, 2U, 4U, 6U}, + .vm_id = 1U, + .start_hpa = 0x100000000UL, + .mem_size = 0x80000000UL, /* uses contiguous memory from host */ + .vm_vuart = true, + .bootargs = "root=/dev/sda rw rootwait noxsave maxcpus=4 nohpet console=hvc0 " \ + "console=ttyS0 no_timer_check ignore_loglevel log_buf_len=16M "\ + "consoleblank=0 tsc=reliable xapic_phys apic_debug", + .vpci_vdev_array = &vpci_vdev_array1, + .mptable = &mptable_vm1, + .lapic_pt = true, +};
- { - /* Internal variable, MUSTBE init to -1 */ - .vm_hw_num_cores = VM2_NUM_CPUS, - .vm_pcpu_ids = &VM2_CPUS[0], - .vm_id = 2U, - .start_hpa = 0x180000000UL, - .mem_size = 0x80000000UL, /* uses contiguous memory from host */ - .vm_vuart = true, - .bootargs = "root=/dev/sda2 rw rootwait noxsave maxcpus=4 nohpet console=hvc0 "\ - "console=ttyS0 no_timer_check ignore_loglevel log_buf_len=16M "\ - "consoleblank=0 tsc=reliable xapic_phys apic_debug", - .vpci_vdev_array = &vpci_vdev_array2, - .mptable = &mptable_vm2, - .lapic_pt = true, - }, - } +struct vm_description vm2_desc = { + /* Internal variable, MUSTBE init to -1 */ + .vm_hw_num_cores = VM2_NUM_CPUS, + .vm_pcpu_ids = {7U, 5U, 3U, 1U}, + .vm_id = 2U, + .start_hpa = 0x180000000UL, + .mem_size = 0x80000000UL, /* uses contiguous memory from host */ + .vm_vuart = true, + .bootargs = "root=/dev/sda2 rw rootwait noxsave maxcpus=4 nohpet console=hvc0 "\ + "console=ttyS0 no_timer_check ignore_loglevel log_buf_len=16M "\ + "consoleblank=0 tsc=reliable xapic_phys apic_debug", + .vpci_vdev_array = &vpci_vdev_array2, + .mptable = &mptable_vm2, + .lapic_pt = true, };
const struct pcpu_vm_desc_mapping pcpu_vm_desc_map[] = { { - .vm_desc_ptr = &vm_desc_partition.vm_desc_array[0], + .vm_desc_ptr = &vm1_desc, .is_bsp = true, }, { - .vm_desc_ptr = &vm_desc_partition.vm_desc_array[1], + .vm_desc_ptr = &vm2_desc, .is_bsp = false, }, { - .vm_desc_ptr = &vm_desc_partition.vm_desc_array[0], + .vm_desc_ptr = &vm1_desc, .is_bsp = false, }, { - .vm_desc_ptr = &vm_desc_partition.vm_desc_array[1], + .vm_desc_ptr = &vm2_desc, .is_bsp = false, }, { - .vm_desc_ptr = &vm_desc_partition.vm_desc_array[0], + .vm_desc_ptr = &vm1_desc, .is_bsp = false, }, { - .vm_desc_ptr = &vm_desc_partition.vm_desc_array[1], + .vm_desc_ptr = &vm2_desc, .is_bsp = false, }, { - .vm_desc_ptr = &vm_desc_partition.vm_desc_array[0], + .vm_desc_ptr = &vm1_desc, .is_bsp = false, }, { - .vm_desc_ptr = &vm_desc_partition.vm_desc_array[1], + .vm_desc_ptr = &vm2_desc, .is_bsp = true, }, }; -- 2.7.4
|