From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1C3YC5-0000L6-U4 for qemu-devel@nongnu.org; Sat, 04 Sep 2004 06:54:54 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1C3YC4-0000Ku-9z for qemu-devel@nongnu.org; Sat, 04 Sep 2004 06:54:53 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1C3YC4-0000Kr-1w for qemu-devel@nongnu.org; Sat, 04 Sep 2004 06:54:52 -0400 Received: from [129.104.30.34] (helo=a.mx.polytechnique.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1C3Y6o-0005Jk-3A for qemu-devel@nongnu.org; Sat, 04 Sep 2004 06:49:26 -0400 Received: from localhost (localhost [127.0.0.1]) by djali.m4x.org (Postfix) with ESMTP id 820AA3320D for ; Sat, 4 Sep 2004 12:49:22 +0200 (CEST) Received: from djali.m4x.org ([127.0.0.1]) by localhost (djali [127.0.0.1]) (amavisd-new, port 10025) with ESMTP id 12524-03 for ; Sat, 4 Sep 2004 12:49:22 +0200 (CEST) Received: from bellard.org (nas-cbv-6-213-228-26-37.dial.proxad.net [213.228.26.37]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by ssl.polytechnique.org (Postfix) with ESMTP id 5998433207 for ; Sat, 4 Sep 2004 12:49:18 +0200 (CEST) Message-ID: <41399DC2.2030404@bellard.org> Date: Sat, 04 Sep 2004 12:49:38 +0200 From: Fabrice Bellard MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] fix interaction with noexecstack References: <20040904000017.GA27986@xi.wantstofly.org> In-Reply-To: <20040904000017.GA27986@xi.wantstofly.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit 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 The patch seems OK for me, at least until the instruction cache is dynamically allocated. Fabrice. Lennert Buytenhek wrote: > Hi, > > qemu-arm doesn't work on Fedora Core 2 by default because it expects to > be able to execute stuff off the heap (code_gen_buffer), but that part of > the heap is not marked PROT_EXEC, and Fedora Core 2 has a patch that sets > the CS segment limit to the highest PROT_EXEC-mapped address in the address > space. > > It's a bit of a hacky fix, but it Works For Me(tm) on the default Fedora > 2.6.5 kernel. I haven't yet looked into why qemu-arm was crashing on the > Fedora 2.6.[78] update kernels. > > > --L > > > diff -urN qemu-20040804.orig/exec.c qemu-20040804.test/exec.c > --- qemu-20040804.orig/exec.c 2004-07-06 02:00:18.000000000 +0300 > +++ qemu-20040804.test/exec.c 2004-09-04 02:49:25.414945456 +0300 > @@ -127,6 +127,9 @@ > > static void page_init(void) > { > + unsigned long address; > + unsigned long length; > + > /* NOTE: we can always suppose that qemu_host_page_size >= > TARGET_PAGE_SIZE */ > #ifdef _WIN32 > @@ -134,6 +137,17 @@ > #else > qemu_real_host_page_size = getpagesize(); > #endif > + > + address = (unsigned long)code_gen_buffer; > + address &= ~(qemu_real_host_page_size - 1); > + > + length = (unsigned long)code_gen_buffer + sizeof(code_gen_buffer); > + length -= address; > + length += qemu_real_host_page_size - 1; > + length &= ~(qemu_real_host_page_size - 1); > + > + mprotect(address, length, PROT_READ | PROT_WRITE | PROT_EXEC); > + > if (qemu_host_page_size == 0) > qemu_host_page_size = qemu_real_host_page_size; > if (qemu_host_page_size < TARGET_PAGE_SIZE) > > > > _______________________________________________ > Qemu-devel mailing list > Qemu-devel@nongnu.org > http://lists.nongnu.org/mailman/listinfo/qemu-devel > >