qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] RFC: mremap() patch
@ 2008-09-27 20:40 Vince Weaver
  0 siblings, 0 replies; only message in thread
From: Vince Weaver @ 2008-09-27 20:40 UTC (permalink / raw)
  To: qemu-devel

Hello

This patch lets programs using mremap() on 32-bit targets on top of 64-bit 
machines work.

It is a hack though in many ways.  I was wondering if anyone had any 
better ideas on how to implement this (short of fixing the Linux mremap() 
syscall which I think has already been shot-down on the linux-kernel list, 
and in any case would be linux specific and require new kernels).

The big problem is trying to get the original mmap() flags back.  Right 
now my patch just assumes write and read, which probably isn't correct.

Vince

Index: linux-user/mmap.c
===================================================================
--- linux-user/mmap.c	(revision 5321)
+++ linux-user/mmap.c	(working copy)
@@ -538,6 +538,25 @@
      mmap_lock();
      /* XXX: use 5 args syscall */
      host_addr = (long)mremap(g2h(old_addr), old_size, new_size, flags);
+#if TARGET_ABI_BITS == 32
+    if (host_addr > 0xffffffff) {
+       void *temp_addr;
+ 
+       temp_addr = mmap(NULL,new_size,
+			PROT_READ|PROT_WRITE,MAP_ANONYMOUS|MAP_PRIVATE|MAP_32BIT, 0, 0);
+       memcpy(temp_addr,(void *)host_addr,old_size);
+       munmap((void *)host_addr,new_size); 
+       host_addr=(long)temp_addr;
+
+ 
+       if (host_addr > 0xffffffff) {
+ 
+          printf("ERROR!  mremap() returned 64-bit value on 32-bit target!\n\n");
+          exit(-1); 
+       }
+    }
+#endif 
+
      if (host_addr == -1) {
          new_addr = -1;
      } else {

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

only message in thread, other threads:[~2008-09-27 20:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-27 20:40 [Qemu-devel] RFC: mremap() patch Vince Weaver

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).