qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] fix interaction with noexecstack


From: Filip Navara
Subject: Re: [Qemu-devel] [PATCH] fix interaction with noexecstack
Date: Sat, 04 Sep 2004 14:19:15 +0200
User-agent: Mozilla Thunderbird 0.7.3 (Windows/20040803)

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)






reply via email to

[Prev in Thread] Current Thread [Next in Thread]