qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Initialize data memory in user space emulation


From: Peter Maydell
Subject: Re: Initialize data memory in user space emulation
Date: Fri, 20 Sep 2019 17:08:54 +0100

On Fri, 20 Sep 2019 at 16:26, Libo Zhou <address@hidden> wrote:
>
> I actually thought about hacking it to mmap from file into guest memory 
> before running ELF. In include/exec/memory.h, the function 
> memory_region_init_ram_from_file sounds like what I need. But the entire 
> memory.h source file is wrapped by #ifndef CONFIG_USER_ONLY, I cannot use 
> that API in user space emulation, right?

Correct, you don't want to use that. You want
to put some code in linux-user/main.c, probably
just after the call to signal_init(), which opens
the host file and then calls target_mmap() to mmap
it into the host.

If you happen to have the source for the guest program,
you could also just make it do the open and mmap() itself
as the first thing it does in main() -- this is basically
equivalent. Or if the guest program is dynamically linked
then you can use QEMU's -E option to set the LD_PRELOAD
environment variable for the guest to make it load a guest
shared library that has a constructor function that does
the open/mmap before the guest main() gets control.

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]