mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-12-17 18:32:40 +00:00
We should not hardcode the VM ramdisk load address right after kernel load address because of two reasons: 1. Per Linux kernel boot protocol, the Kernel need a size of contiguous memory(i.e. init_size field in zeropage) from its load address to boot, then the address would overlap with ramdisk; 2. The hardcoded address could not be ensured as a valid address in guest e820 table, especially with a huge ramdisk; Also we should not hardcode the VM kernel load address to its pref_address which work for non-relocatable kernel only. For a relocatable kernel, it could run from any valid address where bootloader load to. The patch will set the VM kernel and ramdisk load address by scanning guest e820 table with find_space_from_ve820() api: 1. For SOS VM, the ramdisk has been loaded by multiboot bootloader already so set the load address as module source address, the relocatable kernel would be relocated to a higher address after hypervisor and all multiboot modules to avoid guest memory copy corruption; 2. For pre-launched VM, the kernel would be loaded to pref_address first. If kernel end address is higher than maximum ramdisk address limit, hypervisor would try to locate ramdisk load address from 0x100000 to kernel load address; If kernel end address is lower than maximum ramdisk address limit, hypervisor would try to locate ramdisk address from kernel end address to the maximum ramdisk address limit under 4GB; Tracked-On: #5879 Signed-off-by: Victor Sun <victor.sun@intel.com> Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>