hv: remove CONFIG_HV_RAM_SIZE

It's difficult to configure CONFIG_HV_RAM_SIZE properly at once. This patch
not only remove CONFIG_HV_RAM_SIZE, but also we use ld linker script to
dynamically get the size of HV RAM size.

Tracked-On: #6663
Signed-off-by: Fei Li <fei1.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Fei Li
2021-10-12 16:23:33 +08:00
committed by wenlingz
parent 7c2c3ad636
commit df7ffab441
8 changed files with 19 additions and 8 deletions

View File

@@ -472,7 +472,7 @@ void cpu_dead(void)
vmx_off();
stac();
flush_cache_range((void *)get_hv_image_base(), CONFIG_HV_RAM_SIZE);
flush_cache_range((void *)get_hv_image_base(), get_hv_ram_size());
clac();
/* Set state to show CPU is dead */

View File

@@ -139,7 +139,7 @@ void create_sos_vm_e820(struct acrn_vm *vm)
{
uint16_t vm_id, i;
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 + get_hv_ram_size();
uint32_t entries_count = get_e820_entries_count();
struct acrn_vm_config *sos_vm_config = get_vm_config(vm->vm_id);

View File

@@ -434,7 +434,7 @@ static void prepare_sos_vm_memmap(struct acrn_vm *vm)
* will cause EPT violation if sos accesses hv memory
*/
hv_hpa = hva2hpa((void *)(get_hv_image_base()));
ept_del_mr(vm, pml4_page, hv_hpa, CONFIG_HV_RAM_SIZE);
ept_del_mr(vm, pml4_page, hv_hpa, get_hv_ram_size());
/* unmap prelaunch VM memory */
for (vm_id = 0U; vm_id < CONFIG_MAX_VM_NUM; vm_id++) {
vm_config = get_vm_config(vm_id);

View File

@@ -40,6 +40,7 @@
#include <logmsg.h>
#include <misc_cfg.h>
static uint32_t hv_ram_size;
static void *ppt_mmu_pml4_addr;
static uint8_t sanitized_page[PAGE_SIZE] __aligned(PAGE_SIZE);
@@ -151,6 +152,11 @@ void invept(const void *eptp)
}
}
uint32_t get_hv_ram_size(void)
{
return hv_ram_size;
}
void enable_paging(void)
{
uint64_t tmp64 = 0UL;
@@ -249,6 +255,7 @@ void init_paging(void)
const struct abi_mmap *p_mmap = abi->mmap_entry;
pr_dbg("HV MMU Initialization");
hv_ram_size = (uint32_t)(uint64_t)&ld_ram_size;
init_sanitized_page((uint64_t *)sanitized_page, hva2hpa_early(sanitized_page));
@@ -295,7 +302,7 @@ void init_paging(void)
*/
hv_hva = get_hv_image_base();
pgtable_modify_or_del_map((uint64_t *)ppt_mmu_pml4_addr, hv_hva & PDE_MASK,
CONFIG_HV_RAM_SIZE + (((hv_hva & (PDE_SIZE - 1UL)) != 0UL) ? PDE_SIZE : 0UL),
hv_ram_size + (((hv_hva & (PDE_SIZE - 1UL)) != 0UL) ? PDE_SIZE : 0UL),
PAGE_CACHE_WB, PAGE_CACHE_MASK | PAGE_USER, &ppt_pgtable, MR_MODIFY);
/*