From patchwork Thu Dec 15 14:29:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 33659 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp395521wrn; Thu, 15 Dec 2022 06:38:10 -0800 (PST) X-Google-Smtp-Source: AA0mqf6tnqQgNdp8yep5FdcDxBbOWr1cOgQEQfxxE/7mm1pGjCgFEZYnBDNjuhDoAuN9qs/RoWNc X-Received: by 2002:a17:906:7116:b0:7c1:8450:f963 with SMTP id x22-20020a170906711600b007c18450f963mr15089345ejj.34.1671115090419; Thu, 15 Dec 2022 06:38:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671115090; cv=none; d=google.com; s=arc-20160816; b=AG7o7w0tYyR5a9nCmdKtI33hb1QMl8r9g3uqw9d+BGvAgmXSoA5R/UzkvwgL2u3mkV 9tAh+Y0gcGB65JGZXvYI0Zpu7q/J4oC3TYZGyWmQB2PmLMdCwtLCvdF5TK6Hs/Pw2FOl Eu0h/jgNIJ5ZeWUbo1FOFq5plds8L4RHyKq9wIp71NSnHpAjwoLpXyi5tNVy50ey09eW NLw63EKoxmOXmBb4NfZBhbnu2v1gleB7I3Jb0iEjBDHye9pekjg639dM9wQkwu3ug1Zj YMHppYOP1e58I7xlgoQxUAavZj20IBC6EyyGg6ecpt+RrY+Hmv1PGmlGgsOVQwTflBG6 D2dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=01a2UV5FsPpOUVUYf2R+k+b8Dh0cH0M3wFlrMUvhruw=; b=NPLCtDkfJ1vGcSBoeofs5BdSkMG1RihMt8fmKIq6zucaTo6mvHoQnT13LppC3tKVll CVpb7iFsAuEQGfg0MQYoGw97FbCSt17m6MgcvqQTqK5+2t7BzY3YZnLFh88O7UD8qrr8 f7JZevz8ZEoKxfU0Emvi55c6zkJrY6ghic8VUwUgpXI3adfWSMZz83hjU/8jphMrBBnS OGiYVm/jVWEIx1azMT4JS1mW15BfTX2qDZuszF+khhWlGYrwcGoBYw0F9hPEMeg6LRvK ThUuLo1qtxx65pHyFj+Y1/FnA1ScR4ZC7t+POntEvPsozRGQoIgBGlPwsj6YME5fG+kF 6ubA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HqUCLpNQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ww2-20020a170907084200b007ae1874c142si14244100ejb.446.2022.12.15.06.37.46; Thu, 15 Dec 2022 06:38:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HqUCLpNQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229898AbiLOO3Z (ORCPT + 99 others); Thu, 15 Dec 2022 09:29:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229844AbiLOO3Y (ORCPT ); Thu, 15 Dec 2022 09:29:24 -0500 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C05F125F2 for ; Thu, 15 Dec 2022 06:29:22 -0800 (PST) Received: by mail-pj1-x1036.google.com with SMTP id 3-20020a17090a098300b00219041dcbe9so2833852pjo.3 for ; Thu, 15 Dec 2022 06:29:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=01a2UV5FsPpOUVUYf2R+k+b8Dh0cH0M3wFlrMUvhruw=; b=HqUCLpNQ4nZIY3dP3D3DeWny5wH83I40YR+GanSSNBRAdmWYA6Auprhi94xLnHVRVn IpyiPDX0w3v1al7y1sa3Wl12jQl2T4deTeZWF94P/3ojQhTfuyjRlLOD6I5/NLpJL0H2 6kwyB3Gvovd8EqEfdJUknFfERUe7t3NtWFLEI+n5NielFJjfpoBn61HfitkLaV/p6dqK vDEd278TQv9u+wqxp3VNp5eUXKlaOHvqnQE31XHxNBSzTyygOlB11vjuTTUdLvIW7Pjv PgTXb7djiM10JmiwNbgmgCzjFDtmr/4MY96LJ5HY3t9EG7Cs5ht4Gm3gQFjr7L3dFbGx UItw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=01a2UV5FsPpOUVUYf2R+k+b8Dh0cH0M3wFlrMUvhruw=; b=0lLbJd3OzvMZT4bC0AjDSothwgwRVb0DKcD+EwusnOlFiPdlRN4ey5UltUAhsPRBV8 2Uq3iy5YNQ5nEH7gryErt7Sg63g7Jzm85QaSdgR6NccTxsIK+dRZtQDn9D2wEu4nrF2Y rJBwb8zfbTpRzZ0JAr5pD6EqFvTIvJoml/+we5f16azhD4h+303SeyOxrka70Lq3PoRm HWM4pQyLPsPbWyXT+V+/um+gwD5CCIxEZ/ljL5OWyPVdlMGynwKjU50S4jR5zDJ8fj9c NYLwfoySXy9j1JSWYUB3h0C8/pEF8iSeCttF6crWi4qCLuyoNCUFiqxr1q5+NZ2fwjP6 Tu+g== X-Gm-Message-State: ANoB5pnTLbh2YmL7KjoPlXizZjwFW0Y4aV/0jMD2FGENE4aNDuOUmyL1 DC7dPvADKQvOPRpZEeEX0QjR3w== X-Received: by 2002:a17:902:cf12:b0:186:a5a7:cc4e with SMTP id i18-20020a170902cf1200b00186a5a7cc4emr33472597plg.17.1671114562277; Thu, 15 Dec 2022 06:29:22 -0800 (PST) Received: from sumit-X1.. ([223.178.208.45]) by smtp.gmail.com with ESMTPSA id z1-20020a170902d54100b0017f5ad327casm3922010plf.103.2022.12.15.06.29.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Dec 2022 06:29:22 -0800 (PST) From: Sumit Garg To: will@kernel.org, catalin.marinas@arm.com, daniel.thompson@linaro.org, dianders@chromium.org Cc: liwei391@huawei.com, mark.rutland@arm.com, mhiramat@kernel.org, maz@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sumit Garg Subject: [PATCH v4 1/2] arm64: entry: Skip single stepping into interrupt handlers Date: Thu, 15 Dec 2022 19:59:02 +0530 Message-Id: <20221215142903.2624142-2-sumit.garg@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221215142903.2624142-1-sumit.garg@linaro.org> References: <20221215142903.2624142-1-sumit.garg@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752291176906528313?= X-GMAIL-MSGID: =?utf-8?q?1752291176906528313?= Currently on systems where the timer interrupt (or any other fast-at-human-scale periodic interrupt) is active then it is impossible to step any code with interrupts unlocked because we will always end up stepping into the timer interrupt instead of stepping the user code. The common user's goal while single stepping is that when they step then the system will stop at PC+4 or PC+I for a branch that gets taken relative to the instruction they are stepping. So, fix broken single step implementation via skipping single stepping into interrupt handlers. The methodology is when we receive an interrupt from EL1, check if we are single stepping (pstate.SS). If yes then we save MDSCR_EL1.SS and clear the register bit if it was set. Then unmask only D and leave I set. On return from the interrupt, set D and restore MDSCR_EL1.SS. Along with this skip reschedule if we were stepping. Suggested-by: Will Deacon Signed-off-by: Sumit Garg Tested-by: Douglas Anderson --- arch/arm64/kernel/entry-common.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kernel/entry-common.c b/arch/arm64/kernel/entry-common.c index cce1167199e3..53bcb1902f2f 100644 --- a/arch/arm64/kernel/entry-common.c +++ b/arch/arm64/kernel/entry-common.c @@ -471,19 +471,35 @@ static __always_inline void __el1_irq(struct pt_regs *regs, do_interrupt_handler(regs, handler); irq_exit_rcu(); - arm64_preempt_schedule_irq(); + /* Don't reschedule in case we are single stepping */ + if (!(regs->pstate & DBG_SPSR_SS)) + arm64_preempt_schedule_irq(); exit_to_kernel_mode(regs); } + static void noinstr el1_interrupt(struct pt_regs *regs, void (*handler)(struct pt_regs *)) { + unsigned long reg; + + /* Disable single stepping within interrupt handler */ + if (regs->pstate & DBG_SPSR_SS) { + reg = read_sysreg(mdscr_el1); + write_sysreg(reg & ~DBG_MDSCR_SS, mdscr_el1); + } + write_sysreg(DAIF_PROCCTX_NOIRQ, daif); if (IS_ENABLED(CONFIG_ARM64_PSEUDO_NMI) && !interrupts_enabled(regs)) __el1_pnmi(regs, handler); else __el1_irq(regs, handler); + + if (regs->pstate & DBG_SPSR_SS) { + write_sysreg(DAIF_PROCCTX_NOIRQ | PSR_D_BIT, daif); + write_sysreg(reg, mdscr_el1); + } } asmlinkage void noinstr el1h_64_irq_handler(struct pt_regs *regs) From patchwork Thu Dec 15 14:29:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 33660 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp395740wrn; Thu, 15 Dec 2022 06:38:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf7RPdishxB5QFqwWV0qUcUUdmTQKyON1ngSxDDEf6CGN0XTKnMH3CHk+NExKaRagVklLc/W X-Received: by 2002:a17:902:7288:b0:189:db2b:93ad with SMTP id d8-20020a170902728800b00189db2b93admr27528600pll.2.1671115116271; Thu, 15 Dec 2022 06:38:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671115116; cv=none; d=google.com; s=arc-20160816; b=YFEfzzoAd47PX28g3bovF7O/NGxNylOgx6wq6bBYbx0HJlOrzoEzN6opRVtTBkYXQL pZm6NtTzIQe28UzZwp7aayF0D1RupKREQDfmqNgEvpXyzRWKE5hND/xxYupNNKhWZeb3 2o5bfBFbzLBsWKXJwcoskXR37MHQMIBNRRC/q90mFaTxqn9oXWaveSj8K5AhE6QzawaI kr1aeKYuopXdTJPY+EOmKT/GHlo9uM4mbEuEaHjTCi+RVFXgnrJIga93WNbPbIrPcLBp FSCAf5kxGuh+gAsxz8TjZVLei99kRpDLKSiGMa7P9znnv5948/xRZIYNWcCifMH2/NMq OTdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=FuxPSSo3Y0HNcsTRiv4LvjgP5Z2vwZbV6xJtY/KrG9Q=; b=l88xcs0weZq5B2PSpNQrXBbGraheQpMYpGWZj7tku1Sm3h5zVmBoPAzA6yDxvqxnu/ GULs8B5U4BaijudCqsnm4wkBylXP1cFmCQpeibtd+TKQQqh7v0xqv5EENMNN5EBlhZjN 5kuIM5YmD687qQ2fMc3gjrqL9kSMb5qIc17mdNz3Ly6qmOsgSN96RTo5peOXqSql/AF9 G0aiH4lLHCwglKlIqVvtFahVZVi8zOXQPkf13dp8Qex+2NAuVPasugX3mJAEc1X6wQdr HOYc/r0J1QgtVoeTO0BBuZvePm0zZZ0ZvutPD0Up2YwJfHrggd2NyRzYiu1eetLD+ir/ RTvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GH+o3xGp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p7-20020a1709026b8700b00189e2b9e681si5861498plk.450.2022.12.15.06.38.16; Thu, 15 Dec 2022 06:38:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GH+o3xGp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229495AbiLOO3e (ORCPT + 99 others); Thu, 15 Dec 2022 09:29:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229844AbiLOO31 (ORCPT ); Thu, 15 Dec 2022 09:29:27 -0500 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C26ED2CE1B for ; Thu, 15 Dec 2022 06:29:26 -0800 (PST) Received: by mail-pj1-x102f.google.com with SMTP id t11-20020a17090a024b00b0021932afece4so2884534pje.5 for ; Thu, 15 Dec 2022 06:29:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FuxPSSo3Y0HNcsTRiv4LvjgP5Z2vwZbV6xJtY/KrG9Q=; b=GH+o3xGpbeSkSiHU4ZhFMZ9jkmwSgjEShmS+hkyC7LNuC+FLDPkFdCt39W2pFj3AEq 3As93RhfetUr/a7+HyILd1yr1jzNA4jL3g65bSUssPV3DXNsyRiz7MB4Q1IZMNyHQdX0 KdKsXm+wpuXZumoARgb0dOpHO6JxWQXv3nabufiTcvvLq6C/KV29jIjx6SzomLlD3CiL cdoIvLW6MjHKI32o3jL/M6+DbJaMmhAHE3iNhv8LQxF0tqxqQJjUq/W3D0jzhC0oKL1F tjpZFM6Dv21s0Dp9a6xoJGxJmlCzbNMtmDDN3LEC4KyS+J3XtdDbTB03jQdaw5kLlIce EKjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FuxPSSo3Y0HNcsTRiv4LvjgP5Z2vwZbV6xJtY/KrG9Q=; b=2YcjGme5bEdqa0NkgrMRS7FEf5Xz9F4Q3GjsTTawiopblKITzAs3dlx4MyobPWQjo+ W19NMJUYySHK9rRCu+HQQ25ZQQy61ABsqCj4NClF+mpLogBhrVxxLLDaT+1M5UZEhfwb aR3FFaXTDwkd/+a5L4ViwUyv9s/0e43ooHdELAasL/irMHQ1D+HhdaIM+vLCDG0DeDQz nby7rZ6LrbQ0LoGgXghRlMtnzzZPf5x94PcTOxNIQ0wtZhj/pJ++DsCVoB+FH+JzTkh0 pG3wFYrgeKBVRDRqxcD8b2+BsjUlGEWh+jxV0yLHl+Z6md+iHoFqTp0HUA0qE3UtPyzH wiJQ== X-Gm-Message-State: ANoB5pkJLYnqkDVYLXlr1dalQs3ejywDHyODcvtLlawfnUFZ7lgXXyOO JlkZ0u7nCxdISDL+LG9V4iIY2Q== X-Received: by 2002:a17:903:251:b0:189:7891:574d with SMTP id j17-20020a170903025100b001897891574dmr32757233plh.47.1671114566259; Thu, 15 Dec 2022 06:29:26 -0800 (PST) Received: from sumit-X1.. ([223.178.208.45]) by smtp.gmail.com with ESMTPSA id z1-20020a170902d54100b0017f5ad327casm3922010plf.103.2022.12.15.06.29.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Dec 2022 06:29:25 -0800 (PST) From: Sumit Garg To: will@kernel.org, catalin.marinas@arm.com, daniel.thompson@linaro.org, dianders@chromium.org Cc: liwei391@huawei.com, mark.rutland@arm.com, mhiramat@kernel.org, maz@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sumit Garg Subject: [PATCH v4 2/2] arm64: kgdb: Set PSTATE.SS to 1 to re-enable single-step Date: Thu, 15 Dec 2022 19:59:03 +0530 Message-Id: <20221215142903.2624142-3-sumit.garg@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221215142903.2624142-1-sumit.garg@linaro.org> References: <20221215142903.2624142-1-sumit.garg@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752291204119681799?= X-GMAIL-MSGID: =?utf-8?q?1752291204119681799?= 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); +} + /* 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 cda9c1e9864f..51f204bbcf87 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: