From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56793) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPuKf-00076y-D8 for qemu-devel@nongnu.org; Wed, 20 Jul 2016 12:26:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bPuKb-0005aa-0x for qemu-devel@nongnu.org; Wed, 20 Jul 2016 12:26:48 -0400 Received: from mga03.intel.com ([134.134.136.65]:46927) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPuKa-0005aN-R4 for qemu-devel@nongnu.org; Wed, 20 Jul 2016 12:26:44 -0400 From: Dave Hansen Date: Wed, 20 Jul 2016 08:57:40 -0700 Message-Id: <1469030260-28448-1-git-send-email-dave.hansen@intel.com> Subject: [Qemu-devel] [PATCH] i386 translation: fix typo in xsetbv implementation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: dave@sr71.net, qemu-devel@nongnu.org Cc: Dave Hansen , Dave Hansen , Paolo Bonzini , Eduardo Habkost , Richard Henderson QEMU 2.6 added support for the XSAVE family of instructions, which includes the XSETBV instruction which allows setting the 'XCR0' register. But, when booting Linux kernels with XSAVE support enabled, I was getting very early crashes where the instruction pointer was set to 0x3. I tracked it down to a jump instruction generated by this: gen_jmp_im(s->pc - pc_start); where s->pc is pointing to the instruction after XSETBV and pc_start is pointing _at_ XSETBV. Subtract the two and you get 0x3. Whoops. The fix is to replace this typo with the pattern found everywhere else in the file when folks want to end the translation buffer. Richard Henderson confirmed that this is a bug and that this is the correct fix. Signed-off-by: Dave Hansen Cc: Paolo Bonzini Cc: Eduardo Habkost Cc: Richard Henderson --- target-i386/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target-i386/translate.c b/target-i386/translate.c index 1a1214d..53a065c 100644 --- a/target-i386/translate.c +++ b/target-i386/translate.c @@ -7170,7 +7170,7 @@ static target_ulong disas_insn(CPUX86State *env, DisasContext *s, tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_regs[R_ECX]); gen_helper_xsetbv(cpu_env, cpu_tmp2_i32, cpu_tmp1_i64); /* End TB because translation flags may change. */ - gen_jmp_im(s->pc - pc_start); + gen_jmp_im(s->pc - s->cs_base); gen_eob(s); break; -- 1.9.1