qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Libo Zhou" <zhlb29@foxmail.com>
To: "Peter Maydell" <peter.maydell@linaro.org>
Cc: qemu-devel <qemu-devel@nongnu.org>
Subject: Re:  Initialize data memory in user space emulation
Date: Sat, 21 Sep 2019 00:29:46 +0800	[thread overview]
Message-ID: <tencent_2CB77C2B1C2DB29264EB30A0@qq.com> (raw)
In-Reply-To: <CAFEAcA-GEtZUVU838Cb0j7ekUzrQ9VTLFfFVL37BALzk_VQFBA@mail.gmail.com>

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";<peter.maydell@linaro.org>;
Send time: Saturday, Sep 21, 2019 0:08 AM
To: "Libo Zhou"<zhlb29@foxmail.com>; 
Cc: "qemu-devel"<qemu-devel@nongnu.org>; 
Subject:  Re: Initialize data memory in user space emulation



On Fri, 20 Sep 2019 at 16:26, Libo Zhou <zhlb29@foxmail.com> 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	other threads:[~2019-09-20 16:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-20  9:15 Initialize data memory in user space emulation Libo Zhou
2019-09-20 10:36 ` Peter Maydell
2019-09-20 14:49   ` Libo Zhou
2019-09-20 14:55     ` Peter Maydell
2019-09-20 15:26       ` Libo Zhou
2019-09-20 16:08         ` Peter Maydell
2019-09-20 16:29           ` Libo Zhou [this message]
2019-09-20  9:40 Libo Zhou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tencent_2CB77C2B1C2DB29264EB30A0@qq.com \
    --to=zhlb29@foxmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).