HV: relocate SOS kernel before boot modules for SBL

SBL would load multiboot modules to the maximum usable ram below 4GB, in this
case the SOS kernel would be failed to load because no room for kernel in
the range of end of modules and MEM_4G. So kernel must be relocated to the
range of MEM_1M and start of modules, or other appropriate place according
to modules layout.

Tracked-On: #6162

Signed-off-by: Victor Sun <victor.sun@intel.com>
This commit is contained in:
Victor Sun
2021-06-07 11:25:18 +08:00
committed by wenlingz
parent 79bd3f498f
commit 695e09a194
3 changed files with 86 additions and 56 deletions

View File

@@ -14,6 +14,27 @@
static struct acrn_boot_info acrn_bi = { 0U };
static char boot_protocol_name[16U] = { 0 };
/**
* @pre (p_start != NULL) && (p_end != NULL)
*/
void get_boot_mods_range(uint64_t *p_start, uint64_t *p_end)
{
uint32_t i;
uint64_t start = ~0UL, end = 0UL;
struct acrn_boot_info *abi = get_acrn_boot_info();
for (i = 0; i < abi->mods_count; i++) {
if (hva2hpa(abi->mods[i].start) < start) {
start = hva2hpa(abi->mods[i].start);
}
if (hva2hpa(abi->mods[i].start + abi->mods[i].size) > end) {
end = hva2hpa(abi->mods[i].start + abi->mods[i].size);
}
}
*p_start = start;
*p_end = end;
}
void init_acrn_boot_info(uint32_t *registers)
{
if (init_multiboot_info(registers) == 0) {