From patchwork Thu May 7 20:08: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: 214007 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46813C54E49 for ; Thu, 7 May 2020 20:09:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1751521582 for ; Thu, 7 May 2020 20:09:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="oGL2HmBj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728580AbgEGUJr (ORCPT ); Thu, 7 May 2020 16:09:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728518AbgEGUJH (ORCPT ); Thu, 7 May 2020 16:09:07 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2580EC05BD43 for ; Thu, 7 May 2020 13:09:07 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id m7so2519087plt.5 for ; Thu, 07 May 2020 13:09:07 -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=cED6NDO4Kxls/KrnV6UJCllmK01DyycDxaWWk+2LKjw=; b=oGL2HmBjVpDLGAerPqZz5QWfbBmc6h4NYbJ+HPzp2t89q2jx0vM/u3t8eVesy/Kp/i c6jIzQyF5Xt3oUA9KKLyvj4PI1/KF3EWjdAl8k/oJnQ9h3m6Y+2sBbN/hiJm7zpjHRd+ M3GAlPq6ArCpj5RzA2ZcdESD+Zbesy1vwzmP0= 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=cED6NDO4Kxls/KrnV6UJCllmK01DyycDxaWWk+2LKjw=; b=eBaRKChsMXIgAzU2lPS1CVm3wk4M2XIHbmnrMOuj+0kdw8Ga06PaB7sydAQAU24D4n kyBT83JiO0OMaBAsRtFb2iqH6gwZNY7Pge0PSL1nm1ba+F9Nm9Da4/CaP7e/55e7reBj z/o26Sq5xItsaDMxnoisUAjB1wgqQCgR88ZqA64NRgz9WTRQ2V2NVhQe3YsAOq3U2MZ3 0hu9+NjnWTlk2iqzLv1AFDlv0OCW1tkz4LPeU/Dq38ZIi3vaRx0l42VH3U6xvl1J3giO ybBeppw1b01EJgGOo5ISb8x/1t5pUqCnKOtiVKwgzMw9/AuecoGkOeYLjMxdrPlK7Dfs su6w== X-Gm-Message-State: AGi0PuaTrkllpElXRF5fnSenjdLnYi/dHnHWANg0niZfjBeCnT7PCC27 rzLfk3kfF0XTFiyrg/PVl3KJ5Q== X-Google-Smtp-Source: APiQypKpAqCp8XOc/MLMZN0fgX43ORq5W22WL3D4XMRDrYPdkpsKqwzrWH7JlpnFrGUTMIhRBkHrmg== X-Received: by 2002:a17:90b:a8e:: with SMTP id bn14mr2009217pjb.197.1588882146670; Thu, 07 May 2020 13:09:06 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:24fa:e766:52c9:e3b2]) by smtp.gmail.com with ESMTPSA id d203sm5547601pfd.79.2020.05.07.13.09.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2020 13:09:06 -0700 (PDT) From: Douglas Anderson To: jason.wessel@windriver.com, daniel.thompson@linaro.org, gregkh@linuxfoundation.org Cc: corbet@lwn.net, frowand.list@gmail.com, bjorn.andersson@linaro.org, linux-serial@vger.kernel.org, mingo@redhat.com, hpa@zytor.com, jslaby@suse.com, kgdb-bugreport@lists.sourceforge.net, sumit.garg@linaro.org, will@kernel.org, tglx@linutronix.de, agross@kernel.org, catalin.marinas@arm.com, bp@alien8.de, Douglas Anderson , Alexios Zavras , Allison Randal , Dave Martin , Enrico Weigelt , "Eric W. Biederman" , James Morse , Mark Rutland , Masami Hiramatsu , jinho lim , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 05/12] arm64: Add call_break_hook() to early_brk64() for early kgdb Date: Thu, 7 May 2020 13:08:43 -0700 Message-Id: <20200507130644.v4.5.I22067ad43e77ddfd4b64c2d49030628480f9e8d9@changeid> X-Mailer: git-send-email 2.26.2.645.ge9eca65c58-goog In-Reply-To: <20200507200850.60646-1-dianders@chromium.org> References: <20200507200850.60646-1-dianders@chromium.org> MIME-Version: 1.0 Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.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: Greg Kroah-Hartman Reviewed-by: Daniel Thompson --- Changes in v4: - Add "if KGDB" to "select ARCH_HAS_EARLY_DEBUG" in Kconfig. Changes in v3: - Change boolean weak function to KConfig. Changes in v2: None arch/arm64/Kconfig | 1 + arch/arm64/include/asm/debug-monitors.h | 2 ++ arch/arm64/kernel/debug-monitors.c | 2 +- arch/arm64/kernel/traps.c | 3 +++ 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 40fb05d96c60..3d78f581269c 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -13,6 +13,7 @@ config ARM64 select ARCH_HAS_DEVMEM_IS_ALLOWED select ARCH_HAS_DMA_PREP_COHERENT select ARCH_HAS_ACPI_TABLE_UPGRADE if ACPI + select ARCH_HAS_EARLY_DEBUG if KGDB select ARCH_HAS_FAST_MULTIPLIER select ARCH_HAS_FORTIFY_SOURCE select ARCH_HAS_GCOV_PROFILE_ALL 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/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; }