From patchwork Mon Apr 11 09:38:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 12808779 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 A9553C433F5 for ; Mon, 11 Apr 2022 09:39:49 +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:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=4MVKPM/80Jm/1VMJ+QthweeqisFOXW+/QeYEAd+0MC0=; b=ViYQ7spF02ADOt R0F8kQbRCLwfnNmQDGWji9PTgNrS3I0mixyQshhxFtKd/OyQ88EkiAgB+ZLluBGkJ15p79MmIUOnx BbWlcymu0k0zYki4VB5hQNBXjzk8pVV3jgqcYUUVN3yGdRg6o9v1wFlg9OruV/UjAnnN0U/Tp6qlz 56K4kZNrBzfX+VyLHQwFmAWG9l+Dg0781Ffyyqi4ssONekKokVIXHIcwRBHLQGrevlkJVOmntZIrV pIGF326Gi0srsvyjbqA710FR4mKLZKvc00zINSOIz6Ty7XE0kpjFUnXFYBR7pUsWqW3XP4G6fNLV9 0sL6rJilPRRYB79Fe5Gg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ndqVO-007yNA-4S; Mon, 11 Apr 2022 09:38:42 +0000 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ndqVL-007yMd-6N for linux-arm-kernel@lists.infradead.org; Mon, 11 Apr 2022 09:38:40 +0000 Received: by mail-pj1-x102a.google.com with SMTP id mm4-20020a17090b358400b001cb93d8b137so2443415pjb.2 for ; Mon, 11 Apr 2022 02:38:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2Mgp6pVkSMNLUNo4DPsjqmPs+yoIZMbh8PrScCQtPiM=; b=judohM/9aPQkaHYw1OyW/B0E5FdtFLosJNkmK0hYldEG0y04UchNLjdYEgRfG8e5UG Qu4kWs2fUS7aIquBJXpVeBD2YhVI7XQIDJy6KRTxek2URMvb9JFUl4KcVNnoEhmPlXSJ WLWEFZwiqGvhaHcw50HsI7tasDEQkPVutFSBMMWOcii47maRd1wcP03X2QjPXg3r3aw2 AZ+paeJtnDxsLr18B8fyZ97WAnVNGS8y4NWz0ag/wPLnvz+gRsR2eriRojGu35Ch/C3f M5SsjGISWBgJbhfYU0rmx59ut3Y+o8W2cbsa7aZFpTBOtrryl4xe1b764hPxSIMAl8v5 MTmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2Mgp6pVkSMNLUNo4DPsjqmPs+yoIZMbh8PrScCQtPiM=; b=MOtOThKvx+k9bLvbt+j7HKYjBe8XkylVCcXbPOSP2wlaSBjUBWYxURP5ttVHAS0/4c OX2rYMrjCMxLt9vL/h/DjY3BUs1WgolQ8lfRi8od91L1UoGkGh8RVuxYXgicBB9UyIRa oFzAzUQU4jVyFxgvf3YwTrcp345TaHTcSBuXrzA1uSbykxqN0l2TDElIHOl0Rdu8O74d M/o+QyOre636mQSvtUyjXarZnr9sqj2O6/XYLsvl2ilxtqqnkMdF9yAPW0EvMi3QUZKb 3KnrLFTfS+VGEZqMn3HGx/uuW0Rz4E/onEivzS4kk69+kFb9/hKlEefyQI5bqzhnUlF8 3UHQ== X-Gm-Message-State: AOAM533J3dKIhkQM1xqEgQPG6DIzZ4GG5O48p83ruoIxpE5mMexxbvVe OnWWhq2xs4y7WLwFwdO4PD47JAyHWRU34vwJ X-Google-Smtp-Source: ABdhPJzX5UalnwICGKeRp6I4kHxHVKJILwYU0i00E7ab8iFGqOBWigZ0yzBU/yPnkSl80u5CckyZhQ== X-Received: by 2002:a17:90b:1bc2:b0:1c9:9cd1:a4fe with SMTP id oa2-20020a17090b1bc200b001c99cd1a4femr35412815pjb.136.1649669917110; Mon, 11 Apr 2022 02:38:37 -0700 (PDT) Received: from localhost.localdomain ([223.177.215.72]) by smtp.gmail.com with ESMTPSA id d6-20020a056a00244600b004f701135460sm36461596pfj.146.2022.04.11.02.38.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Apr 2022 02:38:36 -0700 (PDT) From: Sumit Garg To: linux-arm-kernel@lists.infradead.org, dianders@chromium.org, will@kernel.org, liwei391@huawei.com Cc: catalin.marinas@arm.com, mark.rutland@arm.com, mhiramat@kernel.org, daniel.thompson@linaro.org, jason.wessel@windriver.com, linux-kernel@vger.kernel.org, Sumit Garg Subject: [PATCH 0/2] arm64: kgdb/kdb: Fix pending single-step debugging issues Date: Mon, 11 Apr 2022 15:08:17 +0530 Message-Id: <20220411093819.1012583-1-sumit.garg@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220411_023839_304725_34AFBC0E X-CRM114-Status: GOOD ( 10.73 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch-set reworks pending fixes from Wei's series [1] to make single-step debugging via kgdb/kdb on arm64 work as expected. There was a prior discussion on ML [2] regarding if we should keep the interrupts enabled during single-stepping but it turns out that in case of kgdb, it is risky to enable interrupts as sometimes a resume after single stepping an interrupt handler leads to following unbalanced locking issue: [ 300.328300] WARNING: bad unlock balance detected! [ 300.328608] 5.18.0-rc1-00016-g3e732ebf7316-dirty #6 Not tainted [ 300.329058] ------------------------------------- [ 300.329298] sh/173 is trying to release lock (dbg_slave_lock) at: [ 300.329718] [] kgdb_cpu_enter+0x7ac/0x820 [ 300.330029] but there are no more locks to release! [ 300.330265] [ 300.330265] other info that might help us debug this: [ 300.330668] 4 locks held by sh/173: [ 300.330891] #0: ffff4f5e454d8438 (sb_writers#3){.+.+}-{0:0}, at: vfs_write+0x98/0x204 [ 300.331735] #1: ffffd57c973bc2f0 (dbg_slave_lock){+.+.}-{2:2}, at: kgdb_cpu_enter+0x5b4/0x820 [ 300.332259] #2: ffffd57c973a9460 (rcu_read_lock){....}-{1:2}, at: kgdb_cpu_enter+0xe0/0x820 [ 300.332717] #3: ffffd57c973bc2a8 (dbg_master_lock){....}-{2:2}, at: kgdb_cpu_enter+0x1ec/0x820 So, I choose to keep interrupts disabled specifically for kgdb. This series has been rebased to Linux 5.18-rc1 and I have dropped Doug's review and test tags as there is significant rework involved. [1] https://lore.kernel.org/all/20200509214159.19680-1-liwei391@huawei.com/ [2] https://lore.kernel.org/all/CAD=FV=Voyfq3Qz0T3RY+aYWYJ0utdH=P_AweB=13rcV8GDBeyQ@mail.gmail.com/ Sumit Garg (2): arm64: kgdb: Fix incorrect single stepping into the irq handler arm64: kgdb: Set PSTATE.SS to 1 to re-enable single-step arch/arm64/include/asm/debug-monitors.h | 1 + arch/arm64/kernel/debug-monitors.c | 5 ++++ arch/arm64/kernel/kgdb.c | 35 +++++++++++++++++++++++-- 3 files changed, 39 insertions(+), 2 deletions(-)