Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1C3O3r-0005Tm-5F for qemu-devel@nongnu.org; Fri, 03 Sep 2004 20:05:43 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1C3O3o-0005Sp-Kd for qemu-devel@nongnu.org; Fri, 03 Sep 2004 20:05:41 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1C3O3o-0005SY-Ic for qemu-devel@nongnu.org; Fri, 03 Sep 2004 20:05:40 -0400 Received: from [212.238.201.82] (helo=xi.wantstofly.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1C3Nyc-0004vu-67 for qemu-devel@nongnu.org; Fri, 03 Sep 2004 20:00:18 -0400 Date: Sat, 4 Sep 2004 02:00:17 +0200 From: Lennert Buytenhek Message-ID: <20040904000017.GA27986@xi.wantstofly.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [Qemu-devel] [PATCH] fix interaction with noexecstack 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 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)