From patchwork Wed Sep 5 01:43:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 10588163 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AA554920 for ; Wed, 5 Sep 2018 01:48:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B8E529CC0 for ; Wed, 5 Sep 2018 01:48:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F2A329CF0; Wed, 5 Sep 2018 01:48:59 +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=-7.3 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,FROM_LOCAL_NOVOWEL,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 2BB4529CC0 for ; Wed, 5 Sep 2018 01:48:59 +0000 (UTC) Received: from localhost ([::1]:53399 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fxMwE-0003Et-FM for patchwork-qemu-devel@patchwork.kernel.org; Tue, 04 Sep 2018 21:48:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57825) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fxMs0-0005wO-9C for qemu-devel@nongnu.org; Tue, 04 Sep 2018 21:44:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fxMrz-0006n1-0M for qemu-devel@nongnu.org; Tue, 04 Sep 2018 21:44:36 -0400 Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]:42888) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fxMry-0006lt-My for qemu-devel@nongnu.org; Tue, 04 Sep 2018 21:44:34 -0400 Received: by mail-lf1-x136.google.com with SMTP id z11-v6so4568322lff.9 for ; Tue, 04 Sep 2018 18:44:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+CdP+JtmU77mO5MGmmItIopubGRzTQRFLRe3LfxOQnk=; b=Eu7rhbYZ4HX3GB61pDyHxNLpaZoQg0UqgOH1kRi7Ib2KEW0+vy0wBtVX91dl+ehkPq zqaJ+pjO+FXpLVmGy9FB4SczBLFqV14pKzu30z4cJK1G3ao28srbJsD3giolzWpCQp6h I2ZrlN6gfjZPRjAUQfLBZFJifzi0E2GyzXVJM3EVOUd1mYgMgkuAfDLpwUc7/JSSeYCN eHUoS39dbuBZmH5xTx+9RoCpNr8NfQ1ItXbZMh7WSnFQw1cPtYdtBdVa7EsON3LM/Ygf DXb+hlMe1XGsTwh3FLo5IIe0iXag6GPZtxp82N74BoIqo/1FjNtpatbHYP5iHUHsLn1Y 7ZYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+CdP+JtmU77mO5MGmmItIopubGRzTQRFLRe3LfxOQnk=; b=bjLTr55JLF1ItAYcDxPTsd17taiU4Ly1hmb7q1RcEQwJCsXienecdNqmoaouSuvrQs c4AwJBLCsf5KH9cPc5CpuRd42LGrplkOyAh3U4i3oVgdrdTBSR0+S6LOFRCb8kQmRekS 4XQY1ZEUXy2u5Cm7rF1A9H938JkVz8+sefDvgeuucp5d6n5/VKNvStSUpDvaYn6laaVU UiFRLxILWfpXgiDKlZoLPJhm2AkfJIkIOziGs2SOJMgzyhElEBpixD1MLmVqbGznGh5t B9F2jy6ZMUnZvu+5QjfAeEFeEqLWZeH726Ukv0P52Lu697sVxoy7d/gKUvKCSmJi7eQw 7y/A== X-Gm-Message-State: APzg51C89ps8ThdikNIPXPMb+yD4ErYmWMpkomh6C4P8A4RgINiknWsP EZbf/243jhxyZx+GsId0Mq9/FzWIejE= X-Google-Smtp-Source: ANB0VdbmjcBYl+99YqYllI8fuExrjNyljuWTwMZjAVM2hBfOxD/henSCYymWJv44QjWEb5R+6rU9/Q== X-Received: by 2002:a19:57c5:: with SMTP id l188-v6mr23318145lfb.109.1536111873199; Tue, 04 Sep 2018 18:44:33 -0700 (PDT) Received: from octofox.cadence.com (jcmvbkbc-1-pt.tunnel.tserv24.sto1.ipv6.he.net. [2001:470:27:1fa::2]) by smtp.gmail.com with ESMTPSA id g10-v6sm59337lfl.11.2018.09.04.18.44.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Sep 2018 18:44:32 -0700 (PDT) From: Max Filippov To: qemu-devel@nongnu.org Date: Tue, 4 Sep 2018 18:43:43 -0700 Message-Id: <20180905014352.970-7-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180905014352.970-1-jcmvbkbc@gmail.com> References: <20180905014352.970-1-jcmvbkbc@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::136 Subject: [Qemu-devel] [PATCH 06/15] target/xtensa: extract test for window underflow exception 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: Max Filippov Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP - mark retw and retw.n instructions; - extract window inderflow test from retw helper; - put underflow exception check generation right after the overflow check; Signed-off-by: Max Filippov --- target/xtensa/helper.h | 1 + target/xtensa/op_helper.c | 24 +++++++++++++++--------- target/xtensa/translate.c | 9 +++++++++ 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/target/xtensa/helper.h b/target/xtensa/helper.h index c1b3bacb4cf2..10153c245360 100644 --- a/target/xtensa/helper.h +++ b/target/xtensa/helper.h @@ -6,6 +6,7 @@ DEF_HELPER_3(debug_exception, noreturn, env, i32, i32) DEF_HELPER_2(wsr_windowbase, void, env, i32) DEF_HELPER_4(entry, void, env, i32, i32, i32) DEF_HELPER_2(test_ill_retw, void, env, i32) +DEF_HELPER_2(test_underflow_retw, void, env, i32) DEF_HELPER_2(retw, i32, env, i32) DEF_HELPER_2(rotw, void, env, i32) DEF_HELPER_3(window_check, noreturn, env, i32, i32) diff --git a/target/xtensa/op_helper.c b/target/xtensa/op_helper.c index 68052851af32..e4b42ab3e56c 100644 --- a/target/xtensa/op_helper.c +++ b/target/xtensa/op_helper.c @@ -310,19 +310,15 @@ void HELPER(test_ill_retw)(CPUXtensaState *env, uint32_t pc) } } -uint32_t HELPER(retw)(CPUXtensaState *env, uint32_t pc) +void HELPER(test_underflow_retw)(CPUXtensaState *env, uint32_t pc) { int n = (env->regs[0] >> 30) & 0x3; - uint32_t windowbase = windowbase_bound(env->sregs[WINDOW_BASE], env); - uint32_t windowstart = env->sregs[WINDOW_START]; - uint32_t ret_pc = 0; - ret_pc = (pc & 0xc0000000) | (env->regs[0] & 0x3fffffff); + if (!(env->sregs[WINDOW_START] & + windowstart_bit(env->sregs[WINDOW_BASE] - n, env))) { + uint32_t windowbase = windowbase_bound(env->sregs[WINDOW_BASE], env); - xtensa_rotate_window(env, -n); - if (windowstart & windowstart_bit(env->sregs[WINDOW_BASE], env)) { - env->sregs[WINDOW_START] &= ~windowstart_bit(windowbase, env); - } else { + xtensa_rotate_window(env, -n); /* window underflow */ env->sregs[PS] = (env->sregs[PS] & ~PS_OWB) | (windowbase << PS_OWB_SHIFT) | PS_EXCM; @@ -336,6 +332,16 @@ uint32_t HELPER(retw)(CPUXtensaState *env, uint32_t pc) HELPER(exception)(env, EXC_WINDOW_UNDERFLOW12); } } +} + +uint32_t HELPER(retw)(CPUXtensaState *env, uint32_t pc) +{ + int n = (env->regs[0] >> 30) & 0x3; + uint32_t windowbase = windowbase_bound(env->sregs[WINDOW_BASE], env); + uint32_t ret_pc = (pc & 0xc0000000) | (env->regs[0] & 0x3fffffff); + + xtensa_rotate_window(env, -n); + env->sregs[WINDOW_START] &= ~windowstart_bit(windowbase, env); return ret_pc; } diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c index de306bdfd344..deedd4c973ef 100644 --- a/target/xtensa/translate.c +++ b/target/xtensa/translate.c @@ -1071,6 +1071,13 @@ static void disas_xtensa_insn(CPUXtensaState *env, DisasContext *dc) return; } + if (op_flags & XTENSA_OP_UNDERFLOW) { + TCGv_i32 tmp = tcg_const_i32(dc->pc); + + gen_helper_test_underflow_retw(cpu_env, tmp); + tcg_temp_free(tmp); + } + for (slot = 0; slot < slots; ++slot) { XtensaOpcodeOps *ops = slot_prop[slot].ops; @@ -3485,10 +3492,12 @@ static const XtensaOpcodeOps core_ops[] = { .name = "retw", .translate = translate_retw, .test_ill = test_ill_retw, + .op_flags = XTENSA_OP_UNDERFLOW, }, { .name = "retw.n", .translate = translate_retw, .test_ill = test_ill_retw, + .op_flags = XTENSA_OP_UNDERFLOW, }, { .name = "rfdd", .op_flags = XTENSA_OP_ILL,