From patchwork Wed Sep 5 01:43:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 10588157 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 46B8213BB for ; Wed, 5 Sep 2018 01:46:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3921929CE6 for ; Wed, 5 Sep 2018 01:46:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D0A029D92; Wed, 5 Sep 2018 01:46:11 +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 CC00C29CE6 for ; Wed, 5 Sep 2018 01:46:10 +0000 (UTC) Received: from localhost ([::1]:53384 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fxMtW-00079m-4Y for patchwork-qemu-devel@patchwork.kernel.org; Tue, 04 Sep 2018 21:46:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57789) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fxMrx-0005uI-PF for qemu-devel@nongnu.org; Tue, 04 Sep 2018 21:44:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fxMrv-0006jv-T4 for qemu-devel@nongnu.org; Tue, 04 Sep 2018 21:44:33 -0400 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]:40294) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fxMru-0006gE-Q1 for qemu-devel@nongnu.org; Tue, 04 Sep 2018 21:44:31 -0400 Received: by mail-lf1-x12e.google.com with SMTP id x26-v6so4575915lfi.7 for ; Tue, 04 Sep 2018 18:44:29 -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=WbuiwURD1XdRYx69ckMkOGwbTDhBwY/RgI9CjIJlI+o=; b=GE398+xnq8yTM2yyQ2OpK2CqQsYspdMMsKFQwrVWLl7JMcmtbADTPzi8+M4AiCq/84 YuNYqNhlAATuw26zpUmG+MHLuxUQ92zgoq6lJ/YAM5W9l6zNyS1qcRHT/VZ2EcVcA3BZ xUW29J7hT+5PhLP/pGQrBU6JMEPu28w68hfJSxwuXbr1CcgpEOLTYCflbrQZPnZtLZt/ IzR2ejiaodFa0XipZ7mjE7BibPMQ/74oKhXegm/PkJofyEnltI5mLURuzM5sisHB4CPA 8kVyR1Z/T+ZKV15wYuViOdUj66gSc8rDoD16ptLhJhWAqhk49UGfO1hO3EjvQ+4mKebY ylEw== 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=WbuiwURD1XdRYx69ckMkOGwbTDhBwY/RgI9CjIJlI+o=; b=nusAHv/T5pVh8zLK2br81X7SCB5mNgzlaHT+XHZz4VzQTxIuSieuXXpczhI+5vmS8A agZZUk/IdiGe3q1zdiGT6R0lsTAvGFT50NhXHcPHLqoOxFPWe9SyJ8631f69OBklST10 LDiLrQfqVRtEO/zUXrlmkDT4LJrQI840fwzWEckPmGT7K7drOFhU2ASpRfa0tVT2IL1i qxDrp3Yn4sHnJDMaVNfTEgpbcnrOCxhm8SlvFZG8lt/MtyAoalcNnSalgdAiCtrhO29E x2c4LYR09xS0CpYAF3Ufm0+xI1fsp4d9nUk9XclJ/GzY3+TcqImsOvnotZSrA6B5j0em Qefg== X-Gm-Message-State: APzg51DCtSy2wXpPSxqeILfw1qrZiuSlMKynfwadienYTmYOFX5B23hD 5niNLjfd+hJOMlJEDfjvIUvQeDJUzxI= X-Google-Smtp-Source: ANB0VdbDuU7VheSc/+lZOEf53+WPXApWF2GDQTXn+ITYSeCLG0MQAjls7qYzUySuag87p2LEI5LfHA== X-Received: by 2002:a19:8c8:: with SMTP id 191-v6mr4420864lfi.152.1536111867728; Tue, 04 Sep 2018 18:44:27 -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.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Sep 2018 18:44:27 -0700 (PDT) From: Max Filippov To: qemu-devel@nongnu.org Date: Tue, 4 Sep 2018 18:43:41 -0700 Message-Id: <20180905014352.970-5-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::12e Subject: [Qemu-devel] [PATCH 04/15] target/xtensa: extract test for debug 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 break and break.n instructions; - collect debug cause bits from parameter 0 of instructions marked for debug exception; - put debug exception check right after syscall check; Signed-off-by: Max Filippov --- target/xtensa/translate.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c index 450e30d316a8..5222c952a1b7 100644 --- a/target/xtensa/translate.c +++ b/target/xtensa/translate.c @@ -959,6 +959,7 @@ static void disas_xtensa_insn(CPUXtensaState *env, DisasContext *dc) uint32_t arg[MAX_OPCODE_ARGS]; uint32_t raw_arg[MAX_OPCODE_ARGS]; } slot_prop[MAX_INSN_SLOTS]; + uint32_t debug_cause = 0; if (len == XTENSA_UNDEFINED) { qemu_log_mask(LOG_GUEST_ERROR, @@ -1040,6 +1041,9 @@ static void disas_xtensa_insn(CPUXtensaState *env, DisasContext *dc) gen_exception_cause(dc, ILLEGAL_INSTRUCTION_CAUSE); return; } + if (ops->op_flags & XTENSA_OP_DEBUG_BREAK) { + debug_cause |= ops->par[0]; + } } if ((op_flags & XTENSA_OP_PRIVILEGED) && @@ -1052,6 +1056,11 @@ static void disas_xtensa_insn(CPUXtensaState *env, DisasContext *dc) return; } + if ((op_flags & XTENSA_OP_DEBUG_BREAK) && dc->debug) { + gen_debug_exception(dc, debug_cause); + return; + } + for (slot = 0; slot < slots; ++slot) { XtensaOpcodeOps *ops = slot_prop[slot].ops; @@ -1515,14 +1524,6 @@ static void translate_bp(DisasContext *dc, const uint32_t arg[], tcg_temp_free(tmp); } -static void translate_break(DisasContext *dc, const uint32_t arg[], - const uint32_t par[]) -{ - if (dc->debug) { - gen_debug_exception(dc, par[0]); - } -} - static void translate_call0(DisasContext *dc, const uint32_t arg[], const uint32_t par[]) { @@ -2827,12 +2828,14 @@ static const XtensaOpcodeOps core_ops[] = { .par = (const uint32_t[]){TCG_COND_EQ}, }, { .name = "break", - .translate = translate_break, + .translate = translate_nop, .par = (const uint32_t[]){DEBUGCAUSE_BI}, + .op_flags = XTENSA_OP_DEBUG_BREAK, }, { .name = "break.n", - .translate = translate_break, + .translate = translate_nop, .par = (const uint32_t[]){DEBUGCAUSE_BN}, + .op_flags = XTENSA_OP_DEBUG_BREAK, }, { .name = "bt", .translate = translate_bp,