From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34703) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YuN5L-0006lw-4B for qemu-devel@nongnu.org; Mon, 18 May 2015 11:36:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YuN5G-0001qp-Re for qemu-devel@nongnu.org; Mon, 18 May 2015 11:36:07 -0400 Received: from mail-qc0-x242.google.com ([2607:f8b0:400d:c01::242]:34613) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YuN5G-0001qg-Gm for qemu-devel@nongnu.org; Mon, 18 May 2015 11:36:02 -0400 Received: by qcvs11 with SMTP id s11so213797qcv.1 for ; Mon, 18 May 2015 08:36:00 -0700 (PDT) Sender: Richard Henderson Message-ID: <555A06DC.7030608@twiddle.net> Date: Mon, 18 May 2015 08:35:56 -0700 From: Richard Henderson MIME-Version: 1.0 References: <1431818883-14944-1-git-send-email-aurelien@aurel32.net> In-Reply-To: <1431818883-14944-1-git-send-email-aurelien@aurel32.net> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] target-s390x: fix CC computation for EX instruction List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Aurelien Jarno , qemu-devel@nongnu.org Cc: Alexander Graf On 05/16/2015 04:28 PM, Aurelien Jarno wrote: > Commit 7a6c7067f optimized CC computation by only saving cc_op before > calling helpers as they either don't touch the CC or generate a new > static value. This however doesn't work for the EX instruction as the > helper changes or not the CC value depending on the actual executed > instruction (e.g. MVC vs CLC). > > This patches force a CC computation before calling the helper. This > fixes random memory corruption occuring in guests. > > Cc: Richard Henderson > Cc: Alexander Graf > Signed-off-by: Aurelien Jarno > --- > target-s390x/translate.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/target-s390x/translate.c b/target-s390x/translate.c > index 80e3a54..10522df 100644 > --- a/target-s390x/translate.c > +++ b/target-s390x/translate.c > @@ -2095,7 +2095,7 @@ static ExitStatus op_ex(DisasContext *s, DisasOps *o) > TCGv_i64 tmp; > > update_psw_addr(s); > - update_cc_op(s); > + gen_op_calc_cc(s); > > tmp = tcg_const_i64(s->next_pc); > gen_helper_ex(cc_op, cpu_env, cc_op, o->in1, o->in2, tmp); I agree this is a bug, and the right fix. You can also remove the set_cc_static at the end of op_ex, since that's done by gen_op_calc_cc. r~