All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 5/5] Fix x86_64 support
@ 2008-01-17  6:43 Alexander Graf
  0 siblings, 0 replies; only message in thread
From: Alexander Graf @ 2008-01-17  6:43 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 128 bytes --]

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.

[-- Attachment #2: qemu-gcc4-x86_64.patch --]
[-- Type: text/x-patch, Size: 2408 bytes --]

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",

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2008-01-17 10:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-17  6:43 [Qemu-devel] [PATCH 5/5] Fix x86_64 support Alexander Graf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.