From: Stuart Anderson <anderson@netsweng.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] linux-user EFAULT implementation
Date: Fri, 6 Jul 2007 14:45:51 -0400 (EDT) [thread overview]
Message-ID: <Pine.LNX.4.64.0707061433490.12799@trantor.stuart.netsweng.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0707061253470.12799@trantor.stuart.netsweng.com>
On Fri, 6 Jul 2007, Stuart Anderson wrote:
>> Moreover, I believe using similar functions as Linux for memory access
>> (copyfromuser, copytouser, get_user, put_user) would be cleaner.
>
> This makes sense. That code that I sent was based on the idea that I was
> just extending the model that was already there, instead of giving it a
> complete overhaul. I'll look into how much work the overhaul would be.
After some digging, the one "design-level" issue I have found is that the
current lock_user_struct() and the new lock_and_check_user_struct(),
interfaces are based on the assumption that we need to map addresses
between guest and host, so they provide a place to call g2h() and return the
new address. This is different from copy_{to|from}_user(), which assumes
all addresses are valid as is, but that the system just needs to ensure
they are correctly mapped in for the data copy.
Contrary to this, cpu-all.h has the following comment & code:
#define GUEST_BASE 0
/* All direct uses of g2h and h2g need to go away for usermode softmmu. */
#define g2h(x) ((void *)((unsigned long)(x) + GUEST_BASE))
#define h2g(x) ((target_ulong)(x - GUEST_BASE))
It appears that g2h() and h2g() are mostly no-ops, with the typecasting
being the only possible useful part remaining.
So, the question is:
Can I simplify this code to assume that guest and
host addresses coexist and use the copy_*_user() or
just the access_ok() interfaces?
This would be one step closer to eliminating the use of g2h() and h2g() in
the usermode code as is suggested by the comment in cpu-all.h.
One other comment to make, is that in most cases, a simple copy is not
sufficient. Unlike the real Linux kernel, in many places, we are doing
structure mapping instead of a simple buffer copy.
Stuart
Stuart R. Anderson anderson@netsweng.com
Network & Software Engineering http://www.netsweng.com/
1024D/37A79149: 0791 D3B8 9A4C 2CDC A31F
BD03 0A62 E534 37A7 9149
next prev parent reply other threads:[~2007-07-06 18:46 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-06 15:15 [Qemu-devel] [PATCH] linux-user EFAULT implementation Stuart Anderson
2007-07-06 16:08 ` Fabrice Bellard
2007-07-06 16:55 ` Stuart Anderson
2007-07-06 18:45 ` Stuart Anderson [this message]
2007-07-09 11:41 ` Stuart Anderson
2007-07-09 12:02 ` Stuart Anderson
2007-07-09 21:15 ` Fabrice Bellard
2007-07-10 2:22 ` Stuart Anderson
2007-07-10 12:38 ` Paul Brook
2007-07-10 20:45 ` Fabrice Bellard
2007-07-10 21:09 ` Stuart Anderson
2007-07-13 17:55 ` Stuart Anderson
2007-07-20 20:16 ` Stuart Anderson
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=Pine.LNX.4.64.0707061433490.12799@trantor.stuart.netsweng.com \
--to=anderson@netsweng.com \
--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).