qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 2/2] Revived GUEST_BASE support for usermode emu


From: Mika Westerberg
Subject: Re: [Qemu-devel] [PATCH 2/2] Revived GUEST_BASE support for usermode emulation targets.
Date: Fri, 17 Apr 2009 02:24:03 +0300


On Apr 10, 2009, at 2:22 AM, malc wrote:

On Thu, 9 Apr 2009, address@hidden wrote:

From: Riku Voipio <address@hidden>

From: Mika Westerberg <address@hidden>

- Now GUEST_BASE is dynamic and can be set from command line.
- Qemu checks /proc/sys/vm/mmap_min_addr and sets GUEST_BASE
 if needed.
- Code generation supports GUEST_BASE for i386 and x86_64 hosts.

Signed-off-by: Riku Voipio <address@hidden>
[..snip..]

diff --git a/tcg/i386/tcg-target.c b/tcg/i386/tcg-target.c
index e0fd434..7cb51b5 100644
--- a/tcg/i386/tcg-target.c
+++ b/tcg/i386/tcg-target.c
@@ -560,6 +560,12 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args,
    /* add x(r1), r0 */
tcg_out_modrm_offset(s, 0x03, r0, r1, offsetof(CPUTLBEntry, addend) -
                         offsetof(CPUTLBEntry, addr_read));
+#elif defined(CONFIG_USE_GUEST_BASE)
+    /*
+     * Add guest_base to all loads.
+     */
+    tcg_out_mov(s, r0, addr_reg);    /* movl addr_reg, r0 */
+    tcg_out_addi(s, r0, GUEST_BASE); /* addl $GUEST_BASE, r0 */

I think 'lea' is warranted here, and likewise in _st and x86_64 case.

Can you be more specific about that? Do you mean that we should change MOV into
LEA?

I think that in this case, as we are just moving address (pointer) from one register to another, it should be ok. For example gcc generates from this:

static char *
f(char *p)
{
        return (p + 65536);
}

following code:

00000000 <f>:
   0:   55                      push   %ebp
   1:   89 e5                   mov    %esp,%ebp
   3:   8b 45 08                mov    0x8(%ebp),%eax
   6:   05 00 00 01 00          add    $0x10000,%eax
   b:   c9                      leave
   c:   c3                      ret

Or am I missing something?

Thanks,
MW





reply via email to

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