qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] hw/loongarch/virt: Get physical entry address with elf file
@ 2025-04-25  2:16 Bibo Mao
  2025-04-25 15:33 ` Richard Henderson
  0 siblings, 1 reply; 3+ messages in thread
From: Bibo Mao @ 2025-04-25  2:16 UTC (permalink / raw)
  To: Richard Henderson, Philippe Mathieu-Daudé, Song Gao; +Cc: qemu-devel

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>
---
  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 +
 1 file changed, 1 insertion(+)

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,

base-commit: 019fbfa4bcd2d3a835c241295e22ab2b5b56129b
-- 
2.39.3



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] hw/loongarch/virt: Get physical entry address with elf file
  2025-04-25  2:16 [PATCH v2] hw/loongarch/virt: Get physical entry address with elf file Bibo Mao
@ 2025-04-25 15:33 ` Richard Henderson
  2025-04-27  8:34   ` bibo mao
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Henderson @ 2025-04-25 15:33 UTC (permalink / raw)
  To: Bibo Mao, Philippe Mathieu-Daudé, Song Gao; +Cc: qemu-devel

On 4/24/25 19:16, Bibo Mao wrote:
> 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>
> ---
>    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 +
>   1 file changed, 1 insertion(+)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

Although perhaps we should adjust the API because all users have to do exactly this, and 
it's easy to miss.


r~


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] hw/loongarch/virt: Get physical entry address with elf file
  2025-04-25 15:33 ` Richard Henderson
@ 2025-04-27  8:34   ` bibo mao
  0 siblings, 0 replies; 3+ messages in thread
From: bibo mao @ 2025-04-27  8:34 UTC (permalink / raw)
  To: Richard Henderson, Philippe Mathieu-Daudé, Song Gao; +Cc: qemu-devel



On 2025/4/25 下午11:33, Richard Henderson wrote:
> On 4/24/25 19:16, Bibo Mao wrote:
>> 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>
>> ---
>>    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 +
>>   1 file changed, 1 insertion(+)
> 
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> 
> Although perhaps we should adjust the API because all users have to do 
> exactly this, and it's easy to miss.
Thanks, that is fair.

Regards
Bibo Mao
> 
> 
> r~



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-04-27  8:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-25  2:16 [PATCH v2] hw/loongarch/virt: Get physical entry address with elf file Bibo Mao
2025-04-25 15:33 ` Richard Henderson
2025-04-27  8:34   ` bibo mao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).