From patchwork Mon Jul 24 20:27:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 9860429 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 DE1C460349 for ; Mon, 24 Jul 2017 20:48:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D15A0285C3 for ; Mon, 24 Jul 2017 20:48:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C5FB9285C9; Mon, 24 Jul 2017 20:48:17 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, 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 22C31285C3 for ; Mon, 24 Jul 2017 20:48:17 +0000 (UTC) Received: from localhost ([::1]:56906 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZkH2-0001rJ-9T for patchwork-qemu-devel@patchwork.kernel.org; Mon, 24 Jul 2017 16:48:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48011) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZjxy-0003NA-Dp for qemu-devel@nongnu.org; Mon, 24 Jul 2017 16:28:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dZjxx-0001QD-Bf for qemu-devel@nongnu.org; Mon, 24 Jul 2017 16:28:34 -0400 Received: from mail-qt0-x243.google.com ([2607:f8b0:400d:c0d::243]:38094) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dZjxx-0001PP-73 for qemu-devel@nongnu.org; Mon, 24 Jul 2017 16:28:33 -0400 Received: by mail-qt0-x243.google.com with SMTP id p3so2660442qtg.5 for ; Mon, 24 Jul 2017 13:28:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=z7357IktWnAV4Qu7VppBRGj/Bgu5Y8QnjvRfN6kvfpU=; b=R8IMh2NS4RpaOA1/ESFefH0KFSl/Jn+z/nD1uIp2HAUxSahqwXNyYAtQbtx/8yU9ob 9buPHuvThNxu9cJ+pJ85QfFWow2WI/7xyBdHgp/KvvcYYJa9X2mVCHJyoQEsdRzX38gE GNzk7bxjpYyi5MZ1HVzPpKutUx5q7y0yKtzwDw7ENUXSykV14rK+8UF+FstEMU9uQMxa yf5YBpgelxV4c4Fw01MIcNxpOcTRTlu7KPI3/4nDb/faPKSiliqSfSL5YfM+UFEQBPkY GBJf/zgpYRJHLR2K35J4GJzpnYNrq7C0NKDbtoZR8ltMtSLPqnrZaFk7iTO5GQo+WAj3 +DZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=z7357IktWnAV4Qu7VppBRGj/Bgu5Y8QnjvRfN6kvfpU=; b=sKGFVGLIp85W0mg4Gjx9Kw1dw/hXiXjBdsmZrG8COYXYjPpUlIOWP3Bm9IH6y5hbdw 1gmihCD+54iDnm+31mwZ1M1WXjeNgFpyGW41AjUf2PP4t7k4jRhJK5f+AwzWJUMDAzHP 8J3DFcK+h1PVMKO4LF+76oAH1XBq4lo+sOjxCwxR4Je9ydmj8T0StNBLv5Xm1+4KJ9WC u1vrEw7XOwIhUiVd8EkypSLMu7mVejLCNFHkuXbuWitdH4WLS1iMln+EEsawt/daUUBS wUiblwPikH6bf2DrHPCnNflrqFk8iDnvIEHLKSOuA711Rkis63L/XzMWexoqt1mHOfxn tNKQ== X-Gm-Message-State: AIVw112LHK8zCrFkFESAwmln7latzAJTKboxNT7XWZnMAe09WecHnhbu 33wDC0yFrbXcI3SAbTc= X-Received: by 10.237.35.156 with SMTP id j28mr22340464qtc.284.1500928112429; Mon, 24 Jul 2017 13:28:32 -0700 (PDT) Received: from bigtime.com ([71.217.194.233]) by smtp.gmail.com with ESMTPSA id p52sm9196808qtc.74.2017.07.24.13.28.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jul 2017 13:28:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 24 Jul 2017 13:27:17 -0700 Message-Id: <20170724202728.25960-22-rth@twiddle.net> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170724202728.25960-1-rth@twiddle.net> References: <20170724202728.25960-1-rth@twiddle.net> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::243 Subject: [Qemu-devel] [PATCH v15 21/32] target/arm: [tcg, a64] Port to breakpoint_check 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: cota@braap.org, vilanova@ac.upc.edu Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Lluís Vilanova Incrementally paves the way towards using the generic instruction translation loop. Reviewed-by: Emilio G. Cota Reviewed-by: Richard Henderson Signed-off-by: Lluís Vilanova Message-Id: <150002461630.22386.14827196109258040543.stgit@frigg.lan> [rth: Use DISAS_TOO_MANY for "execute only one more" after bp.] Signed-off-by: Richard Henderson --- target/arm/translate-a64.c | 48 ++++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 2edcfe05f3..4cb8c66b8d 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -11246,6 +11246,30 @@ static void aarch64_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu) tcg_gen_insn_start(dc->pc, 0, 0); } +static bool aarch64_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cpu, + const CPUBreakpoint *bp) +{ + DisasContext *dc = container_of(dcbase, DisasContext, base); + + if (bp->flags & BP_CPU) { + gen_a64_set_pc_im(dc->pc); + gen_helper_check_breakpoints(cpu_env); + /* End the TB early; it likely won't be executed */ + dc->base.is_jmp = DISAS_TOO_MANY; + } else { + gen_exception_internal_insn(dc, 0, EXCP_DEBUG); + /* The address covered by the breakpoint must be + included in [tb->pc, tb->pc + tb->size) in order + to for it to be properly cleared -- thus we + increment the PC here so that the logic setting + tb->size below does the right thing. */ + dc->pc += 4; + dc->base.is_jmp = DISAS_NORETURN; + } + + return true; +} + void gen_intermediate_code_a64(DisasContextBase *dcbase, CPUState *cs, TranslationBlock *tb) { @@ -11282,25 +11306,15 @@ void gen_intermediate_code_a64(DisasContextBase *dcbase, CPUState *cs, if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) { CPUBreakpoint *bp; QTAILQ_FOREACH(bp, &cs->breakpoints, entry) { - if (bp->pc == dc->pc) { - if (bp->flags & BP_CPU) { - gen_a64_set_pc_im(dc->pc); - gen_helper_check_breakpoints(cpu_env); - /* End the TB early; it likely won't be executed */ - dc->base.is_jmp = DISAS_UPDATE; - } else { - gen_exception_internal_insn(dc, 0, EXCP_DEBUG); - /* The address covered by the breakpoint must be - included in [dc->base.tb->pc, dc->base.tb->pc + dc->base.tb->size) in order - to for it to be properly cleared -- thus we - increment the PC here so that the logic setting - dc->base.tb->size below does the right thing. */ - dc->pc += 4; - goto done_generating; + if (bp->pc == dc->base.pc_next) { + if (aarch64_tr_breakpoint_check(&dc->base, cs, bp)) { + break; } - break; } } + if (dc->base.is_jmp > DISAS_TOO_MANY) { + break; + } } if (dc->base.num_insns == max_insns && (dc->base.tb->cflags & CF_LAST_IO)) { @@ -11371,6 +11385,7 @@ void gen_intermediate_code_a64(DisasContextBase *dcbase, CPUState *cs, } else { switch (dc->base.is_jmp) { case DISAS_NEXT: + case DISAS_TOO_MANY: gen_goto_tb(dc, 1, dc->pc); break; case DISAS_JUMP: @@ -11408,7 +11423,6 @@ void gen_intermediate_code_a64(DisasContextBase *dcbase, CPUState *cs, } } -done_generating: gen_tb_end(tb, dc->base.num_insns); #ifdef DEBUG_DISAS