Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1033525ybj; Thu, 7 May 2020 13:12:52 -0700 (PDT) X-Google-Smtp-Source: APiQypIH3QKTka/+98e5t3WVun9zZ8w1VwJytu9GWPPS6b/ag5t9kpkrviA1EDa/KwWmyNEVdqR/ X-Received: by 2002:aa7:db0b:: with SMTP id t11mr12878643eds.304.1588882372524; Thu, 07 May 2020 13:12:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588882372; cv=none; d=google.com; s=arc-20160816; b=k0KIj7azEtH0WQoMOux65keMchrclhvAD2DyWAepQI/Nr1JFCNaxYN0oJ5xHTLu33N K1VWPJvuQnQO8ZsI0ZbO+DpXuvWJS9U5kNIPsxoGRsb2AA6KZ6Abum95Ngb8Q0f5m2B9 OvcckyHym0cnf3Tzx5bEww1D2PFZv7Oyrc0JrJh0D7u5cRS/glPtDf8uF6toMDI6WZMK YyUGylZColKy3UA68EMCvQZV3Q+G89Jtgg6cMDuGRc0mdp5DFWSTbZtbmfQ1NytCM4PY 5W/1HjILjHYjA+Qks/XtozbV0qY+/nXfEvOc04M6t0Vo0EGHQEfhBYdtb3GOJPtoz5Xh yFWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cED6NDO4Kxls/KrnV6UJCllmK01DyycDxaWWk+2LKjw=; b=rFE4K+OPKPObHHmxNFxgDsXh2KpRsLvyJWghwAYsCnSlpaq5bibSrVIyZPSec2TBvw /0PTuvSmUxlHKOSNw93Ui/HAJEXbxvB1XpwPEK5iRCeY8++iT0QlXZwXACB63QDwOQG+ 4HrXrmUe1uTQRmpyLMuOVaFtcXrQulxRk6hnYZWz1hZFMjsF+heLEaySoMliDRDZbyyX 48FPyoB+GQHK5UkXDBNJ0STYeqZY9T8eLylQst1BOiWZ/90Ymf+xGmx8IQs3TbDUeK0U ccyXQMKMog6f6wiRt3DvDoxhyCo1MGpbu/fIr8fWzHwg5qKAMCjuqNUQCSs0OoAWi0n0 5RRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=oGL2HmBj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dk23si3591653edb.282.2020.05.07.13.12.29; Thu, 07 May 2020 13:12:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=oGL2HmBj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728777AbgEGUJr (ORCPT + 99 others); Thu, 7 May 2020 16:09:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728524AbgEGUJH (ORCPT ); Thu, 7 May 2020 16:09:07 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37F5AC05BD0A for ; Thu, 7 May 2020 13:09:07 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id 7so4217405pjo.0 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=jIdfeMMwfPyw1inwhaPP/e/H7rA4SMKPq9WQJQl2Yku0ETctVmYHgihrp07mjEIJhU Fu3V4sNCiLpPjDBPAe5yCXQViOls8d+UW+uU3XGZFirjIqSxy50RZgpfJQSjr33mJddg /59MN+vQw+fBeJmMU/LvWr+oWCVxWHPAi9UKvROqe3j8UkqluJCg2zvrsnA33ZmPyvI9 hT650LeFJxnXH+g28gkj7yXm7bL3zM9VBVuETd6AeP1Z4+6B+Ur/UeCIZHgdTLcskskW Uu+4AaOy1/I76CzT2u1kjSYv3f5TVmprFLBzNfbhnUbNBrK09Y4s5VNkimQ5mNbQaehP D8OA== X-Gm-Message-State: AGi0PuaW0/R2HqEYi+Rwotfkl1AW8cDM9NXcxmNq3ns4dTzVWfqDM7km 5bkRRIq28UXfJ1SXDdylebcMdg== 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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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; } -- 2.26.2.645.ge9eca65c58-goog