[PATCH] hw/elf_ops: Use physical address about kernel entry

Bibo Mao posted 1 patch 11 months, 3 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20250219021758.190644-1-maobibo@loongson.cn
include/hw/elf_ops.h.inc | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
[PATCH] hw/elf_ops: Use physical address about kernel entry
Posted by Bibo Mao 11 months, 3 weeks ago
With load_elf() API, if input parameter translate_fn is set, loading
address is converted to physical address. It should be the same for entry
address, since MMU is disabled when system power on, the first instruction
of PC should be physical address.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
 include/hw/elf_ops.h.inc | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/hw/elf_ops.h.inc b/include/hw/elf_ops.h.inc
index 9c35d1b9da..37ce7845a9 100644
--- a/include/hw/elf_ops.h.inc
+++ b/include/hw/elf_ops.h.inc
@@ -388,7 +388,11 @@ static ssize_t glue(load_elf, SZ)(const char *name, int fd,
         *pflags = ehdr.e_flags;
     }
     if (pentry) {
-        *pentry = ehdr.e_entry;
+        if (translate_fn) {
+            *pentry = translate_fn(translate_opaque, ehdr.e_entry);
+        } else {
+            *pentry = ehdr.e_entry;
+        }
     }
 
     glue(load_symbols, SZ)(&ehdr, fd, must_swab, clear_lsb, sym_cb);

base-commit: db7aa99ef894e88fc5eedf02ca2579b8c344b2ec
-- 
2.39.3
Re: [PATCH] hw/elf_ops: Use physical address about kernel entry
Posted by bibo mao 11 months ago
Gently ping :)
On 2025/2/19 上午10:17, Bibo Mao wrote:
> With load_elf() API, if input parameter translate_fn is set, loading
> address is converted to physical address. It should be the same for entry
> address, since MMU is disabled when system power on, the first instruction
> of PC should be physical address.
> 
> Signed-off-by: Bibo Mao <maobibo@loongson.cn>
> ---
>   include/hw/elf_ops.h.inc | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/include/hw/elf_ops.h.inc b/include/hw/elf_ops.h.inc
> index 9c35d1b9da..37ce7845a9 100644
> --- a/include/hw/elf_ops.h.inc
> +++ b/include/hw/elf_ops.h.inc
> @@ -388,7 +388,11 @@ static ssize_t glue(load_elf, SZ)(const char *name, int fd,
>           *pflags = ehdr.e_flags;
>       }
>       if (pentry) {
> -        *pentry = ehdr.e_entry;
> +        if (translate_fn) {
> +            *pentry = translate_fn(translate_opaque, ehdr.e_entry);
> +        } else {
> +            *pentry = ehdr.e_entry;
> +        }
>       }
>   
>       glue(load_symbols, SZ)(&ehdr, fd, must_swab, clear_lsb, sym_cb);
> 
> base-commit: db7aa99ef894e88fc5eedf02ca2579b8c344b2ec
>