From patchwork Thu Aug 3 14:45:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongbok Kim X-Patchwork-Id: 9879289 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 277DD603B4 for ; Thu, 3 Aug 2017 14:49:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 897C72892F for ; Thu, 3 Aug 2017 14:49:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E2F628931; Thu, 3 Aug 2017 14:49:32 +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 31A322892F for ; Thu, 3 Aug 2017 14:49:32 +0000 (UTC) Received: from localhost ([::1]:49692 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddHRL-0003Ta-GB for patchwork-qemu-devel@patchwork.kernel.org; Thu, 03 Aug 2017 10:49:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35459) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddHNT-00017l-Tu for qemu-devel@nongnu.org; Thu, 03 Aug 2017 10:45:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ddHNS-0002YF-Iv for qemu-devel@nongnu.org; Thu, 03 Aug 2017 10:45:31 -0400 Received: from mailapp01.imgtec.com ([195.59.15.196]:51454) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddHNS-0002Xu-CE for qemu-devel@nongnu.org; Thu, 03 Aug 2017 10:45:30 -0400 Received: from HHMAIL01.hh.imgtec.org (unknown [10.100.10.19]) by Forcepoint Email with ESMTPS id E57FD5D467ED2; Thu, 3 Aug 2017 15:45:25 +0100 (IST) Received: from hhmipssw204.hh.imgtec.org (10.100.21.121) by HHMAIL01.hh.imgtec.org (10.100.10.21) with Microsoft SMTP Server (TLS) id 14.3.294.0; Thu, 3 Aug 2017 15:45:29 +0100 From: Yongbok Kim To: Date: Thu, 3 Aug 2017 15:45:15 +0100 Message-ID: <1501771515-22847-9-git-send-email-yongbok.kim@imgtec.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1501771515-22847-1-git-send-email-yongbok.kim@imgtec.com> References: <1501771515-22847-1-git-send-email-yongbok.kim@imgtec.com> MIME-Version: 1.0 X-Originating-IP: [10.100.21.121] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 195.59.15.196 Subject: [Qemu-devel] [PULL 8/8] target/mips: Fix RDHWR CC with icount 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: Peter Maydell , James Hogan , Aurelien Jarno Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: James Hogan RDHWR CC reads the CPU timer like MFC0 CP0_Count, so with icount enabled it must set can_do_io while it calls the helper to avoid the "Bad icount read" error. It should also break out of the translation loop to ensure that timer interrupts are immediately handled. Fixes: 2e70f6efa8b9 ("Add instruction counter.") Signed-off-by: James Hogan Cc: Aurelien Jarno Cc: Yongbok Kim Reviewed-by: Richard Henderson Signed-off-by: Yongbok Kim --- target/mips/translate.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/target/mips/translate.c b/target/mips/translate.c index bcea2a1..c78d272 100644 --- a/target/mips/translate.c +++ b/target/mips/translate.c @@ -10755,8 +10755,19 @@ static void gen_rdhwr(DisasContext *ctx, int rt, int rd, int sel) gen_store_gpr(t0, rt); break; case 2: + if (ctx->tb->cflags & CF_USE_ICOUNT) { + gen_io_start(); + } gen_helper_rdhwr_cc(t0, cpu_env); + if (ctx->tb->cflags & CF_USE_ICOUNT) { + gen_io_end(); + } gen_store_gpr(t0, rt); + /* Break the TB to be able to take timer interrupts immediately + after reading count. BS_STOP isn't sufficient, we need to ensure + we break completely out of translated code. */ + gen_save_pc(ctx->pc + 4); + ctx->bstate = BS_EXCP; break; case 3: gen_helper_rdhwr_ccres(t0, cpu_env);