From patchwork Tue Jul 11 15:16:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongbok Kim X-Patchwork-Id: 9834953 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C3971602A0 for ; Tue, 11 Jul 2017 15:19:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B50AC24151 for ; Tue, 11 Jul 2017 15:19:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A971926256; Tue, 11 Jul 2017 15:19:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3316A24151 for ; Tue, 11 Jul 2017 15:19:23 +0000 (UTC) Received: from localhost ([::1]:46967 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUwwc-0007Ey-En for patchwork-qemu-devel@patchwork.kernel.org; Tue, 11 Jul 2017 11:19:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55851) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUwtk-0005j1-2Q for qemu-devel@nongnu.org; Tue, 11 Jul 2017 11:16:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dUwth-0005xu-4a for qemu-devel@nongnu.org; Tue, 11 Jul 2017 11:16:24 -0400 Received: from mailapp01.imgtec.com ([195.59.15.196]:36075) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUwtg-0005wv-Uv for qemu-devel@nongnu.org; Tue, 11 Jul 2017 11:16:21 -0400 Received: from HHMAIL01.hh.imgtec.org (unknown [10.100.10.19]) by Forcepoint Email with ESMTPS id B9BBAADA4F336 for ; Tue, 11 Jul 2017 16:16:13 +0100 (IST) Received: from localhost.localdomain (192.168.169.30) by HHMAIL01.hh.imgtec.org (10.100.10.21) with Microsoft SMTP Server (TLS) id 14.3.294.0; Tue, 11 Jul 2017 16:16:17 +0100 From: Yongbok Kim To: Date: Tue, 11 Jul 2017 16:16:04 +0100 Message-ID: <1499786165-9404-2-git-send-email-yongbok.kim@imgtec.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1499786165-9404-1-git-send-email-yongbok.kim@imgtec.com> References: <1499786165-9404-1-git-send-email-yongbok.kim@imgtec.com> MIME-Version: 1.0 X-Originating-IP: [192.168.169.30] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 195.59.15.196 Subject: [Qemu-devel] [PULL 1/2] target/mips: fix msa copy_[s|u]_df rd = 0 corner case 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: Miodrag Dinic Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Miodrag Dinic This patch fixes the msa copy_[s|u]_df instruction emulation when the destination register rd is zero. Without this patch the zero register would get clobbered, which should never happen because it is supposed to be hardwired to 0. Fix this corner case by explicitly checking rd = 0 and effectively making these instructions emulation no-op in that case. Signed-off-by: Miodrag Dinic Reviewed-by: Aurelien Jarno Acked-by: Aurelien Jarno Signed-off-by: Yongbok Kim --- target/mips/translate.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/target/mips/translate.c b/target/mips/translate.c index 559f8fe..befb87f 100644 --- a/target/mips/translate.c +++ b/target/mips/translate.c @@ -18712,10 +18712,14 @@ static void gen_msa_elm_df(CPUMIPSState *env, DisasContext *ctx, uint32_t df, #endif switch (MASK_MSA_ELM(ctx->opcode)) { case OPC_COPY_S_df: - gen_helper_msa_copy_s_df(cpu_env, tdf, twd, tws, tn); + if (likely(wd != 0)) { + gen_helper_msa_copy_s_df(cpu_env, tdf, twd, tws, tn); + } break; case OPC_COPY_U_df: - gen_helper_msa_copy_u_df(cpu_env, tdf, twd, tws, tn); + if (likely(wd != 0)) { + gen_helper_msa_copy_u_df(cpu_env, tdf, twd, tws, tn); + } break; case OPC_INSERT_df: gen_helper_msa_insert_df(cpu_env, tdf, twd, tws, tn);