From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 46C63C38142 for ; Fri, 27 Jan 2023 12:51:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=TKDuf9E9dGkVEGjSg5EkdZ03iGr//8dsTYNEDu0EoqA=; b=OGdwvUmWKDmKs7 M/JHsYf52vuzpNRhDORbU5ZqaqA2NihLGUCCszhPWFuireKKByKaTBn1ljfm6/AXOBxMPpd/qcZsz 1ZmUBpPhgCpDjt+SlGNrDqWmE7pB4dDrQ1bXvHTTqWg6RgpfzSy8CEvgmgQc4e4tsqzn1a2gXiwcb gpurvCHiVtKr9jratRKjIkIekpRIXREVHzNv0dUl1kNHwbKXMP+91ufqA2k+C8bexlOVOCqF7FWfg JtjMzmGbJwxHKhi1fvJFcGdUV6EiGk/yEFoSPxwL+XjTX4QR1Nir+fCecuPGhokbWK5g0OjEDOTaE j0TF9Vrb3IAQYxyoOfeQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLOAo-00Ei4F-J9; Fri, 27 Jan 2023 12:49:45 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNFo-00EHgt-Cy for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:50:50 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id ADC04B820BD; Fri, 27 Jan 2023 11:50:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82CC0C433EF; Fri, 27 Jan 2023 11:50:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674820245; bh=yg7LVjF/Sxi7pRws/+ezLgbUiexQuVEylBV9Ln2+OZk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fIsy9043QSVE0+qZwwPJD86MLjYhe5Vl7AcvAzBQ7tCcVq3TxiJo2HUMywupE3z59 H1iTpcLQIDEDFGmXNkmfMrnlbCzmiNQLLmYeZvtHBkxpxLeBy88FzMv57J8P7Od0wt XovcKlayuFatPnOVBVgcWSZHD6DxFcpwLupGojlCdx2qg5lsvYt6wh/08nYYTMZpLO Cl9P0pAr8x+JOdHdu0cxbbU8VOXTInmxp7N9fkXoWHh6Yr4N3/V+OCA/E4pKk3Qy9Z QKsa9pTT0pJbOIrtpPi24mk3HW3Rc5KHK4sLcoZ0A4sLzaBBk0rcmQTQ5QolgtdeN4 nQp+VmQkV8r5w== Date: Fri, 27 Jan 2023 11:50:39 +0000 From: Will Deacon To: Sumit Garg Cc: catalin.marinas@arm.com, mark.rutland@arm.com, daniel.thompson@linaro.org, dianders@chromium.org, liwei391@huawei.com, mhiramat@kernel.org, maz@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 2/2] arm64: kgdb: Set PSTATE.SS to 1 to re-enable single-step Message-ID: <20230127115039.GA30505@willie-the-truck> References: <20221219102452.2860088-1-sumit.garg@linaro.org> <20221219102452.2860088-3-sumit.garg@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221219102452.2860088-3-sumit.garg@linaro.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_035048_846174_A7AF1A68 X-CRM114-Status: GOOD ( 23.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Dec 19, 2022 at 03:54:52PM +0530, Sumit Garg wrote: > Currently only the first attempt to single-step has any effect. After > that all further stepping remains "stuck" at the same program counter > value. > > Refer to the ARM Architecture Reference Manual (ARM DDI 0487E.a) D2.12, > PSTATE.SS=1 should be set at each step before transferring the PE to the > 'Active-not-pending' state. The problem here is PSTATE.SS=1 is not set > since the second single-step. > > After the first single-step, the PE transferes to the 'Inactive' state, > with PSTATE.SS=0 and MDSCR.SS=1, thus PSTATE.SS won't be set to 1 due to > kernel_active_single_step()=true. Then the PE transferes to the > 'Active-pending' state when ERET and returns to the debugger by step > exception. > > Before this patch: > ================== > Entering kdb (current=0xffff3376039f0000, pid 1) on processor 0 due to Keyboard Entry > [0]kdb> > > [0]kdb> > [0]kdb> bp write_sysrq_trigger > Instruction(i) BP #0 at 0xffffa45c13d09290 (write_sysrq_trigger) > is enabled addr at ffffa45c13d09290, hardtype=0 installed=0 > > [0]kdb> go > $ echo h > /proc/sysrq-trigger > > Entering kdb (current=0xffff4f7e453f8000, pid 175) on processor 1 due to Breakpoint @ 0xffffad651a309290 > [1]kdb> ss > > Entering kdb (current=0xffff4f7e453f8000, pid 175) on processor 1 due to SS trap @ 0xffffad651a309294 > [1]kdb> ss > > Entering kdb (current=0xffff4f7e453f8000, pid 175) on processor 1 due to SS trap @ 0xffffad651a309294 > [1]kdb> > > After this patch: > ================= > Entering kdb (current=0xffff6851c39f0000, pid 1) on processor 0 due to Keyboard Entry > [0]kdb> bp write_sysrq_trigger > Instruction(i) BP #0 at 0xffffc02d2dd09290 (write_sysrq_trigger) > is enabled addr at ffffc02d2dd09290, hardtype=0 installed=0 > > [0]kdb> go > $ echo h > /proc/sysrq-trigger > > Entering kdb (current=0xffff6851c53c1840, pid 174) on processor 1 due to Breakpoint @ 0xffffc02d2dd09290 > [1]kdb> ss > > Entering kdb (current=0xffff6851c53c1840, pid 174) on processor 1 due to SS trap @ 0xffffc02d2dd09294 > [1]kdb> ss > > Entering kdb (current=0xffff6851c53c1840, pid 174) on processor 1 due to SS trap @ 0xffffc02d2dd09298 > [1]kdb> ss > > Entering kdb (current=0xffff6851c53c1840, pid 174) on processor 1 due to SS trap @ 0xffffc02d2dd0929c > [1]kdb> > > Fixes: 44679a4f142b ("arm64: KGDB: Add step debugging support") > Co-developed-by: Wei Li > Signed-off-by: Wei Li > Signed-off-by: Sumit Garg > Tested-by: Douglas Anderson > --- > arch/arm64/include/asm/debug-monitors.h | 1 + > arch/arm64/kernel/debug-monitors.c | 5 +++++ > arch/arm64/kernel/kgdb.c | 2 ++ > 3 files changed, 8 insertions(+) > > diff --git a/arch/arm64/include/asm/debug-monitors.h b/arch/arm64/include/asm/debug-monitors.h > index 7b7e05c02691..ce3875ad5cd3 100644 > --- a/arch/arm64/include/asm/debug-monitors.h > +++ b/arch/arm64/include/asm/debug-monitors.h > @@ -104,6 +104,7 @@ void user_regs_reset_single_step(struct user_pt_regs *regs, > void kernel_enable_single_step(struct pt_regs *regs); > void kernel_disable_single_step(void); > int kernel_active_single_step(void); > +void kernel_regs_reset_single_step(struct pt_regs *regs); > > #ifdef CONFIG_HAVE_HW_BREAKPOINT > int reinstall_suspended_bps(struct pt_regs *regs); > diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c > index 3da09778267e..9af898b22ed4 100644 > --- a/arch/arm64/kernel/debug-monitors.c > +++ b/arch/arm64/kernel/debug-monitors.c > @@ -438,6 +438,11 @@ int kernel_active_single_step(void) > } > NOKPROBE_SYMBOL(kernel_active_single_step); > > +void kernel_regs_reset_single_step(struct pt_regs *regs) > +{ > + set_regs_spsr_ss(regs); > +} Just a nit on the naming here, but please can this be kernel_rewind_single_step() instead? I think it's closer to the rewind function we have for user tasks than the reset function. Cheers, Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel