From patchwork Wed Sep 6 16:06:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 111831 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1154572qge; Wed, 6 Sep 2017 09:33:51 -0700 (PDT) X-Received: by 10.200.56.252 with SMTP id g57mr2936005qtc.322.1504715631017; Wed, 06 Sep 2017 09:33:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504715631; cv=none; d=google.com; s=arc-20160816; b=Inz959W2njH3dwfYjXppTgXGmHsC5ejxpxirynHGfv7dyXi6Qw/SLodm7OnnMI44kb NzdDQ9DHJudrpOG0U/cUumNRGsNcxtknVCMPpg4qHQzssoEH9Tm/j3TINSy5vyP2MyOZ bTfOkX+I1ujCD+ITt+UCxD0EzSrIBUCSFHhJ7vEJQsA5NdLmMJb/1i5hbGrE7mXRS+U2 32t0dQy9PvzS0rs4m8Nl9SVL/xyJzQwswQWAnNU7KHr1sPF+TFq8fNUkDqhh7Mgi6J35 FR7bh8sgLfRf2RWwtwjEDlvR9MtAob8axh0EQM/wVPkr4b3KGizO2sLyLXmQZ/ocPLeu o1GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=iQeSsig0LrUqKt2taUtiV4ym+Ibb3h0DSczL0zy/jlI=; b=x1qV3U0REf8Bm0RWaQfsZyYWJkpxr2Bjj19cZx0RzVYzBZHHtEf1xwLB4y+sbAyUtv jRXfy2nZKHe++3RmEnZZS3RGmA5Ki+VhgmSl6yOPD0dlPYzoY029ulPXbeQj9/GNOAoj PEhVj3hQIG1EmhzS2PZdC9BGmPNRbJCHjiEhmBz7qBN1tr1GKk0A5RO2q27f98QJkW1t /tE2XMKQLyakr/rUtCrhVvlZlmXHj9sOGrNdaVvi14lobzV+vJoUw7HDD2nWOmLgNiAv w6AChrMyBh+h3DQ1pSScALsNJqz2c5QAv8o2I59yX8Uut0nmbtOWwFcAzQqTnFkEgfBR lqkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=hETCc4cw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id i83si269738qke.83.2017.09.06.09.33.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 06 Sep 2017 09:33:51 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=hETCc4cw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37082 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpdGu-0006Cf-IO for patch@linaro.org; Wed, 06 Sep 2017 12:33:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41906) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpcqm-0000LW-Qf for qemu-devel@nongnu.org; Wed, 06 Sep 2017 12:06:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpcqi-0002cX-CW for qemu-devel@nongnu.org; Wed, 06 Sep 2017 12:06:48 -0400 Received: from mail-pf0-x234.google.com ([2607:f8b0:400e:c00::234]:34783) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dpcqi-0002bQ-6n for qemu-devel@nongnu.org; Wed, 06 Sep 2017 12:06:44 -0400 Received: by mail-pf0-x234.google.com with SMTP id m1so13485760pfk.1 for ; Wed, 06 Sep 2017 09:06:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iQeSsig0LrUqKt2taUtiV4ym+Ibb3h0DSczL0zy/jlI=; b=hETCc4cw7yVmnPV8rZJwmsDQtApG2o8yEaFLh4XeHkHvM4aL+7k/O7DjcO2POnhINF mbpua6C7x4p/g5cZtt7GQUrgN1DxwggNrUT5zlcU1uydyf2ft8Mlp1cP2HUKZLAAOzKo vSWLgphpWlApLM7yXkGQa4EfL9rJPvv1gal+4= 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:mime-version:content-transfer-encoding; bh=iQeSsig0LrUqKt2taUtiV4ym+Ibb3h0DSczL0zy/jlI=; b=d+hVqhNTckxK9OqTuUR6zv3a4ZUEmaOKO7zhAZGH+Ics/GXafaTkiIqMh1qWmcLibT iV7KkvkV+ZMjWHS+LhfGWimVO3yrKcJrMHntzdTqWu6xMlxVzuz4WUJJyYslhUMkWpVZ Rm5ylIZNapxyT5G4vcm0IFzw1U6RSBx+Lt816OnZkb5F5PmbqvMBGlLg0lHOuMNr+eXn FIWth8Le6hG1rfmeuP138DkoPIPOgp5Mp9ATBht0I1dmeDRglaUTC55hw9Ubx+ezFys+ Pgzprg7mr4kMZJH8FeWq1yYOOi5HN40bucC3RkyzA0Jfp5zsmHfHIHBDJEn9BGjP/1Kt DMEA== X-Gm-Message-State: AHPjjUgKD+O9X5UMYFNh06ipK9dtQzCzpGhNM+iG/XMFUXElMqFl2tk5 zJEXKD5w1/NFlqf13YoH2w== X-Google-Smtp-Source: ADKCNb7CnWHxlRZxLds7i6fJCeqa632A5C1gR7kMrb5beaXuP8lI7FrdGKC7lIsM1W9nNVr/6YcGFw== X-Received: by 10.99.109.142 with SMTP id i136mr8073200pgc.353.1504714003003; Wed, 06 Sep 2017 09:06:43 -0700 (PDT) Received: from bigtime.twiddle.net (97-126-108-236.tukw.qwest.net. [97.126.108.236]) by smtp.gmail.com with ESMTPSA id t65sm262863pfk.59.2017.09.06.09.06.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 06 Sep 2017 09:06:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 6 Sep 2017 09:06:01 -0700 Message-Id: <20170906160612.22769-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170906160612.22769-1-richard.henderson@linaro.org> References: <20170906160612.22769-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::234 Subject: [Qemu-devel] [PULL 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: peter.maydell@linaro.org, =?utf-8?q?Llu=C3=ADs_Vilanova?= , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.13.5 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 1eab10696c..e94198280d 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -11267,6 +11267,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) { @@ -11303,25 +11327,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)) { @@ -11392,6 +11406,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: @@ -11429,7 +11444,6 @@ void gen_intermediate_code_a64(DisasContextBase *dcbase, CPUState *cs, } } -done_generating: gen_tb_end(tb, dc->base.num_insns); #ifdef DEBUG_DISAS