Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4588198ybz; Tue, 28 Apr 2020 14:16:34 -0700 (PDT) X-Google-Smtp-Source: APiQypIC4R+ht8xT+nKdLSpVTdd95LZSW79Dr2xz2wwXq67R0Qhvzogy35gtl6TtUq69GMAsVzC1 X-Received: by 2002:a17:907:4365:: with SMTP id nd5mr24945109ejb.231.1588108594122; Tue, 28 Apr 2020 14:16:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588108594; cv=none; d=google.com; s=arc-20160816; b=AKu44JWFKrFhpnfpknuD+67H1S0TmmxfXu1BSj1J7b08OhGsFtm85Q5u/JG0xeYec2 Qxx2npnJqzYpQxxHVRUrflyzuQrobtpX9qCJ1YwgI2X/y4ldZbY3BHffWhxlhigotd2O boJl+E4YutytDClj+akXDYvSyUxqpEvSlwRHtTrT2zwwfIpC84F12S1L6BGOjBwKV6Ul hmrsqVVbtTlAo+wl70802HYMSOALgM9LNMuso5GNdtlKFlV+rIo1HOPpPVldmnNgvdWY AxY1CnjcG/vGRK+H1b9zrXF+V5v/ttbheqmHPjj2zLvtuWid89LBHprDUuJkD3kAb9jf NJlg== 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=JZmkueo9bTgmb3PydH64E/vdUILQ0LUamDaAt5MylEk=; b=ezOL2+2IQAWtJZAakoradEDbKzCeC9MTZkLpoVUMiqUlYgJskbYLv7RuKX8UeFTjEF k8IO+CDiG9NHEIv89wV/meRK74Wa8cZPLt/xj2P/OUz7GfSdnvrAmc3pfNApvAmWlYVE SVt5sldREEBhmVFrYcLeVibgOLVnsgwKEd3tW0vKomDGAfffQtWdAfiNvqYGNKsK8e3f S6n6+85qRvSRtEWKvKxbbspBnM8uRswDv4Ekf1aploUxaUacsMBmArXTChOTWnQ+Ld1E Y6jWeup8VKgiRkwc1ylXQltikAvRm+feIdEyI8je+mwxCL6WpSry55xjVwLxQb1AEoSq ALjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=NhZmIu4K; 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 q12si2523043ejm.358.2020.04.28.14.16.07; Tue, 28 Apr 2020 14:16:34 -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=NhZmIu4K; 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 S1726818AbgD1VO2 (ORCPT + 99 others); Tue, 28 Apr 2020 17:14:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726697AbgD1VO0 (ORCPT ); Tue, 28 Apr 2020 17:14:26 -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 1B3ABC03C1AD for ; Tue, 28 Apr 2020 14:14:26 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id a5so58075pjh.2 for ; Tue, 28 Apr 2020 14:14:26 -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=JZmkueo9bTgmb3PydH64E/vdUILQ0LUamDaAt5MylEk=; b=NhZmIu4KEqUSDa/E+bo/5joJgDeITf/iXWPe9alloMIQ6fDCSGwu+3cLqwlZVdQ15e /+/0jACKvFQqBmuUk4OKqh074PQSR7z5Bh7WGcKq0S3IrqNrc8w7oebIsxOOaX/saVgP 6SXl2o1kZH8RxKpkPmMPqM/5pj+j24CowDnE0= 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=JZmkueo9bTgmb3PydH64E/vdUILQ0LUamDaAt5MylEk=; b=QaNAl+2w1UxFwFT7kPY6bEv/cop9+lkLmho4VC3Aopj+dMxFVVXvPDcof8nPT4BMd0 UblCRPRYPvuFDMnValIWpjZ/mZR1tkd2jhcdwMP4rlSuUxwrqwdJxeQqNad4yYJwE6De 6WejTXOzyw1rJvsRrIgxIhOiXx3++04AFINiWvpvPwP77P3vX48x3dHWW9NE8YB3Xfpq jvQsX9tma4xX6oJReyWwMsokf6zk4c09FskpLjBJgHie/v1UQtLAsoM1X2bmLApSpE+T GjdEmW1WcX/9FhzKar/lZgM10GlIBWp2W6tZQMbZS0CJoGdwl7fVXwr3IR9+NsEd/EUO 76Yw== X-Gm-Message-State: AGi0PuZGWChDvGQLuC1gibq/bNgo1U1o9q5xZ4WgRjJDBugIBIkapfIv G+dLXMT8DSpbLfHQ0dnijTSPLg== X-Received: by 2002:a17:902:9697:: with SMTP id n23mr3755091plp.150.1588108465622; Tue, 28 Apr 2020 14:14:25 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:24fa:e766:52c9:e3b2]) by smtp.gmail.com with ESMTPSA id 18sm2988202pjf.30.2020.04.28.14.14.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2020 14:14:24 -0700 (PDT) From: Douglas Anderson To: jason.wessel@windriver.com, daniel.thompson@linaro.org, gregkh@linuxfoundation.org Cc: agross@kernel.org, kgdb-bugreport@lists.sourceforge.net, catalin.marinas@arm.com, linux-serial@vger.kernel.org, sumit.garg@linaro.org, corbet@lwn.net, mingo@redhat.com, will@kernel.org, hpa@zytor.com, tglx@linutronix.de, frowand.list@gmail.com, bp@alien8.de, bjorn.andersson@linaro.org, jslaby@suse.com, Douglas Anderson , Alexios Zavras , Allison Randal , Dave Martin , "Eric W. Biederman" , James Morse , Mark Rutland , Masami Hiramatsu , jinho lim , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 05/11] arm64: Add call_break_hook() to early_brk64() for early kgdb Date: Tue, 28 Apr 2020 14:13:45 -0700 Message-Id: <20200428141218.v3.5.I22067ad43e77ddfd4b64c2d49030628480f9e8d9@changeid> X-Mailer: git-send-email 2.26.2.303.gf8c07b1a785-goog In-Reply-To: <20200428211351.85055-1-dianders@chromium.org> References: <20200428211351.85055-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 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..08a736175d2d 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 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.303.gf8c07b1a785-goog