All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fabrice Bellard <fabrice@bellard.org>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] linux-user EFAULT implementation
Date: Mon, 09 Jul 2007 23:15:09 +0200	[thread overview]
Message-ID: <4692A55D.5050102@bellard.org> (raw)
In-Reply-To: <Pine.LNX.4.64.0707090734490.12799@trantor.stuart.netsweng.com>

Stuart Anderson wrote:
> On Fri, 6 Jul 2007, Stuart Anderson wrote:
> 
>> 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?

No. Ideally you should use the same conventions as the Linux kernel and 
assume that you cannot access the user data directly. To summarise:

- access_ok() is needed before __copy_*_user and __[get|put]_user.

- access_ok() is not needed before copy_[to|from]_user and [get|put]_user.

- [get|put]_user do automatic endianness change.

- Use tswapx and the other related functions to change the endianness 
before or after copy_*_user.

- for specific cases requiring speed (e.g. buffers for read/write 
syscalls), specific tricks to avoid memory copies can be used with a 
lock/unlock style API.

> Attached is a diff [...]

Please send a unified diff.

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.

Regards,

Fabrice.

  parent reply	other threads:[~2007-07-09 21:16 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 [this message]
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=4692A55D.5050102@bellard.org \
    --to=fabrice@bellard.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.