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: Libo Zhou
Subject: Re: Initialize data memory in user space emulation
Date: Sat, 21 Sep 2019 00:29:46 +0800

Thanks for your insightful input. I will come back to this thread after I tried 
all the options.

Cheers,
Libo Zhou




------------------ Original ------------------
From:  "Peter Maydell";<address@hidden>;
Send time: Saturday, Sep 21, 2019 0:08 AM
To: "Libo Zhou"<address@hidden>; 
Cc: "qemu-devel"<address@hidden>; 
Subject:  Re: Initialize data memory in user space emulation



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]