mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-21 13:08:42 +00:00
hv: vE820: calculate SOS memory size by vE820 tables
SOS's memory size could be calculated by its vE820 Tables easily. Tracked-On: #5830 Signed-off-by: Li Fei1 <fei1.li@intel.com> Acked-by: eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
ad15053304
commit
901e8c869e
@ -86,11 +86,10 @@ static void filter_mem_from_sos_e820(struct acrn_vm *vm, uint64_t start_pa, uint
|
|||||||
*/
|
*/
|
||||||
void create_sos_vm_e820(struct acrn_vm *vm)
|
void create_sos_vm_e820(struct acrn_vm *vm)
|
||||||
{
|
{
|
||||||
uint16_t vm_id;
|
uint16_t vm_id, i;
|
||||||
uint64_t hv_start_pa = hva2hpa((void *)(get_hv_image_base()));
|
uint64_t hv_start_pa = hva2hpa((void *)(get_hv_image_base()));
|
||||||
uint64_t hv_end_pa = hv_start_pa + CONFIG_HV_RAM_SIZE;
|
uint64_t hv_end_pa = hv_start_pa + CONFIG_HV_RAM_SIZE;
|
||||||
uint32_t entries_count = get_e820_entries_count();
|
uint32_t entries_count = get_e820_entries_count();
|
||||||
const struct mem_range *p_mem_range_info = get_mem_range_info();
|
|
||||||
struct acrn_vm_config *sos_vm_config = get_vm_config(vm->vm_id);
|
struct acrn_vm_config *sos_vm_config = get_vm_config(vm->vm_id);
|
||||||
|
|
||||||
(void)memcpy_s((void *)sos_vm_e820, entries_count * sizeof(struct e820_entry),
|
(void)memcpy_s((void *)sos_vm_e820, entries_count * sizeof(struct e820_entry),
|
||||||
@ -100,7 +99,6 @@ void create_sos_vm_e820(struct acrn_vm *vm)
|
|||||||
vm->e820_entries = sos_vm_e820;
|
vm->e820_entries = sos_vm_e820;
|
||||||
/* filter out hv memory from e820 table */
|
/* filter out hv memory from e820 table */
|
||||||
filter_mem_from_sos_e820(vm, hv_start_pa, hv_end_pa);
|
filter_mem_from_sos_e820(vm, hv_start_pa, hv_end_pa);
|
||||||
sos_vm_config->memory.size = p_mem_range_info->total_mem_size - CONFIG_HV_RAM_SIZE;
|
|
||||||
|
|
||||||
/* filter out prelaunched vm memory from e820 table */
|
/* filter out prelaunched vm memory from e820 table */
|
||||||
for (vm_id = 0U; vm_id < CONFIG_MAX_VM_NUM; vm_id++) {
|
for (vm_id = 0U; vm_id < CONFIG_MAX_VM_NUM; vm_id++) {
|
||||||
@ -109,16 +107,21 @@ void create_sos_vm_e820(struct acrn_vm *vm)
|
|||||||
if (vm_config->load_order == PRE_LAUNCHED_VM) {
|
if (vm_config->load_order == PRE_LAUNCHED_VM) {
|
||||||
filter_mem_from_sos_e820(vm, vm_config->memory.start_hpa,
|
filter_mem_from_sos_e820(vm, vm_config->memory.start_hpa,
|
||||||
vm_config->memory.start_hpa + vm_config->memory.size);
|
vm_config->memory.start_hpa + vm_config->memory.size);
|
||||||
sos_vm_config->memory.size -= vm_config->memory.size;
|
|
||||||
|
|
||||||
/* if HPA2 is available, filter it out as well*/
|
/* if HPA2 is available, filter it out as well*/
|
||||||
if (vm_config->memory.size_hpa2 != 0UL) {
|
if (vm_config->memory.size_hpa2 != 0UL) {
|
||||||
filter_mem_from_sos_e820(vm, vm_config->memory.start_hpa2,
|
filter_mem_from_sos_e820(vm, vm_config->memory.start_hpa2,
|
||||||
vm_config->memory.start_hpa2 + vm_config->memory.size_hpa2);
|
vm_config->memory.start_hpa2 + vm_config->memory.size_hpa2);
|
||||||
sos_vm_config->memory.size -= vm_config->memory.size_hpa2;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (i = 0U; i < vm->e820_entry_num; i++) {
|
||||||
|
struct e820_entry *entry = &sos_vm_e820[i];
|
||||||
|
if ((entry->type == E820_TYPE_RAM)) {
|
||||||
|
sos_vm_config->memory.size += entry->length;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct e820_entry pre_ve820_template[E820_MAX_ENTRIES] = {
|
static const struct e820_entry pre_ve820_template[E820_MAX_ENTRIES] = {
|
||||||
|
Loading…
Reference in New Issue
Block a user