From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JofLG-0002VR-8a for qemu-devel@nongnu.org; Wed, 23 Apr 2008 09:48:58 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JofLE-0002UI-G9 for qemu-devel@nongnu.org; Wed, 23 Apr 2008 09:48:57 -0400 Received: from [199.232.76.173] (port=48021 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JofLE-0002Tu-28 for qemu-devel@nongnu.org; Wed, 23 Apr 2008 09:48:56 -0400 Received: from tim.rpsys.net ([194.106.48.114]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JofLC-0000r7-KN for qemu-devel@nongnu.org; Wed, 23 Apr 2008 09:48:55 -0400 Received: from localhost (localhost [127.0.0.1]) by tim.rpsys.net (8.13.6/8.13.8) with ESMTP id m3NDmfJC009881 for ; Wed, 23 Apr 2008 14:48:41 +0100 Received: from tim.rpsys.net ([127.0.0.1]) by localhost (tim.rpsys.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 09444-10 for ; Wed, 23 Apr 2008 14:48:36 +0100 (BST) Received: from [192.168.1.3] (dax.rpnet.com [192.168.1.3]) (authenticated bits=0) by tim.rpsys.net (8.13.6/8.13.8) with ESMTP id m3NDmZtP009871 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 23 Apr 2008 14:48:35 +0100 From: Richard Purdie Content-Type: multipart/mixed; boundary="=-S+QpzW/fUQU4zHeAk5wi" Date: Wed, 23 Apr 2008 14:48:36 +0100 Message-Id: <1208958516.4988.30.camel@dax.rpnet.com> Mime-Version: 1.0 Subject: [Qemu-devel] [PATCH] Fix page protection flag handling solving ARM emulation issues 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 --=-S+QpzW/fUQU4zHeAk5wi Content-Type: text/plain Content-Transfer-Encoding: 7bit Hi, I've been seeing some strange errors when trying to mix binaries from two different ARM toolchains. They work on real hardware but they don't work under qemu failing with an error about being unable to change the stack area protection bits. I tracked this down to an mprotect call failing inside the dynamic linker. The reason is that ARM has some strange page protection bits (from mman.h): #define PROT_GROWSDOWN 0x01000000 /* Extend change to start of growsdown vma (mprotect only). */ #define PROT_GROWSUP 0x02000000 /* Extend change to start of growsup vma (mprotect only). */ and if qemu sees these as page protection flags it gets rather upset. A fix is to: a) not error if these bits are present b) not pass them to the host system since that doesn't like them I've attached a simple patch which fixes the ARM on x86 case. This shouldn't break anything existing although some tweaking of the bits may be needed for some mixtures of other architectures. Regards, Richard --=-S+QpzW/fUQU4zHeAk5wi Content-Disposition: attachment; filename=fix_protection_bits.patch Content-Type: text/x-patch; name=fix_protection_bits.patch; charset=UTF-8 Content-Transfer-Encoding: 7bit Index: qemu-0.9.1/linux-user/mmap.c =================================================================== --- qemu-0.9.1.orig/linux-user/mmap.c 2008-04-16 14:10:26.000000000 +0100 +++ qemu-0.9.1/linux-user/mmap.c 2008-04-16 14:10:51.000000000 +0100 @@ -49,8 +49,7 @@ end = start + len; if (end < start) return -EINVAL; - if (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC)) - return -EINVAL; + prot = prot & (PROT_READ | PROT_WRITE | PROT_EXEC); if (len == 0) return 0; --=-S+QpzW/fUQU4zHeAk5wi--