From d766487e3e27d276ead3adcf35b8acfe0f9d9a75 Mon Sep 17 00:00:00 2001 From: Zhang Chen Date: Thu, 27 Jul 2023 16:05:31 +0800 Subject: [PATCH] HV: elf_loader: Fix copy gpa bug in load elf32 The elf images can't be loaded correctly because the elf_loader copy_to_gpa with wrong size. The p_filesz and p_memsz both belong to elf32_prog_entry, this data structure describes segments loaded in ram. p_filesz means size of segment in file and p_memsz means size of segment in memory. ELF loader should copy elf_img to gpa with the size of p_prg_tbl_head32->p_filesz. Tracked-On: #8642 Signed-off-by: Zhang Chen Signed-off-by: Victor Sun Reviewed-by: Junjie Mao --- hypervisor/boot/guest/elf_loader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hypervisor/boot/guest/elf_loader.c b/hypervisor/boot/guest/elf_loader.c index 6e9b6915df..4fde38930a 100644 --- a/hypervisor/boot/guest/elf_loader.c +++ b/hypervisor/boot/guest/elf_loader.c @@ -173,7 +173,7 @@ static void *do_load_elf32(struct acrn_vm *vm) * We assume that the guest elf can put segments to valid gpa. */ (void)copy_to_gpa(vm, p_elf_img + p_prg_tbl_head32->p_offset, - p_prg_tbl_head32->p_paddr, p_prg_tbl_head32->p_memsz); + p_prg_tbl_head32->p_paddr, p_prg_tbl_head32->p_filesz); /* copy_to_gpa has it's stac/clac inside. So call stac again here. */ stac(); }