qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paul Brook <paul@codesourcery.com>
To: qemu-devel@nongnu.org
Cc: Stuart Anderson <anderson@netsweng.com>
Subject: Re: [Qemu-devel] [PATCH] linux-user EFAULT implementation
Date: Tue, 10 Jul 2007 13:38:43 +0100	[thread overview]
Message-ID: <200707101338.44885.paul@codesourcery.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0707092218270.12799@trantor.stuart.netsweng.com>

On Tuesday 10 July 2007, Stuart Anderson wrote:
> On Mon, 9 Jul 2007, Fabrice Bellard wrote:
> > No. Ideally you should use the same conventions as the Linux kernel and
> > assume that you cannot access the user data directly.
>
> That's what I had already started doing today.
>
> > For the time being, I would suggest to minimize the number of changes and
> > just extend lock_user()/unlock_user() as you began to do to handle
> > -EFAULT. The rest is mostly a question of cosmetics.
>
> The attached patch is my in-progress work of the complete overhaul to use
> the kernel conventions. It needs some more work to finish the
> conversion, but enough should be done to see how it is going to turn
> out. Overall, I think the converted code is easier to read, especially
> if you are familiar with reading kernel code. I also think it will end
> up being more correct both becasue of the additional time now spent on
> reviewing each syscall, as well as the kernel conventions tend to make
> you be more thorough and explicite.

>  {
>      struct target_rusage *target_rusage;
>
> -    lock_user_struct(target_rusage, target_addr, 0);
> +    if( !access_ok(VERIFY_READ,target_addr,sizeof(*target_rusage)) )
> return -1;
> +    target_rusage = (struct target_rusage *)g2h(target_addr); 

Using g2h directly is bad. g2h is an implementation detail of one particular 
memory model.

The whole point of the lock_user abstraction (or a similar copy_from_user 
abstraction) is that almost none of the code cares how "user" memory is 
accessed. One of the long-term goals of this abstraction is to allow the 
softmmu code to be used with userspace emulation. In this case a region may 
be split across multiple discontiguous host pages.

The reason I used a locking paradigm rather than a copying one is that it 
allows a zero-copy implementation in the common case. I've no strong 
objections to a copying interface, however it must be implementation 
agnostic.

Paul

  reply	other threads:[~2007-07-10 12: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
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 [this message]
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=200707101338.44885.paul@codesourcery.com \
    --to=paul@codesourcery.com \
    --cc=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).