hv: remove CONFIG_LOW_RAM_SIZE

The CONFIG_LOW_RAM_SIZE is used to describe the size of trampoline code
that is never changed. And it totally confused user to configure it.

This patch hard code it to 1MB and remove the macro for configuration.
In the trampoline related code, use ld_trampoline_end and
ld_trampoline_start symbol to calculate the real size.

Tracked-On: #6805
Signed-off-by: Yuanyuan Zhao <yuanyuan.zhao@linux.intel.com>
Reviewed-by: Wang, Yu1 <yu1.wang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Yuanyuan Zhao 2021-10-27 14:41:55 +08:00 committed by wenlingz
parent c0b02e802f
commit 4f6aa38ea5
3 changed files with 14 additions and 12 deletions

View File

@ -42,6 +42,7 @@
#ifdef CONFIG_SECURITY_VM_FIXUP
#include <quirks/security_vm_fixup.h>
#endif
#include <asm/boot/ld_sym.h>
/* Local variables */
@ -409,6 +410,7 @@ static void prepare_service_vm_memmap(struct acrn_vm *vm)
uint32_t entries_count = vm->e820_entry_num;
const struct e820_entry *p_e820 = vm->e820_entries;
struct pci_mmcfg_region *pci_mmcfg;
uint64_t trampoline_memory_size = round_page_up((uint64_t)(&ld_trampoline_end - &ld_trampoline_start));
pr_dbg("Service VM e820 layout:\n");
for (i = 0U; i < entries_count; i++) {
@ -462,7 +464,7 @@ static void prepare_service_vm_memmap(struct acrn_vm *vm)
/* unmap AP trampoline code for security
* This buffer is guaranteed to be page aligned.
*/
ept_del_mr(vm, pml4_page, get_trampoline_start16_paddr(), CONFIG_LOW_RAM_SIZE);
ept_del_mr(vm, pml4_page, get_trampoline_start16_paddr(), trampoline_memory_size);
/* unmap PCIe MMCONFIG region since it's owned by hypervisor */
pci_mmcfg = get_mmcfg_region();

View File

@ -107,22 +107,22 @@ static void update_trampoline_code_refs(uint64_t dest_pa)
uint64_t prepare_trampoline(void)
{
uint64_t size, dest_pa;
uint64_t trampline_size, trampoline_pa;
size = (uint64_t)(&ld_trampoline_end - &ld_trampoline_start);
dest_pa = e820_alloc_memory(CONFIG_LOW_RAM_SIZE, MEM_1M);
trampline_size = (uint64_t)(&ld_trampoline_end - &ld_trampoline_start);
trampoline_pa = e820_alloc_memory(trampline_size, MEM_1M);
pr_dbg("trampoline code: %lx size %x", dest_pa, size);
pr_dbg("trampoline code: %lx trampline_size %x", trampoline_pa, trampline_size);
/* Copy segment for AP initialization code below 1MB */
(void)memcpy_s(hpa2hva(dest_pa), (size_t)size, &ld_trampoline_load,
(size_t)size);
update_trampoline_code_refs(dest_pa);
(void)memcpy_s(hpa2hva(trampoline_pa), (size_t)trampline_size, &ld_trampoline_load,
(size_t)trampline_size);
update_trampoline_code_refs(trampoline_pa);
cpu_memory_barrier();
flush_cache_range(hpa2hva(dest_pa), size);
flush_cache_range(hpa2hva(trampoline_pa), trampline_size);
trampoline_start16_paddr = dest_pa;
trampoline_start16_paddr = trampoline_pa;
return dest_pa;
return trampoline_pa;
}

View File

@ -3,7 +3,7 @@ ENTRY(cpu_primary_start_32)
MEMORY
{
/* Low 1MB of memory for secondary processor start-up */
lowram : ORIGIN = 0, LENGTH = CONFIG_LOW_RAM_SIZE
lowram : ORIGIN = 0, LENGTH = 0x100000
/* 32 MBytes of RAM for HV */
ram : ORIGIN = CONFIG_HV_RAM_START, LENGTH = 0x80000000 - CONFIG_HV_RAM_START