From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IY5jB-0002oO-0y for qemu-devel@nongnu.org; Wed, 19 Sep 2007 16:00:53 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IY5j8-0002lV-SB for qemu-devel@nongnu.org; Wed, 19 Sep 2007 16:00:52 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IY5j7-0002kp-HI for qemu-devel@nongnu.org; Wed, 19 Sep 2007 16:00:49 -0400 Received: from mail.codesourcery.com ([65.74.133.4]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IY5j6-0002SY-Vd for qemu-devel@nongnu.org; Wed, 19 Sep 2007 16:00:49 -0400 From: Paul Brook Subject: Re: [Qemu-devel] RFC: [0/11] EFAULT patch Date: Wed, 19 Sep 2007 21:00:43 +0100 References: <1190167518.14938.348.camel@rapid> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200709192100.43630.paul@codesourcery.com> 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 Cc: Stuart Anderson On Wednesday 19 September 2007, Stuart Anderson wrote: > On Wed, 19 Sep 2007, J. Mayer wrote: > > Then, the changes you've done, changing long arguments (which should be > > target_long to be correct, you can take a look at the last patch I sent > > on the list) to pointers, for example in function prototypes, are > > incorrect. > > I just went, and looked at the linux code again for 32 on 64 for x86_64 and > powerpc. In both of these cases (and I suspect the others as well), the > parameters which are passed via registers are 0 extended from 32 bits to > 64 bit in the syscall entry asm code. This way, once the C code is > called via the sys_call_table, everything is dealt with as 64 bits. This > actually keeps the rest of the code simpler as the rest of the kernel > doesn't have to be extending & truncating pointers everywhere else. > > On x86_64 and powerpc, it appears that both user (ie target) and kernel > pointers co-exist and that the code that maps structures assume that the > __get_user()/__put_user() and copy_*_user() routines can handle any > special situation. The pointers passed into functions like > cp_compat_stat() are 64-bits for both the structure located in the > kernel, and the one located in user space. > > My understanding is that we want to do as the kernel does as much as > possible. In light of this, wouldn't we want to be decreasing the use > of target_long where pointers may be involved instead of increasing it? No. We're doing more than most 32-64 syscall thunks. To a first approximation the syscall thunks can bindly zero extend all values. In qemu we need to know whether something is a pointer or a value. Kernel and userspace addresses are not interchangeable in the kernel. Any place that does so is probably a bug. Paul