Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4866810iob; Mon, 9 May 2022 03:34:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxusSadCCYpkGJdh5Nbe+cVjEpaZHUzvzDoY/ezo/7udA3rKqKqVvcXmyHX8yHTP28UZ0BJ X-Received: by 2002:a05:6a00:1a08:b0:510:979e:f5b with SMTP id g8-20020a056a001a0800b00510979e0f5bmr8735465pfv.34.1652092491719; Mon, 09 May 2022 03:34:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652092491; cv=none; d=google.com; s=arc-20160816; b=Dr/7DrLBhMFTloMVeDDlxVUaqy73Ms7F2XYbDmdk55TQ/5saZqyp5HYOBGbD+iEPdI 2hrMRnYVvXgiZNNhzj0a9OAfRFaDvG3nwqcyYQte6y7RSiJEz/QmH3n5QFW526pyGf07 yuPgIxBOun/BWHgvXUMPC6/X8//tlX94NTXkl6OOxiH/X5mRM1IyQoNqEkicjihxxzK5 pOJRrWuUTLH0MTQHKjDuTgUtvMBMc9M9AEhc4sEWhfvqJdKJpwwdowbaayhDtDdbnOlC ih4KThrHDpNxU9PE0p+EtsyTpseb9m8UNkgGoclusOxMvxN1MYqr6By0hoJaNgAgv0jT N2jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=o3f/qnVS2WcXj7iwOwyZu0+V2UDXqQKKLdu50e65PWk=; b=Ce6zz1cOs8hIJgAp6jl88gKHkTLSiDkqjBRaeSFOkukvzcb1JR6HdpjGi+/s+FJIiG C5DWTNkzQmkkXL6BqmOc6J9rCW/PHkVw1zUE3KNnUkHTBB7gWZSvmnNAT/WoDV4Ceaxk DRbEPg2nwnNk8dr0VDa5hBa9BdOjKLypz0tFE1Mjzgr4/Zq7I0/UqZHJYeb9rBoiuxlv KzV5Xtp67vlKyMhQdT72mG9eiVcYPVNwfmM5sXtGkVphcmn8LyVRZeZM3ty+7bLzYKff HI5Ugl2cHrkKBgy1/NLQ/5aPUDRKjXU0o3cwkQhyxd+WYxARMWxaaL+wES8IxQqyh1Vw /IWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IPsL8eNX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id il14-20020a17090b164e00b001d170dc834asi16222430pjb.62.2022.05.09.03.34.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 03:34:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IPsL8eNX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E0C26263DA1; Mon, 9 May 2022 03:05:07 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233256AbiEIINz (ORCPT + 99 others); Mon, 9 May 2022 04:13:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237710AbiEIIB7 (ORCPT ); Mon, 9 May 2022 04:01:59 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4807E195BF1 for ; Mon, 9 May 2022 00:58:03 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id a15-20020a17090ad80f00b001dc2e23ad84so16296991pjv.4 for ; Mon, 09 May 2022 00:58:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=o3f/qnVS2WcXj7iwOwyZu0+V2UDXqQKKLdu50e65PWk=; b=IPsL8eNXADYfgkb1P5Z6nd5wrXDTkdIpPH8ibsl6bxuq/UPgZ4bu/a1MHv/o+EXBvz gaW5r9C9DYOpxC9FkcE36xE4Ia1yssvWI10MjHbg7xC/RiniUQBK7GZhP3ZMTDb6m8N/ ygVnqKxoGfaanRn2uuKm3A1t28JiiWaKFaQW7v8HDeouvGa84CiZ8Me3VsGn0IF8Tuzz C6A3gPbcCrX94xMzTfgzEpXNUzcVUUODbKHD5YNkzQivBjhepHHa8QNcUbTJmG/vJTJd o3iWn6vP/tSqUwilqHsLJsVE4vam9IkLmcMBZSjTVVy5xBV2XZdHTTXEVlTFZL0hui1K 1kBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=o3f/qnVS2WcXj7iwOwyZu0+V2UDXqQKKLdu50e65PWk=; b=kpCBJ1N/+sOabkmWdQEDjYxeXjL7AyUWfMosFBMb6zb0wDnKe6kNutRXjNlMfFLvhZ JdSGYtkeMYsxQYw67XF+NA1ILtXSNLs3uDdnTKL3l5ZVda34uzuNh/HtH47XIDsOlelv ZlRKgaUURcjtX2kFXKARtbzGb5LNW8+DcnzFwQ8LjM9UvqYCLLH9t5iUCJTINfwgYgMP bXh65VBjhIN9DDefRYJu1mPzwBe+TZhMrcmmpQtP06uAAXocgk5Zc1zvEixZdBEdxh4J 9ohYDc70bH3NvmHvIYOYBJ7lAZOCzXDNZgPjuskD9nkXMt7P4WCxE1Du3LcpYQsPrvKN YS9w== X-Gm-Message-State: AOAM53111iLPEAMqzF0Tj6ypfUZ6uapKORa1Ow8vWW/FibWegtrjBO2H OIvIHrrf0PpMXEEZ//stQtnMrSAUB6/p2ATXd2EyIw== X-Received: by 2002:a17:90b:1a86:b0:1dc:eae9:9b5b with SMTP id ng6-20020a17090b1a8600b001dceae99b5bmr12472341pjb.100.1652083002113; Mon, 09 May 2022 00:56:42 -0700 (PDT) MIME-Version: 1.0 References: <20220413065458.88541-1-sumit.garg@linaro.org> <20220413065458.88541-3-sumit.garg@linaro.org> <20220506161258.p5jztdy33hlua3bu@maple.lan> In-Reply-To: <20220506161258.p5jztdy33hlua3bu@maple.lan> From: Sumit Garg Date: Mon, 9 May 2022 13:26:30 +0530 Message-ID: Subject: Re: [PATCH v2 2/2] arm64: kgdb: Set PSTATE.SS to 1 to re-enable single-step To: Daniel Thompson Cc: linux-arm-kernel@lists.infradead.org, dianders@chromium.org, will@kernel.org, liwei391@huawei.com, catalin.marinas@arm.com, mark.rutland@arm.com, mhiramat@kernel.org, jason.wessel@windriver.com, maz@kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 6 May 2022 at 21:43, Daniel Thompson wrote: > > On Wed, Apr 13, 2022 at 12:24:58PM +0530, Sumit Garg wrote: > > After fixing wrongly single-stepping into the irq handler, when we execute > > single-step in kdb/kgdb, we can see only the first step can work. > > I might be nitpicking since, again, I've no problems with the code > but... I'd rather this patch description focused on what this patch > does rather than what the patch before it does! > > Something more like: > > Currently only the first attempt to single-step has any effect. > After that all further stepping remains "stuck" at the same program > counter value. > Ack, I will use this instead. -Sumit > > Daniel. > > > > > > Refer to the ARM Architecture Reference Manual (ARM DDI 0487E.a) D2.12, > > i think PSTATE.SS=1 should be set each step for 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 > > --- > > 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 00c291067e57..9e1e864d6440 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 4f3661eeb7ec..ea3f410aa385 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); > > +} > > + > > /* ptrace API */ > > void user_enable_single_step(struct task_struct *task) > > { > > diff --git a/arch/arm64/kernel/kgdb.c b/arch/arm64/kernel/kgdb.c > > index 2aede780fb80..acf2196b1e9b 100644 > > --- a/arch/arm64/kernel/kgdb.c > > +++ b/arch/arm64/kernel/kgdb.c > > @@ -224,6 +224,8 @@ int kgdb_arch_handle_exception(int exception_vector, int signo, > > */ > > if (!kernel_active_single_step()) > > kernel_enable_single_step(linux_regs); > > + else > > + kernel_regs_reset_single_step(linux_regs); > > err = 0; > > break; > > default: > > -- > > 2.25.1