qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] RFC: mremap() patch


From: Vince Weaver
Subject: [Qemu-devel] RFC: mremap() patch
Date: Sat, 27 Sep 2008 16:40:15 -0400 (EDT)

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 {




reply via email to

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