qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Vince Weaver <vince@csl.cornell.edu>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] RFC: mremap() patch
Date: Sat, 27 Sep 2008 16:40:15 -0400 (EDT)	[thread overview]
Message-ID: <20080927163641.O28993@stanley.csl.cornell.edu> (raw)

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	other threads:[~2008-09-27 20:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080927163641.O28993@stanley.csl.cornell.edu \
    --to=vince@csl.cornell.edu \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).