From patchwork Thu Oct 13 06:29:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: LIU Zhiwei X-Patchwork-Id: 1689373 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Mp08r3Q69z23jn for ; Thu, 13 Oct 2022 17:33:46 +1100 (AEDT) Received: from localhost ([::1]:53124 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oirmo-0000Dq-JL for incoming@patchwork.ozlabs.org; Thu, 13 Oct 2022 02:33:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36776) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oirjQ-0000DU-Fp; Thu, 13 Oct 2022 02:30:12 -0400 Received: from out30-130.freemail.mail.aliyun.com ([115.124.30.130]:52497) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oirjH-00033T-Dg; Thu, 13 Oct 2022 02:30:05 -0400 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R321e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018045192; MF=zhiwei_liu@linux.alibaba.com; NM=1; PH=DS; RN=11; SR=0; TI=SMTPD_---0VS2PtCj_1665642589; Received: from roman-VirtualBox.hz.ali.com(mailfrom:zhiwei_liu@linux.alibaba.com fp:SMTPD_---0VS2PtCj_1665642589) by smtp.aliyun-inc.com; Thu, 13 Oct 2022 14:29:50 +0800 From: LIU Zhiwei To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: Alistair.Francis@wdc.com, palmer@dabbelt.com, bin.meng@windriver.com, sergey.matyukevich@syntacore.com, vladimir.isaev@syntacore.com, anatoly.parshintsev@syntacore.com, philipp.tomsich@vrull.eu, zhiwei_liu@c-sky.com, LIU Zhiwei Subject: [PATCH v1 0/4] Support native debug icount trigger Date: Thu, 13 Oct 2022 14:29:42 +0800 Message-Id: <20221013062946.7530-1-zhiwei_liu@linux.alibaba.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Received-SPF: pass client-ip=115.124.30.130; envelope-from=zhiwei_liu@linux.alibaba.com; helo=out30-130.freemail.mail.aliyun.com X-Spam_score_int: -98 X-Spam_score: -9.9 X-Spam_bar: --------- X-Spam_report: (-9.9 / 5.0 requ) BAYES_00=-1.9, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_SPF_WL=-7.5 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" icount trigger set an instruction count. After one instruction retired, the count will be decreased by 1. If the count decreased to 0, the icount trigger will fire. icount trigger is needed by single step ptrace system call and the native GDB. In this patch set, change the translation when icount trigger enabled in the way that instruction executes one by one. After executing one instruction, call a helper function to decrease the count for itrigger. It also provides an accelebrated way. If QEMU executes with -icount parameter, itrigger is simulated by a timer with the count in itrigger as the deadline. Note the count in itrigger will only decrease when the priviledge matches, which is also processed in this patch set. After merging this patch set, QEMU will support type2/type6 trigger(needed by breakpoint and watchpoint) and icount trigger(needed by single step), which is enough for a PoC of native debug. LIU Zhiwei (4): target/riscv: Add itrigger support when icount is not enabled target/riscv: Add itrigger support when icount is enabled target/riscv: Enable native debug itrigger target/riscv: Add itrigger_enabled field to CPURISCVState target/riscv/cpu.h | 5 + target/riscv/cpu_helper.c | 8 + target/riscv/debug.c | 205 ++++++++++++++++++ target/riscv/debug.h | 13 ++ target/riscv/helper.h | 2 + .../riscv/insn_trans/trans_privileged.c.inc | 4 +- target/riscv/insn_trans/trans_rvi.c.inc | 8 +- target/riscv/insn_trans/trans_rvv.c.inc | 4 +- target/riscv/machine.c | 15 ++ target/riscv/translate.c | 33 ++- 10 files changed, 286 insertions(+), 11 deletions(-)