qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 5/5] Fix x86_64 support


From: Alexander Graf
Subject: [Qemu-devel] [PATCH 5/5] Fix x86_64 support
Date: Thu, 17 Jan 2008 07:43:09 +0100
User-agent: Thunderbird 2.0.0.9 (X11/20070801)

This is the very same patch I sent to this list some weeks ago. It
implements DIRECT_JUMP for x86_64, making it work with gcc4.
diff --git a/exec-all.h b/exec-all.h
index 285da99..6d9b1cd 100644
--- a/exec-all.h
+++ b/exec-all.h
@@ -142,6 +142,9 @@ static inline int tlb_set_page(CPUState *env, target_ulong 
vaddr,
 #if defined(__i386__) && !defined(_WIN32)
 #define USE_DIRECT_JUMP
 #endif
+#if defined(__x86_64__)
+#define USE_DIRECT_JUMP
+#endif
 
 typedef struct TranslationBlock {
     target_ulong pc;   /* simulated PC corresponding to this block (EIP + CS 
base) */
@@ -228,7 +231,7 @@ static inline void tb_set_jmp_target1(unsigned long 
jmp_addr, unsigned long addr
     asm volatile ("sync" : : : "memory");
     asm volatile ("isync" : : : "memory");
 }
-#elif defined(__i386__)
+#elif defined(__i386__) || defined(__x86_64__)
 static inline void tb_set_jmp_target1(unsigned long jmp_addr, unsigned long 
addr)
 {
     /* patch the branch destination */
@@ -320,6 +323,18 @@ do {\
                  "1:\n");\
 } while (0)
 
+#elif defined(__x86_64__) && defined(USE_DIRECT_JUMP)
+
+#define GOTO_TB(opname, tbparam, n)\
+do {\
+    asm volatile (ASM_DATA_SECTION\
+                 ASM_OP_LABEL_NAME(n, opname) ":\n"\
+                 ".quad 1f\n"\
+                 ASM_PREVIOUS_SECTION \
+                  "jmp " ASM_NAME(__op_jmp) #n "\n"\
+                 "1:\n");\
+} while (0)
+
 #else
 
 /* jump to next block operations (more portable code, does not need
diff --git a/dyngen.c b/dyngen.c
index d301c71..e1023a8 100644
--- a/dyngen.c
+++ b/dyngen.c
@@ -1931,6 +2076,17 @@ void gen_code(const char *name, host_ulong offset, 
host_ulong size,
                     type = ELF32_R_TYPE(rel->r_info);
                     addend = rel->r_addend;
                     reloc_offset = rel->r_offset - start_offset;
+                    if (strstart(sym_name, "__op_jmp", &p)) {
+                        int n;
+                        n = strtol(p, NULL, 10);
+                        /* __op_jmp relocations are done at
+                           runtime to do translated block
+                           chaining: the offset of the instruction
+                           needs to be stored */
+                        fprintf(outfile, "    jmp_offsets[%d] = %d + 
(gen_code_ptr - gen_code_buf);\n",
+                                n, reloc_offset);
+                        continue;
+                    }
                     switch(type) {
                     case R_X86_64_32:
                         fprintf(outfile, "    *(uint32_t *)(gen_code_ptr + %d) 
= (uint32_t)%s + %d;\n",

reply via email to

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