Browse Source

hw/loongarch/virt: Get physical entry address with elf file

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>
pull/291/head
Bibo Mao 11 months ago
parent
commit
73047c825e
  1. 1
      hw/loongarch/boot.c
  2. 2
      tests/tcg/loongarch64/system/kernel.ld

1
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,

2
tests/tcg/loongarch64/system/kernel.ld

@ -3,7 +3,7 @@ ENTRY(_start)
SECTIONS
{
/* Linux kernel legacy start address. */
. = 0x9000000000200000;
. = 0x200000;
_text = .;
.text : {
*(.text)

Loading…
Cancel
Save