Skip to content

Commit c25a62e

Browse files
Sainath Grandhilijinxia
authored andcommitted
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 <sainath.grandhi@intel.com>
1 parent ab29614 commit c25a62e

File tree

4 files changed

+130
-102
lines changed

4 files changed

+130
-102
lines changed

hypervisor/bsp/sbl/vm_description.c

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -24,85 +24,3 @@ struct vm_description vm0_desc = {
2424
struct vm_description vm0_desc;
2525

2626
#endif // CONFIG_VM0_DESC
27-
28-
#ifdef CONFIG_PARTITION_MODE
29-
30-
#define NUM_USER_VMS 2U
31-
32-
/**********************/
33-
/* VIRTUAL MACHINE 0 */
34-
/*********************/
35-
36-
/* Number of CPUs in this VM*/
37-
#define VM1_NUM_CPUS 2U
38-
39-
/* Logical CPU IDs assigned to this VM */
40-
int VM1_CPUS[VM1_NUM_CPUS] = {0U, 2U};
41-
42-
/*********************/
43-
/* VIRTUAL MACHINE 1 */
44-
/*********************/
45-
46-
/* Number of CPUs in this VM*/
47-
#define VM2_NUM_CPUS 2U
48-
49-
/* Logical CPU IDs assigned with this VM */
50-
int VM2_CPUS[VM2_NUM_CPUS] = {3U, 1U};
51-
52-
53-
/*******************************/
54-
/* User Defined VM definitions */
55-
/*******************************/
56-
const struct vm_description_array vm_desc_mrb = {
57-
/* Number of user virtual machines */
58-
.num_vm_desc = NUM_USER_VMS,
59-
60-
/* Virtual Machine descriptions */
61-
.vm_desc_array = {
62-
{
63-
/* Internal variable, MUSTBE init to -1 */
64-
.vm_hw_num_cores = VM1_NUM_CPUS,
65-
.vm_pcpu_ids = &VM1_CPUS[0],
66-
.vm_id = 1U,
67-
.start_hpa = 0x100000000UL,
68-
.mem_size = 0x80000000UL, /* uses contiguous memory from host */
69-
.vm_vuart = true,
70-
.bootargs = "root=/dev/sda rw rootwait noxsave maxcpus=2 nohpet console=hvc0 \
71-
console=ttyS0 no_timer_check ignore_loglevel log_buf_len=16M \
72-
consoleblank=0 tsc=reliable"
73-
},
74-
75-
{
76-
/* Internal variable, MUSTBE init to -1 */
77-
.vm_hw_num_cores = VM2_NUM_CPUS,
78-
.vm_pcpu_ids = &VM2_CPUS[0],
79-
.vm_id = 2U,
80-
.start_hpa = 0x180000000UL,
81-
.mem_size = 0x80000000UL, /* uses contiguous memory from host */
82-
.vm_vuart = true,
83-
.bootargs = "root=/dev/sda rw rootwait noxsave maxcpus=2 nohpet console=hvc0 \
84-
console=ttyS0 no_timer_check ignore_loglevel log_buf_len=16M \
85-
consoleblank=0 tsc=reliable"
86-
},
87-
}
88-
};
89-
90-
const struct pcpu_vm_desc_mapping pcpu_vm_desc_map[] = {
91-
{
92-
.vm_desc_ptr = &vm_desc_mrb.vm_desc_array[0],
93-
.is_bsp = true,
94-
},
95-
{
96-
.vm_desc_ptr = &vm_desc_mrb.vm_desc_array[1],
97-
.is_bsp = false,
98-
},
99-
{
100-
.vm_desc_ptr = &vm_desc_mrb.vm_desc_array[0],
101-
.is_bsp = false,
102-
},
103-
{
104-
.vm_desc_ptr = &vm_desc_mrb.vm_desc_array[1],
105-
.is_bsp = true,
106-
},
107-
};
108-
#endif

hypervisor/common/vm_load.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@
77
#include <hypervisor.h>
88
#include <zeropage.h>
99

10+
#ifdef CONFIG_PARTITION_MODE
11+
static uint32_t create_e820_table(struct e820_entry *param_e820)
12+
{
13+
uint32_t i;
14+
15+
for (i = 0U; i < NUM_E820_ENTRIES; i++) {
16+
param_e820[i].baseaddr = e820_default_entries[i].baseaddr;
17+
param_e820[i].length = e820_default_entries[i].length;
18+
param_e820[i].type = e820_default_entries[i].type;
19+
}
20+
21+
return NUM_E820_ENTRIES;
22+
}
23+
#else
1024
static uint32_t create_e820_table(struct e820_entry *param_e820)
1125
{
1226
uint32_t i;
@@ -22,6 +36,7 @@ static uint32_t create_e820_table(struct e820_entry *param_e820)
2236

2337
return e820_entries;
2438
}
39+
#endif
2540

2641
static uint64_t create_zero_page(struct vm *vm)
2742
{

hypervisor/include/arch/x86/guest/guest.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,18 @@ void init_e820(void);
104104
void obtain_e820_mem_info(void);
105105
extern uint32_t e820_entries;
106106
extern struct e820_entry e820[E820_MAX_ENTRIES];
107+
108+
#ifdef CONFIG_PARTITION_MODE
109+
/*
110+
* Default e820 mem map:
111+
*
112+
* Assumption is every VM launched by ACRN in partition mode uses 2G of RAM.
113+
* there is reserved memory of 64K for MPtable and PCI hole of 512MB
114+
*/
115+
#define NUM_E820_ENTRIES 5U
116+
extern const struct e820_entry e820_default_entries[NUM_E820_ENTRIES];
117+
#endif
118+
107119
extern uint32_t boot_regs[2];
108120
extern struct e820_mem_params e820_mem;
109121

hypervisor/partition/vm_description.c

Lines changed: 103 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,28 @@
66

77
#include <hypervisor.h>
88

9+
#define NUM_USER_VMS 2U
10+
11+
/**********************/
12+
/* VIRTUAL MACHINE 0 */
13+
/*********************/
14+
15+
/* Number of CPUs in this VM*/
16+
#define VM1_NUM_CPUS 2U
17+
18+
/* Logical CPU IDs assigned to this VM */
19+
int VM1_CPUS[VM1_NUM_CPUS] = {0U, 2U};
20+
21+
/*********************/
22+
/* VIRTUAL MACHINE 1 */
23+
/*********************/
24+
25+
/* Number of CPUs in this VM*/
26+
#define VM2_NUM_CPUS 2U
27+
28+
/* Logical CPU IDs assigned with this VM */
29+
int VM2_CPUS[VM2_NUM_CPUS] = {3U, 1U};
30+
931
static struct vpci_vdev_array vpci_vdev_array1 = {
1032
.num_pci_vdev = 2,
1133

@@ -51,7 +73,6 @@ static struct vpci_vdev_array vpci_vdev_array1 = {
5173
}
5274
};
5375

54-
5576
static struct vpci_vdev_array vpci_vdev_array2 = {
5677
.num_pci_vdev = 2,
5778

@@ -101,26 +122,88 @@ static struct vpci_vdev_array vpci_vdev_array2 = {
101122
/* User Defined VM definitions */
102123
/*******************************/
103124
const struct vm_description_array vm_desc_partition = {
104-
/* Number of user virtual machines */
105-
.num_vm_desc = 2,
106-
107-
.vm_desc_array = {
108-
{
109-
/* vm1 */
110-
.vm_hw_num_cores = 2,
111-
.vpci_vdev_array = &vpci_vdev_array1,
112-
},
125+
/* Number of user virtual machines */
126+
.num_vm_desc = NUM_USER_VMS,
113127

114-
{
115-
/* vm2 */
116-
.vm_hw_num_cores = 2,
117-
.vpci_vdev_array = &vpci_vdev_array2,
118-
},
119-
}
128+
/* Virtual Machine descriptions */
129+
.vm_desc_array = {
130+
{
131+
/* Internal variable, MUSTBE init to -1 */
132+
.vm_hw_num_cores = VM1_NUM_CPUS,
133+
.vm_pcpu_ids = &VM1_CPUS[0],
134+
.vm_id = 1U,
135+
.start_hpa = 0x100000000UL,
136+
.mem_size = 0x80000000UL, /* uses contiguous memory from host */
137+
.vm_vuart = true,
138+
.bootargs = "root=/dev/sda rw rootwait noxsave maxcpus=2 nohpet console=hvc0 \
139+
console=ttyS0 no_timer_check ignore_loglevel log_buf_len=16M \
140+
consoleblank=0 tsc=reliable",
141+
.vpci_vdev_array = &vpci_vdev_array1,
142+
},
143+
144+
{
145+
/* Internal variable, MUSTBE init to -1 */
146+
.vm_hw_num_cores = VM2_NUM_CPUS,
147+
.vm_pcpu_ids = &VM2_CPUS[0],
148+
.vm_id = 2U,
149+
.start_hpa = 0x180000000UL,
150+
.mem_size = 0x80000000UL, /* uses contiguous memory from host */
151+
.vm_vuart = true,
152+
.bootargs = "root=/dev/sda rw rootwait noxsave maxcpus=2 nohpet console=hvc0 \
153+
console=ttyS0 no_timer_check ignore_loglevel log_buf_len=16M \
154+
consoleblank=0 tsc=reliable",
155+
.vpci_vdev_array = &vpci_vdev_array2,
156+
},
157+
}
158+
};
159+
160+
const struct pcpu_vm_desc_mapping pcpu_vm_desc_map[] = {
161+
{
162+
.vm_desc_ptr = &vm_desc_partition.vm_desc_array[0],
163+
.is_bsp = true,
164+
},
165+
{
166+
.vm_desc_ptr = &vm_desc_partition.vm_desc_array[1],
167+
.is_bsp = false,
168+
},
169+
{
170+
.vm_desc_ptr = &vm_desc_partition.vm_desc_array[0],
171+
.is_bsp = false,
172+
},
173+
{
174+
.vm_desc_ptr = &vm_desc_partition.vm_desc_array[1],
175+
.is_bsp = true,
176+
},
120177
};
121178

122-
const struct vm_description_array *get_vm_desc_base(void)
123-
{
124-
return &vm_desc_partition;
125-
}
179+
const struct e820_entry e820_default_entries[NUM_E820_ENTRIES] = {
180+
{ /* 0 to mptable */
181+
.baseaddr = 0x0U,
182+
.length = 0xEFFFFU,
183+
.type = E820_TYPE_RAM
184+
},
185+
186+
{ /* mptable */
187+
.baseaddr = 0xF0000U,
188+
.length = 0x10000U,
189+
.type = E820_TYPE_RESERVED
190+
},
191+
192+
{ /* mptable to lowmem */
193+
.baseaddr = 0x100000U,
194+
.length = 0x7FF00000U,
195+
.type = E820_TYPE_RAM
196+
},
126197

198+
{ /* lowmem to PCI hole */
199+
.baseaddr = 0x80000000U,
200+
.length = 0x40000000U,
201+
.type = E820_TYPE_RESERVED
202+
},
203+
204+
{ /* PCI hole to 4G */
205+
.baseaddr = 0xe0000000U,
206+
.length = 0x20000000U,
207+
.type = E820_TYPE_RESERVED
208+
},
209+
};

0 commit comments

Comments
 (0)