From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Jz7TV-0001HQ-KK for qemu-devel@nongnu.org; Thu, 22 May 2008 05:52:41 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Jz7TU-0001Gt-T1 for qemu-devel@nongnu.org; Thu, 22 May 2008 05:52:41 -0400 Received: from [199.232.76.173] (port=54045 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jz7TU-0001Ga-Eb for qemu-devel@nongnu.org; Thu, 22 May 2008 05:52:40 -0400 Received: from savannah.gnu.org ([199.232.41.3]:49403 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Jz7TU-0004S5-6s for qemu-devel@nongnu.org; Thu, 22 May 2008 05:52:40 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1Jz7TT-0003as-1F for qemu-devel@nongnu.org; Thu, 22 May 2008 09:52:39 +0000 Received: from bellard by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1Jz7TS-0003ao-Li for qemu-devel@nongnu.org; Thu, 22 May 2008 09:52:38 +0000 MIME-Version: 1.0 Errors-To: bellard Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Fabrice Bellard Message-Id: Date: Thu, 22 May 2008 09:52:38 +0000 Subject: [Qemu-devel] [4522] cmpxchg8b fix - added cmpxchg16b 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 Revision: 4522 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4522 Author: bellard Date: 2008-05-22 09:52:38 +0000 (Thu, 22 May 2008) Log Message: ----------- cmpxchg8b fix - added cmpxchg16b Modified Paths: -------------- trunk/target-i386/helper.c trunk/target-i386/helper.h trunk/target-i386/translate.c Modified: trunk/target-i386/helper.c =================================================================== --- trunk/target-i386/helper.c 2008-05-22 09:36:08 UTC (rev 4521) +++ trunk/target-i386/helper.c 2008-05-22 09:52:38 UTC (rev 4522) @@ -1879,8 +1879,8 @@ eflags = cc_table[CC_OP].compute_all(); d = ldq(a0); - if (d == (((uint64_t)EDX << 32) | EAX)) { - stq(a0, ((uint64_t)ECX << 32) | EBX); + if (d == (((uint64_t)EDX << 32) | (uint32_t)EAX)) { + stq(a0, ((uint64_t)ECX << 32) | (uint32_t)EBX); eflags |= CC_Z; } else { EDX = (uint32_t)(d >> 32); @@ -1890,6 +1890,28 @@ CC_SRC = eflags; } +#ifdef TARGET_X86_64 +void helper_cmpxchg16b(target_ulong a0) +{ + uint64_t d0, d1; + int eflags; + + eflags = cc_table[CC_OP].compute_all(); + d0 = ldq(a0); + d1 = ldq(a0 + 8); + if (d0 == EAX && d1 == EDX) { + stq(a0, EBX); + stq(a0 + 8, ECX); + eflags |= CC_Z; + } else { + EDX = d1; + EAX = d0; + eflags &= ~CC_Z; + } + CC_SRC = eflags; +} +#endif + void helper_single_step(void) { env->dr[6] |= 0x4000; Modified: trunk/target-i386/helper.h =================================================================== --- trunk/target-i386/helper.h 2008-05-22 09:36:08 UTC (rev 4521) +++ trunk/target-i386/helper.h 2008-05-22 09:52:38 UTC (rev 4522) @@ -75,6 +75,9 @@ void helper_rsm(void); void helper_into(int next_eip_addend); void helper_cmpxchg8b(target_ulong a0); +#ifdef TARGET_X86_64 +void helper_cmpxchg16b(target_ulong a0); +#endif void helper_single_step(void); void helper_cpuid(void); void helper_rdtsc(void); Modified: trunk/target-i386/translate.c =================================================================== --- trunk/target-i386/translate.c 2008-05-22 09:36:08 UTC (rev 4521) +++ trunk/target-i386/translate.c 2008-05-22 09:52:38 UTC (rev 4522) @@ -4333,11 +4333,26 @@ mod = (modrm >> 6) & 3; if ((mod == 3) || ((modrm & 0x38) != 0x8)) goto illegal_op; - gen_jmp_im(pc_start - s->cs_base); - if (s->cc_op != CC_OP_DYNAMIC) - gen_op_set_cc_op(s->cc_op); - gen_lea_modrm(s, modrm, ®_addr, &offset_addr); - tcg_gen_helper_0_1(helper_cmpxchg8b, cpu_A0); +#ifdef TARGET_X86_64 + if (dflag == 2) { + if (!(s->cpuid_ext_features & CPUID_EXT_CX16)) + goto illegal_op; + gen_jmp_im(pc_start - s->cs_base); + if (s->cc_op != CC_OP_DYNAMIC) + gen_op_set_cc_op(s->cc_op); + gen_lea_modrm(s, modrm, ®_addr, &offset_addr); + tcg_gen_helper_0_1(helper_cmpxchg16b, cpu_A0); + } else +#endif + { + if (!(s->cpuid_features & CPUID_CX8)) + goto illegal_op; + gen_jmp_im(pc_start - s->cs_base); + if (s->cc_op != CC_OP_DYNAMIC) + gen_op_set_cc_op(s->cc_op); + gen_lea_modrm(s, modrm, ®_addr, &offset_addr); + tcg_gen_helper_0_1(helper_cmpxchg8b, cpu_A0); + } s->cc_op = CC_OP_EFLAGS; break;