From patchwork Thu Jun 15 08:17:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 776172 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wpGbM1G68z9s76 for ; Thu, 15 Jun 2017 18:18:07 +1000 (AEST) Received: from localhost ([::1]:52673 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dLPye-0007wE-Mw for incoming@patchwork.ozlabs.org; Thu, 15 Jun 2017 04:18:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34644) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dLPxw-0007uJ-60 for qemu-devel@nongnu.org; Thu, 15 Jun 2017 04:17:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dLPxs-0001uV-4v for qemu-devel@nongnu.org; Thu, 15 Jun 2017 04:17:20 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:64416) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dLPxr-0001tz-Oc for qemu-devel@nongnu.org; Thu, 15 Jun 2017 04:17:16 -0400 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue003 [212.227.15.167]) with ESMTPSA (Nemesis) id 0LqpKo-1dycKx2vqc-00ePPi; Thu, 15 Jun 2017 10:17:13 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Thu, 15 Jun 2017 10:17:08 +0200 Message-Id: <20170615081711.25347-2-laurent@vivier.eu> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170615081711.25347-1-laurent@vivier.eu> References: <20170615081711.25347-1-laurent@vivier.eu> X-Provags-ID: V03:K0:6YBHxtJ11eZjvgv0P67cfb3DJFZaXJhnNQ2DNxT/WWkBLkmPMGn gb5MHBnHUiO/xj/O7N34gVkz9BIVSmuGcZrsM/S1D0nF0XpQafdfy+BVq1zq2oFVe0dX0Z3 n2mLfOmb3hZNM+eJsCwNHZRGqgU+nC9/5DzYXjtm4hxEDYYH2891C4jR/JJwg/H/nnvgKNe lCUAKL8JyRfYK3o4ap40w== X-UI-Out-Filterresults: notjunk:1; V01:K0:eEGpewzOc+o=:E1p1tYIr1VUW1WDOGWMAZC m1MqfnXuvtzhLWp53inWrJ3wCqk0X4wLcziuVi++eOaKq9HjmzkBeq7Z1N5X8JMKYNvKA3S3f OACCzqBuF2FaQz8nOnoLHmmIlpji6JILKJOYOmPNTy5oTbCzTAMttjBuZNF1ed6CPmovZqxa6 x5Skvl/7PTrv5bZUP/waJPFaqpoJwfgru8kwzjeXHRWbBX21kpbGXB7adChvvAR/As/Js5sbT QlEb6mnMcQsXaCXr+yiNN9JSNfWRGYD5U8NvJ9IpzLKse6M89/sjmjPo9PUH5ubXcPasyRezw DyTaEhvrzqHYOh/qNlwczDpO3bCMAHh1d9IAHehU/61bd0NelcyYmNAm3g7GorhVTKFoEPWER a+62RAD1P7FYJXcRt4SlMlucffrI9o24rsoBtdaRDOtaFM/blp/jQZ8fTZBpTKL0MMrQAfeMa 7NtVgODR1KwcIMDuD3AhQSkTW8Mxj2XZVXczNWUGvCOUZfJF0vg7TnYGErFCWeVJI3+MEnSTF L1opteYTJB9pAKBx4uLbwxX93AIFww+i5yobrGIZ6718uX5QahPNWutd3OtCIkkmFkQSl7ck3 DYky0+D3soFvFeFJOjQ51DdoR2JrSEsSyBoGbGBdAvVd0h+6Snx048T/ZuLkL7qkDgJaX1lvU 7cUy5Hdi3G5me+m5Kpoh3x7jllrqrGtZ0sevCSYQkqN0iQ0vwciLwVp2bMgUZLMwtbgA= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.126.135 Subject: [Qemu-devel] [PULL 1/4] target/m68k: fix V flag for CC_OP_SUBx X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" V flag for subtraction is: v = (res ^ src1) & (src1 ^ src2) (see COMPUTE_CCR() in target/m68k/helper.c) But gen_flush_flags() uses: v = (res ^ src2) & (src1 ^ src2) The problem has been found with the following program: .global _start _start: move.l #-2147483648,%d0 subq.l #1,%d0 jvc 1f move.l #1,%d1 move.l #1,%d0 trap #0 1: move.l #0,%d1 move.l #1,%d0 trap #0 It works fine (exit(1)) on real hardware, and with "-singlestep". "-singlestep" uses gen_helper_flush_flags(), whereas without "-singlestep", V flag is computed directly in gen_flush_flags(). This patch updates gen_flush_flags() to have the same result as with gen_helper_flush_flags(). Signed-off-by: Laurent Vivier Reviewed-by: Richard Henderson Message-Id: <20170614203905.19657-1-laurent@vivier.eu> --- target/m68k/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/m68k/translate.c b/target/m68k/translate.c index ad4d4ef..52653f6 100644 --- a/target/m68k/translate.c +++ b/target/m68k/translate.c @@ -565,7 +565,7 @@ static void gen_flush_flags(DisasContext *s) t1 = tcg_temp_new(); tcg_gen_add_i32(t0, QREG_CC_N, QREG_CC_V); gen_ext(t0, t0, s->cc_op - CC_OP_SUBB, 1); - tcg_gen_xor_i32(t1, QREG_CC_N, QREG_CC_V); + tcg_gen_xor_i32(t1, QREG_CC_N, t0); tcg_gen_xor_i32(QREG_CC_V, QREG_CC_V, t0); tcg_temp_free(t0); tcg_gen_and_i32(QREG_CC_V, QREG_CC_V, t1);