From patchwork Tue Apr 21 21:14:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 11502215 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 80EE113B2 for ; Tue, 21 Apr 2020 21:15:46 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 5EE0D20724 for ; Tue, 21 Apr 2020 21:15:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="KkwDA4kR"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="jCiq2fay" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5EE0D20724 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0LSCjzPkNhx9fvM2vNdA9wHLKcekmcOMUISjhLh5BYM=; b=KkwDA4kR+Xo+BW wm8zYC4NHTMvQ8TJr1v2lFUR2uf0gvpbW+sxiVSRRCnMFS5E7JBf0YrOTodsH28CE/L2WV5IsOoCj DYvVjH4Sbq1uBsPjcIhxlA1YTdVgjq616sE4wVfxE2hF6Fy1Pypbo1V0r+HOGLX6EHnqnayMDwivX 1sQARmIDFUzsS3FuXKMGK9/7ktvif/zTwsoOo3Ii4G4JWUruMTt9GE35vP/IMXD5TmEvft4224rM8 e7pFLQJfPUbufM5ddpYLYy0k2WqpMfnPbA1dNQJ6iH3JlIQlJvknqQBcZCj1QJvyAqSEdoPDx9uPO KA6RuujWQHr09l+SURpQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jR0F1-0006Mg-JU; Tue, 21 Apr 2020 21:15:39 +0000 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jR0En-00069c-MR for linux-arm-kernel@lists.infradead.org; Tue, 21 Apr 2020 21:15:27 +0000 Received: by mail-pf1-x442.google.com with SMTP id f7so1179305pfa.9 for ; Tue, 21 Apr 2020 14:15:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=04XZYo5fXA8jjjQEMhm6NIaDkuVBkhqneNWDzQVam7g=; b=jCiq2faydL3OiQdwG7cFDruVuRAgHnscmd8JDvfJ5iyBf/cSxretgz78r9MZid2wQs pHJQK1BpUlFelzuAEcGpKwyg6UjVOQYEIr4jz1kSFuGgbKFAQErtbb7pXwX5etMp0BBm kJHMsRmyCSl2NnT1g3J8PRJwfFJCUJQNithtk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=04XZYo5fXA8jjjQEMhm6NIaDkuVBkhqneNWDzQVam7g=; b=tziwC6CAXQ183lc9BUy/EtIAU9yoZWs+fkHFmFsslkEMT+kSlAeqZ78PdFuiyu19jQ DVL8PbphLPRSgvIb01ddZkq+ydOVme82i56ACTXhf/ndt1pihSaxMCYs+mDTy9pQmnEX OcoAW62o8rxv87e5b8DF8v5t+nCu6Kj8Iexymb7t46xjMJJkVPWxOaBJvLhaTDF/vgDB a+duqe8Y4HwZLe8Bm/smqbIUFX70t4SZ1fEDhedlZdHegQmO7TyDlJq5xJHl9vH3qrZA 1BXEuGfGnaBEoNqU+SyiqpZ0Tr/SgIJ6ScKIMGe7CpOQLWaRQEUpCm4DPbcbprZ/u4Dr 5n8Q== X-Gm-Message-State: AGi0Pubc6jFkISDVrVeYzIvMS9qdF8lihcbpnpUF3V7WvIvhiZCdwbCn 4oouXsUqADx45Unfa98g3TRUSQ== X-Google-Smtp-Source: APiQypKuBADi/9vxdm+kBSaWN7ML+MvxdmBicivB0CG8boqZPIB1lUO05+yH8k3NEjmmzMx6G4rXkw== X-Received: by 2002:a63:4d5e:: with SMTP id n30mr23391637pgl.154.1587503724930; Tue, 21 Apr 2020 14:15:24 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:24fa:e766:52c9:e3b2]) by smtp.gmail.com with ESMTPSA id c1sm3287880pfo.152.2020.04.21.14.15.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2020 14:15:24 -0700 (PDT) From: Douglas Anderson To: jason.wessel@windriver.com, daniel.thompson@linaro.org, gregkh@linuxfoundation.org Subject: [PATCH v2 5/9] arm64: Add call_break_hook() to early_brk64() for early kgdb Date: Tue, 21 Apr 2020 14:14:43 -0700 Message-Id: <20200421141234.v2.5.I22067ad43e77ddfd4b64c2d49030628480f9e8d9@changeid> X-Mailer: git-send-email 2.26.1.301.g55bc3eb7cb9-goog In-Reply-To: <20200421211447.193860-1-dianders@chromium.org> References: <20200421211447.193860-1-dianders@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200421_141525_826853_21FDCECD X-CRM114-Status: GOOD ( 15.06 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:442 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , catalin.marinas@arm.com, bjorn.andersson@linaro.org, hpa@zytor.com, will@kernel.org, corbet@lwn.net, frowand.list@gmail.com, jinho lim , agross@kernel.org, linux-arm-kernel@lists.infradead.org, linux-serial@vger.kernel.org, kgdb-bugreport@lists.sourceforge.net, Dave Martin , Masami Hiramatsu , jslaby@suse.com, Alexios Zavras , bp@alien8.de, tglx@linutronix.de, mingo@redhat.com, Allison Randal , Douglas Anderson , linux-kernel@vger.kernel.org, James Morse , "Eric W. Biederman" , Enrico Weigelt Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org In order to make early kgdb work properly we need early_brk64() to be able to call into it. This is as easy as adding a call into call_break_hook() just like we do later in the normal brk_handler(). Once we do this we can let kgdb know that it can break into the debugger a little earlier (specifically when parsing early_param's). NOTE: without this patch it turns out that arm64 can't do breakpoints even at dbg_late_init(), so if we decide something about this patch is wrong we might need to move dbg_late_init() a little later. Signed-off-by: Douglas Anderson Cc: Catalin Marinas Cc: Will Deacon Reviewed-by: Daniel Thompson --- Changes in v2: None arch/arm64/include/asm/debug-monitors.h | 2 ++ arch/arm64/kernel/debug-monitors.c | 2 +- arch/arm64/kernel/kgdb.c | 5 +++++ arch/arm64/kernel/traps.c | 3 +++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/debug-monitors.h b/arch/arm64/include/asm/debug-monitors.h index 7619f473155f..2d82a0314d29 100644 --- a/arch/arm64/include/asm/debug-monitors.h +++ b/arch/arm64/include/asm/debug-monitors.h @@ -97,6 +97,8 @@ void unregister_user_break_hook(struct break_hook *hook); void register_kernel_break_hook(struct break_hook *hook); void unregister_kernel_break_hook(struct break_hook *hook); +int call_break_hook(struct pt_regs *regs, unsigned int esr); + u8 debug_monitors_arch(void); enum dbg_active_el { diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c index 48222a4760c2..59c353dfc8e9 100644 --- a/arch/arm64/kernel/debug-monitors.c +++ b/arch/arm64/kernel/debug-monitors.c @@ -297,7 +297,7 @@ void unregister_kernel_break_hook(struct break_hook *hook) unregister_debug_hook(&hook->node); } -static int call_break_hook(struct pt_regs *regs, unsigned int esr) +int call_break_hook(struct pt_regs *regs, unsigned int esr) { struct break_hook *hook; struct list_head *list; diff --git a/arch/arm64/kernel/kgdb.c b/arch/arm64/kernel/kgdb.c index 43119922341f..96a47af870bc 100644 --- a/arch/arm64/kernel/kgdb.c +++ b/arch/arm64/kernel/kgdb.c @@ -301,6 +301,11 @@ static struct notifier_block kgdb_notifier = { .priority = -INT_MAX, }; +extern bool kgdb_arch_can_debug_early(void) +{ + return true; +} + /* * kgdb_arch_init - Perform any architecture specific initialization. * This function will handle the initialization of any architecture diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index cf402be5c573..a8173f0c1774 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -1044,6 +1044,9 @@ int __init early_brk64(unsigned long addr, unsigned int esr, if ((comment & ~KASAN_BRK_MASK) == KASAN_BRK_IMM) return kasan_handler(regs, esr) != DBG_HOOK_HANDLED; #endif + if (call_break_hook(regs, esr) == DBG_HOOK_HANDLED) + return 0; + return bug_handler(regs, esr) != DBG_HOOK_HANDLED; }