From c25a62e5b00d0c0eac2c4a5556f11285ea2be6a2 Mon Sep 17 00:00:00 2001 From: Sainath Grandhi Date: Sun, 12 Aug 2018 20:44:51 -0700 Subject: [PATCH] hv: Create E820 entries for OS in partitioning mode ACRN 1) This patch creates static E820 entries for VMs launced by ACRN in partition mode. 2) Moves vm_description entries from bsp/sbl/ to partition/ 3) Removes unused API get_vm_desc_base Signed-off-by: Sainath Grandhi --- hypervisor/bsp/sbl/vm_description.c | 82 --------------- hypervisor/common/vm_load.c | 15 +++ hypervisor/include/arch/x86/guest/guest.h | 12 +++ hypervisor/partition/vm_description.c | 121 ++++++++++++++++++---- 4 files changed, 129 insertions(+), 101 deletions(-) diff --git a/hypervisor/bsp/sbl/vm_description.c b/hypervisor/bsp/sbl/vm_description.c index 7a2b0fe30..8558293e1 100644 --- a/hypervisor/bsp/sbl/vm_description.c +++ b/hypervisor/bsp/sbl/vm_description.c @@ -24,85 +24,3 @@ struct vm_description vm0_desc = { struct vm_description vm0_desc; #endif // CONFIG_VM0_DESC - -#ifdef CONFIG_PARTITION_MODE - -#define NUM_USER_VMS 2U - -/**********************/ -/* VIRTUAL MACHINE 0 */ -/*********************/ - -/* Number of CPUs in this VM*/ -#define VM1_NUM_CPUS 2U - -/* Logical CPU IDs assigned to this VM */ -int VM1_CPUS[VM1_NUM_CPUS] = {0U, 2U}; - -/*********************/ -/* VIRTUAL MACHINE 1 */ -/*********************/ - -/* Number of CPUs in this VM*/ -#define VM2_NUM_CPUS 2U - -/* Logical CPU IDs assigned with this VM */ -int VM2_CPUS[VM2_NUM_CPUS] = {3U, 1U}; - - -/*******************************/ -/* User Defined VM definitions */ -/*******************************/ -const struct vm_description_array vm_desc_mrb = { - /* 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=2 nohpet console=hvc0 \ - console=ttyS0 no_timer_check ignore_loglevel log_buf_len=16M \ - consoleblank=0 tsc=reliable" - }, - - { - /* 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/sda rw rootwait noxsave maxcpus=2 nohpet console=hvc0 \ - console=ttyS0 no_timer_check ignore_loglevel log_buf_len=16M \ - consoleblank=0 tsc=reliable" - }, - } -}; - -const struct pcpu_vm_desc_mapping pcpu_vm_desc_map[] = { - { - .vm_desc_ptr = &vm_desc_mrb.vm_desc_array[0], - .is_bsp = true, - }, - { - .vm_desc_ptr = &vm_desc_mrb.vm_desc_array[1], - .is_bsp = false, - }, - { - .vm_desc_ptr = &vm_desc_mrb.vm_desc_array[0], - .is_bsp = false, - }, - { - .vm_desc_ptr = &vm_desc_mrb.vm_desc_array[1], - .is_bsp = true, - }, -}; -#endif diff --git a/hypervisor/common/vm_load.c b/hypervisor/common/vm_load.c index e4c52b4cb..f28bd9d83 100644 --- a/hypervisor/common/vm_load.c +++ b/hypervisor/common/vm_load.c @@ -7,6 +7,20 @@ #include #include +#ifdef CONFIG_PARTITION_MODE +static uint32_t create_e820_table(struct e820_entry *param_e820) +{ + uint32_t i; + + for (i = 0U; i < NUM_E820_ENTRIES; i++) { + param_e820[i].baseaddr = e820_default_entries[i].baseaddr; + param_e820[i].length = e820_default_entries[i].length; + param_e820[i].type = e820_default_entries[i].type; + } + + return NUM_E820_ENTRIES; +} +#else static uint32_t create_e820_table(struct e820_entry *param_e820) { uint32_t i; @@ -22,6 +36,7 @@ static uint32_t create_e820_table(struct e820_entry *param_e820) return e820_entries; } +#endif static uint64_t create_zero_page(struct vm *vm) { diff --git a/hypervisor/include/arch/x86/guest/guest.h b/hypervisor/include/arch/x86/guest/guest.h index 0e291a755..db6ea63cf 100644 --- a/hypervisor/include/arch/x86/guest/guest.h +++ b/hypervisor/include/arch/x86/guest/guest.h @@ -104,6 +104,18 @@ void init_e820(void); void obtain_e820_mem_info(void); extern uint32_t e820_entries; extern struct e820_entry e820[E820_MAX_ENTRIES]; + +#ifdef CONFIG_PARTITION_MODE +/* + * Default e820 mem map: + * + * Assumption is every VM launched by ACRN in partition mode uses 2G of RAM. + * there is reserved memory of 64K for MPtable and PCI hole of 512MB + */ +#define NUM_E820_ENTRIES 5U +extern const struct e820_entry e820_default_entries[NUM_E820_ENTRIES]; +#endif + extern uint32_t boot_regs[2]; extern struct e820_mem_params e820_mem; diff --git a/hypervisor/partition/vm_description.c b/hypervisor/partition/vm_description.c index ac375692d..4400eca69 100644 --- a/hypervisor/partition/vm_description.c +++ b/hypervisor/partition/vm_description.c @@ -6,6 +6,28 @@ #include +#define NUM_USER_VMS 2U + +/**********************/ +/* VIRTUAL MACHINE 0 */ +/*********************/ + +/* Number of CPUs in this VM*/ +#define VM1_NUM_CPUS 2U + +/* Logical CPU IDs assigned to this VM */ +int VM1_CPUS[VM1_NUM_CPUS] = {0U, 2U}; + +/*********************/ +/* VIRTUAL MACHINE 1 */ +/*********************/ + +/* Number of CPUs in this VM*/ +#define VM2_NUM_CPUS 2U + +/* Logical CPU IDs assigned with this VM */ +int VM2_CPUS[VM2_NUM_CPUS] = {3U, 1U}; + static struct vpci_vdev_array vpci_vdev_array1 = { .num_pci_vdev = 2, @@ -51,7 +73,6 @@ static struct vpci_vdev_array vpci_vdev_array1 = { } }; - static struct vpci_vdev_array vpci_vdev_array2 = { .num_pci_vdev = 2, @@ -101,26 +122,88 @@ static struct vpci_vdev_array vpci_vdev_array2 = { /* User Defined VM definitions */ /*******************************/ const struct vm_description_array vm_desc_partition = { - /* Number of user virtual machines */ - .num_vm_desc = 2, + /* Number of user virtual machines */ + .num_vm_desc = NUM_USER_VMS, - .vm_desc_array = { - { - /* vm1 */ - .vm_hw_num_cores = 2, - .vpci_vdev_array = &vpci_vdev_array1, - }, + /* 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=2 nohpet console=hvc0 \ + console=ttyS0 no_timer_check ignore_loglevel log_buf_len=16M \ + consoleblank=0 tsc=reliable", + .vpci_vdev_array = &vpci_vdev_array1, + }, - { - /* vm2 */ - .vm_hw_num_cores = 2, - .vpci_vdev_array = &vpci_vdev_array2, - }, - } + { + /* 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/sda rw rootwait noxsave maxcpus=2 nohpet console=hvc0 \ + console=ttyS0 no_timer_check ignore_loglevel log_buf_len=16M \ + consoleblank=0 tsc=reliable", + .vpci_vdev_array = &vpci_vdev_array2, + }, + } }; -const struct vm_description_array *get_vm_desc_base(void) -{ - return &vm_desc_partition; -} +const struct pcpu_vm_desc_mapping pcpu_vm_desc_map[] = { + { + .vm_desc_ptr = &vm_desc_partition.vm_desc_array[0], + .is_bsp = true, + }, + { + .vm_desc_ptr = &vm_desc_partition.vm_desc_array[1], + .is_bsp = false, + }, + { + .vm_desc_ptr = &vm_desc_partition.vm_desc_array[0], + .is_bsp = false, + }, + { + .vm_desc_ptr = &vm_desc_partition.vm_desc_array[1], + .is_bsp = true, + }, +}; +const struct e820_entry e820_default_entries[NUM_E820_ENTRIES] = { + { /* 0 to mptable */ + .baseaddr = 0x0U, + .length = 0xEFFFFU, + .type = E820_TYPE_RAM + }, + + { /* mptable */ + .baseaddr = 0xF0000U, + .length = 0x10000U, + .type = E820_TYPE_RESERVED + }, + + { /* mptable to lowmem */ + .baseaddr = 0x100000U, + .length = 0x7FF00000U, + .type = E820_TYPE_RAM + }, + + { /* lowmem to PCI hole */ + .baseaddr = 0x80000000U, + .length = 0x40000000U, + .type = E820_TYPE_RESERVED + }, + + { /* PCI hole to 4G */ + .baseaddr = 0xe0000000U, + .length = 0x20000000U, + .type = E820_TYPE_RESERVED + }, +};