From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1I80aR-0001Ha-Qq for qemu-devel@nongnu.org; Mon, 09 Jul 2007 17:16:03 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1I80aP-0001HO-6e for qemu-devel@nongnu.org; Mon, 09 Jul 2007 17:16:02 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1I80aP-0001HL-18 for qemu-devel@nongnu.org; Mon, 09 Jul 2007 17:16:01 -0400 Received: from sp604003mt.neufgp.fr ([84.96.92.56] helo=smTp.neuf.fr) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1I80aO-0004tD-Lx for qemu-devel@nongnu.org; Mon, 09 Jul 2007 17:16:00 -0400 Received: from [86.73.70.249] by sp604003mt.gpm.neuf.ld (Sun Java System Messaging Server 6.2-5.05 (built Feb 16 2006)) with ESMTP id <0JKX00BSFKDN6XE0@sp604003mt.gpm.neuf.ld> for qemu-devel@nongnu.org; Mon, 09 Jul 2007 23:15:24 +0200 (CEST) Date: Mon, 09 Jul 2007 23:15:09 +0200 From: Fabrice Bellard Subject: Re: [Qemu-devel] [PATCH] linux-user EFAULT implementation In-reply-to: Message-id: <4692A55D.5050102@bellard.org> MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 7BIT References: <468E68F7.8070005@bellard.org> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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.