From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JFRtp-0005w8-3x for qemu-devel@nongnu.org; Thu, 17 Jan 2008 05:23:05 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JFRto-0005vF-85 for qemu-devel@nongnu.org; Thu, 17 Jan 2008 05:23:04 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JFRtn-0005v9-U2 for qemu-devel@nongnu.org; Thu, 17 Jan 2008 05:23:03 -0500 Received: from kassel160.server4you.de ([62.75.246.160] helo=csgraf.de) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JFRtn-0008Pe-CL for qemu-devel@nongnu.org; Thu, 17 Jan 2008 05:23:03 -0500 Received: from [10.10.100.38] (charybdis-ext.suse.de [195.135.221.2]) by csgraf.de (Postfix) with ESMTP id 40604615F for ; Thu, 17 Jan 2008 11:23:02 +0100 (CET) Message-ID: <478EF8FD.5080009@csgraf.de> Date: Thu, 17 Jan 2008 07:43:09 +0100 From: Alexander Graf MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------040206080603030900030701" Subject: [Qemu-devel] [PATCH 5/5] Fix x86_64 support Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------040206080603030900030701 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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. --------------040206080603030900030701 Content-Type: text/x-patch; name="qemu-gcc4-x86_64.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="qemu-gcc4-x86_64.patch" 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", --------------040206080603030900030701--