With load_elf() api, image load low address and high address is converted to physical address if parameter translate_fn is provided. However executing entry address is still virtual address. Here convert entry address into physical address, since MMU is disabled when system power on, the first PC instruction should be physical address.
Signed-off-by: Bibo Mao <maob...@loongson.cn> Reviewed-by: Richard Henderson <richard.hender...@linaro.org> --- v2 ... v3: 1. Modify link script about tcg system test cases, loading address is changed from virtual address 0x9000000000200000 to physical address 0x200000. Otherwise test case memory-with-libmem.so fails to run with check-tcg command. v1 ... v2: 1. Only modify LoongArch specified rather than load_elf() API, since there is be potential influence with other architectures. --- hw/loongarch/boot.c | 1 + tests/tcg/loongarch64/system/kernel.ld | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/loongarch/boot.c b/hw/loongarch/boot.c index 354cf458c8..0324d6adcb 100644 --- a/hw/loongarch/boot.c +++ b/hw/loongarch/boot.c @@ -245,6 +245,7 @@ static int64_t load_kernel_info(struct loongarch_boot_info *info) &kernel_entry, &kernel_low, &kernel_high, NULL, ELFDATA2LSB, EM_LOONGARCH, 1, 0); + kernel_entry = cpu_loongarch_virt_to_phys(NULL, kernel_entry); if (kernel_size < 0) { kernel_size = load_loongarch_linux_image(info->kernel_filename, &kernel_entry, &kernel_low, diff --git a/tests/tcg/loongarch64/system/kernel.ld b/tests/tcg/loongarch64/system/kernel.ld index f1a7c0168c..56d8588f1a 100644 --- a/tests/tcg/loongarch64/system/kernel.ld +++ b/tests/tcg/loongarch64/system/kernel.ld @@ -3,7 +3,7 @@ ENTRY(_start) SECTIONS { /* Linux kernel legacy start address. */ - . = 0x9000000000200000; + . = 0x200000; _text = .; .text : { *(.text) base-commit: 73d29ea2417b58ca55fba1aa468ba38e3607b583 -- 2.39.3