mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-08-03 09:23:35 +00:00
HV: vm_load: correct needed size of bzImage kernel
The previous code did not load bzImage start from protected mode part, result in the protected mode part un-align with kernel_alignment field and then cause kernel decompression start from a later aligned address. In this case we had to enlarge the needed size of bzImage kernel to kernel_init_size plus double size of kernel_alignment. With loading issue of bzImage protected mode part fixed, the kernel needed size is corrected in this patch. Tracked-On: #6323 Signed-off-by: Victor Sun <victor.sun@intel.com> Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
This commit is contained in:
parent
2b5bd2e87a
commit
d1d59437ea
@ -47,7 +47,7 @@ static void *get_initrd_load_addr(struct acrn_vm *vm, uint64_t kernel_start)
|
|||||||
uint64_t ramdisk_load_gpa = INVALID_GPA;
|
uint64_t ramdisk_load_gpa = INVALID_GPA;
|
||||||
uint64_t ramdisk_gpa_max = DEFAULT_RAMDISK_GPA_MAX;
|
uint64_t ramdisk_gpa_max = DEFAULT_RAMDISK_GPA_MAX;
|
||||||
struct zero_page *zeropage = (struct zero_page *)vm->sw.kernel_info.kernel_src_addr;
|
struct zero_page *zeropage = (struct zero_page *)vm->sw.kernel_info.kernel_src_addr;
|
||||||
uint32_t kernel_init_size, initrd_addr_max;
|
uint32_t kernel_init_size, kernel_align, initrd_addr_max;
|
||||||
uint64_t kernel_end;
|
uint64_t kernel_end;
|
||||||
|
|
||||||
/* Per Linux boot protocol, the Kernel need a size of contiguous
|
/* Per Linux boot protocol, the Kernel need a size of contiguous
|
||||||
@ -58,9 +58,10 @@ static void *get_initrd_load_addr(struct acrn_vm *vm, uint64_t kernel_start)
|
|||||||
*/
|
*/
|
||||||
stac();
|
stac();
|
||||||
kernel_init_size = zeropage->hdr.init_size;
|
kernel_init_size = zeropage->hdr.init_size;
|
||||||
|
kernel_align = zeropage->hdr.kernel_alignment;
|
||||||
initrd_addr_max = zeropage->hdr.initrd_addr_max;
|
initrd_addr_max = zeropage->hdr.initrd_addr_max;
|
||||||
stac();
|
stac();
|
||||||
kernel_end = kernel_start + MEM_2M + kernel_init_size;
|
kernel_end = roundup(kernel_start, kernel_align) + kernel_init_size;
|
||||||
|
|
||||||
if (initrd_addr_max != 0U) {
|
if (initrd_addr_max != 0U) {
|
||||||
ramdisk_gpa_max = initrd_addr_max;
|
ramdisk_gpa_max = initrd_addr_max;
|
||||||
@ -143,9 +144,9 @@ static void *get_bzimage_kernel_load_addr(struct acrn_vm *vm)
|
|||||||
uint32_t kernel_init_size = zeropage->hdr.init_size;
|
uint32_t kernel_init_size = zeropage->hdr.init_size;
|
||||||
/* Because the kernel load address need to be up aligned to kernel_align size
|
/* Because the kernel load address need to be up aligned to kernel_align size
|
||||||
* whereas find_space_from_ve820() can only return page aligned address,
|
* whereas find_space_from_ve820() can only return page aligned address,
|
||||||
* we enlarge the needed size to (kernel_init_size + 2 * kernel_align).
|
* we enlarge the needed size to (kernel_init_size + kernel_align).
|
||||||
*/
|
*/
|
||||||
uint32_t kernel_size = kernel_init_size + 2 * kernel_align;
|
uint32_t kernel_size = kernel_init_size + kernel_align;
|
||||||
|
|
||||||
get_boot_mods_range(&mods_start, &mods_end);
|
get_boot_mods_range(&mods_start, &mods_end);
|
||||||
mods_start = sos_vm_hpa2gpa(mods_start);
|
mods_start = sos_vm_hpa2gpa(mods_start);
|
||||||
|
Loading…
Reference in New Issue
Block a user