From patchwork Mon Jul 24 20:27:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 9860377 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 4752E60385 for ; Mon, 24 Jul 2017 20:32:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 39FB928538 for ; Mon, 24 Jul 2017 20:32:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2EEDB285A3; Mon, 24 Jul 2017 20:32:28 +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 C557B28538 for ; Mon, 24 Jul 2017 20:32:27 +0000 (UTC) Received: from localhost ([::1]:56836 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZk1i-0005WE-Vg for patchwork-qemu-devel@patchwork.kernel.org; Mon, 24 Jul 2017 16:32:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47877) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZjxh-00035x-Mw for qemu-devel@nongnu.org; Mon, 24 Jul 2017 16:28:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dZjxg-0000ws-In for qemu-devel@nongnu.org; Mon, 24 Jul 2017 16:28:17 -0400 Received: from mail-qt0-x244.google.com ([2607:f8b0:400d:c0d::244]:38075) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dZjxg-0000wX-E1 for qemu-devel@nongnu.org; Mon, 24 Jul 2017 16:28:16 -0400 Received: by mail-qt0-x244.google.com with SMTP id p3so2659767qtg.5 for ; Mon, 24 Jul 2017 13:28:16 -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=pxow/ZoGMOCKQCnQLTWk3nVwB5Q0HyJxs30356/F6VU=; b=WxhDHr5r68GpxosV34YqEqwJlHQ6TXf2E3Q9SSYhFCQX0OpF6UWHABNmXC9AFRIIxP f8RS2QHXoRwIymQwRPXcaYGuCqu/Bbydkht8RxzYpvpgz3MR80C24vhq8Ynxmswin/wq qFGw03bgcqM2bpG/NNCPH0zKXoH7NznwvfxMjfDdtAkY+XGMAHygk3EVsBAv6nUNMzW7 DgL5/3R8b+sp2qiELwb6VEaJT7wqBvJYROMm4dHfS1KjqO21PpbdfyiwqoK+ESHmmIE+ ADZR7vMId1eFYLK1vfcEB3LttdM3l+kx5lrSklQPmQa7zxV7ILX+AFuC/7/IycxU9rTm scpQ== 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=pxow/ZoGMOCKQCnQLTWk3nVwB5Q0HyJxs30356/F6VU=; b=bi7EcTPXSmGFvzIbQaAsLhIqmwdGRTh8RQWDiGFBGy4Fob8siACjfktovk3xsoDECC WEf3i/Pco4XXST2gBzDGz+IBOfa0paRPkvD1L5YMZp9d1AxJxgWBI8NU9QTRcDaJLjQE V+I0AYSczXFtLO7UDQIPDdvff7gIBVJ8PBIm89aM4Ckn9Hdj02CU+jqjjXyy6KYrsOXO MeITVupv75xXu4a35mrdIWidSE9cy1G5X9pJktVqCvLI1/jchpfwvlNryMMnpy+biPSV nscRAtNjvI8tm83nuLYcqSky5QU4p1WqSKFx1hbDdR7HpIHCX/yurtFVc7dSdYpjyswd fBrg== X-Gm-Message-State: AIVw113Zssp3g6C8jIs5yIHl2LEwBQBa9IH1PoDBa8db2A4md0sjDPn+ gzYQkYKxvhgyshxBiUM= X-Received: by 10.200.45.236 with SMTP id q41mr22153304qta.177.1500928095542; Mon, 24 Jul 2017 13:28:15 -0700 (PDT) Received: from bigtime.com ([71.217.194.233]) by smtp.gmail.com with ESMTPSA id p52sm9196808qtc.74.2017.07.24.13.28.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jul 2017 13:28:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 24 Jul 2017 13:27:06 -0700 Message-Id: <20170724202728.25960-11-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::244 Subject: [Qemu-devel] [PATCH v15 10/32] target/i386: [tcg] 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. Signed-off-by: Lluís Vilanova Reviewed-by: Richard Henderson Reviewed-by: Emilio G. Cota Message-Id: <150002170871.22386.2172835658104140576.stgit@frigg.lan> Signed-off-by: Richard Henderson --- target/i386/translate.c | 46 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/target/i386/translate.c b/target/i386/translate.c index 6e1243a5b4..a009710128 100644 --- a/target/i386/translate.c +++ b/target/i386/translate.c @@ -8455,6 +8455,26 @@ static void i386_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu) tcg_gen_insn_start(dc->base.pc_next, dc->cc_op); } +static bool i386_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cpu, + const CPUBreakpoint *bp) +{ + DisasContext *dc = container_of(dcbase, DisasContext, base); + /* If RF is set, suppress an internally generated breakpoint. */ + int flags = dc->base.tb->flags & HF_RF_MASK ? BP_GDB : BP_ANY; + if (bp->flags & flags) { + gen_debug(dc, dc->base.pc_next - dc->cs_base); + dc->base.is_jmp = DISAS_NORETURN; + /* 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->base.pc_next += 1; + return true; + } else { + return false; + } +} + /* generate intermediate code for basic block 'tb'. */ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) { @@ -8485,18 +8505,21 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) i386_tr_insn_start(&dc->base, cs); num_insns++; - /* If RF is set, suppress an internally generated breakpoint. */ - if (unlikely(cpu_breakpoint_test(cs, dc->base.pc_next, - tb->flags & HF_RF_MASK - ? BP_GDB : BP_ANY))) { - gen_debug(dc, dc->base.pc_next - dc->cs_base); - /* 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->base.pc_next += 1; - goto done_generating; + if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) { + CPUBreakpoint *bp; + QTAILQ_FOREACH(bp, &cs->breakpoints, entry) { + if (bp->pc == dc->base.pc_next) { + if (i386_tr_breakpoint_check(&dc->base, cs, bp)) { + break; + } + } + } + + if (dc->base.is_jmp == DISAS_NORETURN) { + break; + } } + if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) { gen_io_start(); } @@ -8547,7 +8570,6 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) } if (tb->cflags & CF_LAST_IO) gen_io_end(); -done_generating: gen_tb_end(tb, num_insns); #ifdef DEBUG_DISAS