HV: correct hv_ram_size when hv is relocated

In previous commit df7ffab441
the CONFIG_HV_RAM_SIZE was removed and the hv_ram_size was calculated in
link script by following formula:
	ld_ram_size = _ld_ram_end - _ld_ram_start ;
but _ld_ram_start is a relative address in boot section whereas _ld_ram_end
is a absolute address in global, the mix operation cause hv_ram_size is
incorrect when HV binary is relocated.

The patch fix this issue by getting _ld_ram_start and _ld_ram_end respectively
and calculated at runtime.

Tracked-On: #6885

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
This commit is contained in:
Victor Sun 2021-11-24 11:02:05 +08:00 committed by wenlingz
parent 0940b35340
commit e718f48a55
3 changed files with 3 additions and 3 deletions

View File

@ -255,7 +255,7 @@ void init_paging(void)
const struct abi_mmap *p_mmap = abi->mmap_entry;
pr_dbg("HV MMU Initialization");
hv_ram_size = (uint64_t)&ld_ram_size;
hv_ram_size = (uint64_t)(&_ld_ram_end - &_ld_ram_start);
init_sanitized_page((uint64_t *)sanitized_page, hva2hpa_early(sanitized_page));

View File

@ -100,5 +100,4 @@ SECTIONS
. = ALIGN(0x200000) ;
_ld_ram_end = . ;
ld_ram_size = _ld_ram_end - _ld_ram_start ;
}

View File

@ -14,6 +14,7 @@ extern uint8_t ld_entry_end;
extern const uint8_t ld_trampoline_load;
extern uint8_t ld_trampoline_start;
extern uint8_t ld_trampoline_end;
extern uint8_t ld_ram_size;
extern uint8_t _ld_ram_start;
extern uint8_t _ld_ram_end;
#endif /* LD_SYM_H */