From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IrcVF-0001rd-Eo for qemu-devel@nongnu.org; Mon, 12 Nov 2007 11:51:13 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IrcVB-0001oU-Ff for qemu-devel@nongnu.org; Mon, 12 Nov 2007 11:51:12 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IrcVB-0001oH-A0 for qemu-devel@nongnu.org; Mon, 12 Nov 2007 11:51:09 -0500 Received: from owa.c2.net ([207.235.78.2] helo=email.c2.net) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IrcVA-0000zo-Gg for qemu-devel@nongnu.org; Mon, 12 Nov 2007 11:51:09 -0500 Subject: Re: [Qemu-devel] RFC: x86_64 Best way to fix 'cast to pointer from integer of different size' problems? From: Thayne Harbaugh In-Reply-To: <47320F6E.5060505@bellard.org> References: <1194110810.13889.25.camel@hephaestion> <200711031752.20135.paul@codesourcery.com> <1194292268.5154.73.camel@phantasm.home.enterpriseandprosperity.com> <200711060105.04529.paul@codesourcery.com> <1194314417.5154.176.camel@phantasm.home.enterpriseandprosperity.com> <47320F6E.5060505@bellard.org> Content-Type: multipart/mixed; boundary="=-T9v0VCBptLKS7tY2T3ep" Date: Mon, 12 Nov 2007 09:42:58 -0700 Message-Id: <1194885778.20408.26.camel@phantasm.home.enterpriseandprosperity.com> Mime-Version: 1.0 Reply-To: thayne@c2.net, 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 --=-T9v0VCBptLKS7tY2T3ep Content-Type: text/plain Content-Transfer-Encoding: 7bit On Wed, 2007-11-07 at 20:18 +0100, Fabrice Bellard wrote: > - Fix page_check_range() so that it handles writes to pages containing > code by calling page_unprotect when necessary (the current code can fail > in this case !). > > - Suppress no longer needed page_unprotect_range() call in syscall.c. Something like this? Looks like exec.c needs some attention regarding target_ulong/abi_ulong. --=-T9v0VCBptLKS7tY2T3ep Content-Disposition: attachment; filename=06_efault.patch.1.4 Content-Type: text/x-patch; name=06_efault.patch.1.4; charset=utf-8 Content-Transfer-Encoding: 7bit Index: qemu/linux-user/syscall.c =================================================================== --- qemu.orig/linux-user/syscall.c 2007-11-12 09:56:01.000000000 -0700 +++ qemu/linux-user/syscall.c 2007-11-12 09:56:12.000000000 -0700 @@ -2745,7 +2745,6 @@ ret = 0; /* avoid warning */ break; case TARGET_NR_read: - page_unprotect_range(arg2, arg3); if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0))) goto efault; ret = get_errno(read(arg1, p, arg3)); @@ -4538,7 +4537,6 @@ break; #ifdef TARGET_NR_pread case TARGET_NR_pread: - page_unprotect_range(arg2, arg3); if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0))) goto efault; ret = get_errno(pread(arg1, p, arg3, arg4)); Index: qemu/exec.c =================================================================== --- qemu.orig/exec.c 2007-11-12 09:56:01.000000000 -0700 +++ qemu/exec.c 2007-11-12 10:00:41.000000000 -0700 @@ -1898,6 +1898,9 @@ return -1; if (!(p->flags & PAGE_WRITE) && (flags & PAGE_WRITE) ) return -1; + if ((p->flags & PAGE_EXEC) && (flags & PAGE_WRITE) + && page_unprotect(addr, 0, NULL)) + return -1; } return 0; } @@ -1942,21 +1945,6 @@ return 0; } -/* call this function when system calls directly modify a memory area */ -/* ??? This should be redundant now we have lock_user. */ -void page_unprotect_range(target_ulong data, target_ulong data_size) -{ - target_ulong start, end, addr; - - start = data; - end = start + data_size; - start &= TARGET_PAGE_MASK; - end = TARGET_PAGE_ALIGN(end); - for(addr = start; addr < end; addr += TARGET_PAGE_SIZE) { - page_unprotect(addr, 0, NULL); - } -} - static inline void tlb_set_dirty(CPUState *env, unsigned long addr, target_ulong vaddr) { --=-T9v0VCBptLKS7tY2T3ep--