qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] [resubmit] Allocate translation buffer before guest RAM, in case guest RAM is too large on 64 bit hosts
@ 2008-10-22 22:10 Juergen Lock
  2008-10-23  6:31 ` Laurent Desnogues
  0 siblings, 1 reply; 3+ messages in thread
From: Juergen Lock @ 2008-10-22 22:10 UTC (permalink / raw)
  To: qemu-devel

Hi!

 Further explanation as requested: cpu_exec_init_all() below allocates
code_gen_buffer which needs to be in the lower 4G (actually 2G I guess)
because it uses 32 bit branch offsets.  Allocate this first so that the
guest RAM allocation can't get in the way i.e. block the lower vm when
doing something like -m 4096 on systems that allocate from low addresses
by default.

 I hope this is more clear now? :)

 Thanx,
	Juergen

----- Forwarded message from Juergen Lock <nox@jelal.kn-bremen.de> -----

From: Juergen Lock <nox@jelal.kn-bremen.de>
Date: Sat, 18 Oct 2008 23:05:08 +0200
To: qemu-devel@nongnu.org
Subject: [PATCH] Allocate translation buffer before guest RAM, in case
	guest RAM is too large on 64 bit hosts
User-Agent: Mutt/1.5.17 (2007-11-01)

Hi!

 The following patch appears to fix -m >= 1024 on recent FreeBSD/amd64 hosts
(RELENG_7/HEAD) that no longer return high addresses for allocations by
default (which was the original reason for r5331.)  As this makes sense
in any case when you pass something like -m 4096 on hosts that allocate
from low addresses by default (there would be no room left for the
translation buffer in the low vm where it needs to be), I patched it like
this instead of conditionalizing the mmap hack from r5331 on the FreeBSD
version.

Index: qemu/vl.c
@@ -9850,15 +9850,15 @@
         phys_ram_size += ram_size;
     }
 
+    /* init the dynamic translator */
+    cpu_exec_init_all(tb_size * 1024 * 1024);
+
     phys_ram_base = qemu_vmalloc(phys_ram_size);
     if (!phys_ram_base) {
         fprintf(stderr, "Could not allocate physical memory\n");
         exit(1);
     }
 
-    /* init the dynamic translator */
-    cpu_exec_init_all(tb_size * 1024 * 1024);
-
     bdrv_init(emulate_aio);
 
     /* we always create the cdrom drive, even if no disk is there */

Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de>
----- End forwarded message -----

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] [resubmit] Allocate translation buffer before guest RAM, in case guest RAM is too large on 64 bit hosts
  2008-10-22 22:10 [Qemu-devel] [PATCH] [resubmit] Allocate translation buffer before guest RAM, in case guest RAM is too large on 64 bit hosts Juergen Lock
@ 2008-10-23  6:31 ` Laurent Desnogues
  2008-10-23 21:29   ` Juergen Lock
  0 siblings, 1 reply; 3+ messages in thread
From: Laurent Desnogues @ 2008-10-23  6:31 UTC (permalink / raw)
  To: qemu-devel

On Thu, Oct 23, 2008 at 12:10 AM, Juergen Lock <nox@jelal.kn-bremen.de> wrote:
>
>  Further explanation as requested: cpu_exec_init_all() below allocates
> code_gen_buffer which needs to be in the lower 4G (actually 2G I guess)
> because it uses 32 bit branch offsets.  Allocate this first so that the
> guest RAM allocation can't get in the way i.e. block the lower vm when
> doing something like -m 4096 on systems that allocate from low addresses
> by default.
>
>  I hope this is more clear now? :)

What about including a shorter version of that explanation as a comment
in your patch ? :)


Laurent

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] [resubmit] Allocate translation buffer before guest RAM, in case guest RAM is too large on 64 bit hosts
  2008-10-23  6:31 ` Laurent Desnogues
@ 2008-10-23 21:29   ` Juergen Lock
  0 siblings, 0 replies; 3+ messages in thread
From: Juergen Lock @ 2008-10-23 21:29 UTC (permalink / raw)
  To: laurent.desnogues; +Cc: qemu-devel

In article <761ea48b0810222331g2e56f4e0ocde6229ae975d5ef@mail.gmail.com> you write:
>On Thu, Oct 23, 2008 at 12:10 AM, Juergen Lock <nox@jelal.kn-bremen.de> wrote:
>>
>>  Further explanation as requested: cpu_exec_init_all() below allocates
>> code_gen_buffer which needs to be in the lower 4G (actually 2G I guess)
>> because it uses 32 bit branch offsets.  Allocate this first so that the
>> guest RAM allocation can't get in the way i.e. block the lower vm when
>> doing something like -m 4096 on systems that allocate from low addresses
>> by default.
>>
>>  I hope this is more clear now? :)
>
>What about including a shorter version of that explanation as a comment
>in your patch ? :)

Ok here we go:

Index: qemu/vl.c
@@ -9938,15 +9938,19 @@
         phys_ram_size += ram_size;
     }
 
+    /* init the dynamic translator */
+    /* This allocates code_gen_buffer which needs to be in the lower vm at
+     * least on amd64 hosts because it uses 32 bit branch offsets etc.
+     * Do this before the guest RAM allocation below so that that can't
+     * get in the way. */
+    cpu_exec_init_all(tb_size * 1024 * 1024);
+
     phys_ram_base = qemu_vmalloc(phys_ram_size);
     if (!phys_ram_base) {
         fprintf(stderr, "Could not allocate physical memory\n");
         exit(1);
     }
 
-    /* init the dynamic translator */
-    cpu_exec_init_all(tb_size * 1024 * 1024);
-
     bdrv_init();
 
     /* we always create the cdrom drive, even if no disk is there */

Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-10-23 21:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-22 22:10 [Qemu-devel] [PATCH] [resubmit] Allocate translation buffer before guest RAM, in case guest RAM is too large on 64 bit hosts Juergen Lock
2008-10-23  6:31 ` Laurent Desnogues
2008-10-23 21:29   ` Juergen Lock

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