From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1C3Zbo-0002rf-4E for qemu-devel@nongnu.org; Sat, 04 Sep 2004 08:25:32 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1C3Zbh-0002qE-G3 for qemu-devel@nongnu.org; Sat, 04 Sep 2004 08:25:31 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1C3Zbh-0002q9-4n for qemu-devel@nongnu.org; Sat, 04 Sep 2004 08:25:25 -0400 Received: from [195.250.128.73] (helo=smtp1.vol.cz) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.34) id 1C3ZW2-00060i-Dp for qemu-devel@nongnu.org; Sat, 04 Sep 2004 08:19:36 -0400 Received: from [83.148.10.154] (a6prg-154.dialup.vol.cz [83.148.10.154]) by smtp1.vol.cz (8.12.9p2/8.12.9) with ESMTP id i84CJCnq071126 for ; Sat, 4 Sep 2004 14:19:12 +0200 (CEST) (envelope-from xnavara@volny.cz) Message-ID: <4139B2C3.6000203@volny.cz> Date: Sat, 04 Sep 2004 14:19:15 +0200 From: Filip Navara MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] fix interaction with noexecstack References: <20040904000017.GA27986@xi.wantstofly.org> <41399DC2.2030404@bellard.org> In-Reply-To: <41399DC2.2030404@bellard.org> Content-Type: text/plain; charset=ISO-8859-1; 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 Fabrice Bellard wrote: > The patch seems OK for me, at least until the instruction cache is > dynamically allocated. I haven't tried the patch, but there isn't any "mprotect" function on Windows so I guess it would break MinGW builds. See the code below. It should work, but *I HAVEN'T TESTED IT*: Regards, Filip > Lennert Buytenhek wrote: [snip] >> --- 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; > #ifdef _WIN32 DWORD old_protect; #endif >> + >> /* 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); >> + > #ifdef _WIN32 * *VirtualProtect(address, length, PAGE_EXECUTE_READWRITE, &old_protect); #else >> + mprotect(address, length, PROT_READ | PROT_WRITE | PROT_EXEC); > #endif >> + >> if (qemu_host_page_size == 0) >> qemu_host_page_size = qemu_real_host_page_size; >> if (qemu_host_page_size < TARGET_PAGE_SIZE) >