qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Fix page protection flag handling solving ARM emulation issues
@ 2008-04-23 13:48 Richard Purdie
  0 siblings, 0 replies; only message in thread
From: Richard Purdie @ 2008-04-23 13:48 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1095 bytes --]

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



[-- Attachment #2: fix_protection_bits.patch --]
[-- Type: text/x-patch, Size: 513 bytes --]

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;
 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-04-23 13:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-23 13:48 [Qemu-devel] [PATCH] Fix page protection flag handling solving ARM emulation issues Richard Purdie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).