]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
hw/loongarch/virt: Get physical entry address with elf file
authorBibo Mao <maobibo@loongson.cn>
Fri, 25 Apr 2025 02:05:04 +0000 (10:05 +0800)
committerBibo Mao <maobibo@loongson.cn>
Tue, 6 May 2025 01:17:32 +0000 (09:17 +0800)
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 <maobibo@loongson.cn>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: Song Gao <gaosong@loongson.cn>
hw/loongarch/boot.c
tests/tcg/loongarch64/system/kernel.ld

index 354cf458c819f5bc020c0b0be5316b202509046f..0324d6adcbaec9be26458ddf9a5d302e45a376f1 100644 (file)
@@ -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,
index f1a7c0168c5e6a534ddfe6030fc49a0d46fc1603..56d8588f1a3221f47d0a7f99a200252cf685fe64 100644 (file)
@@ -3,7 +3,7 @@ ENTRY(_start)
 SECTIONS
 {
     /* Linux kernel legacy start address.  */
-    . = 0x9000000000200000;
+    . = 0x200000;
     _text = .;
     .text : {
         *(.text)