Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp20014ybz; Tue, 21 Apr 2020 14:17:25 -0700 (PDT) X-Google-Smtp-Source: APiQypKh97Tx4lifhvFF3inSSFClUHpCgTFYlOcJQsvNn4+pskPrgcca1P8iEDnhnWG7D6iLiYv0 X-Received: by 2002:aa7:dcd7:: with SMTP id w23mr4100311edu.300.1587503845276; Tue, 21 Apr 2020 14:17:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587503845; cv=none; d=google.com; s=arc-20160816; b=uXaz8PgiMwrl2oOseBgIdJnP9BmsYbjw8mXJPxyzMIDpS+RjlCJQ/7xjoZsfZrj1fM L3/azRv+Oeh6BwrxzzSSX5WaefFgWsbn8cl85t4EoJJ/cQ1NAOG4u9i2lwE1NfS8Jalr 7+aveZ5OKDKV0S8GWZ73BwQUONbz3InfEBZ/Xh3Wr8yxb/KPKIxoVTDrE1AVFHhGENvI Ym7+YzpziH6KJEw8d7Ns3eFjVeP0LtHdpf+ZzcWRY3sT5r9maNJG+ZJdyTA+U7dxiCta FAqoO2zcvf+W738OQKO6xM1uQihVOzMVY2SCMj4cC40dmsuIr6vQSWReFJOkgIG5ac8K OD4A== 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=04XZYo5fXA8jjjQEMhm6NIaDkuVBkhqneNWDzQVam7g=; b=cd3hCovLvTsstO2y1qmHLtbR21blHljZ3BVkQE9qQRFr9W6N8BJITsTvuhkjf23w0T MzpR0U6a8S57FkJRS1xE85jnJx+wn7OB7iUmIPiUR3LtBiOFt/ry32szE5c6hcsHdYJM UCTS5YMZJgg4Oe/R3EquTy9ZMiL8Nmh2fnlfOGSXaDaguuPgxk6tgA4KL6GfVAA6/U9n IHFHAYvY2vwcASUkBm2sUHJUUgECZX6w0eY3buEITt0scbhkZDVLn73ZxKeJNO4QaltR Wp3Klc650AJg7PV526FK9dIXgTY6MGyVADVA16gg519OmRXt7zzNU9uSywYz9BuDnBLq fkYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=jCiq2fay; 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 t24si2354824ejr.291.2020.04.21.14.17.00; Tue, 21 Apr 2020 14:17:25 -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=jCiq2fay; 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 S1726358AbgDUVP1 (ORCPT + 99 others); Tue, 21 Apr 2020 17:15:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726362AbgDUVPZ (ORCPT ); Tue, 21 Apr 2020 17:15:25 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74A4CC061BD3 for ; Tue, 21 Apr 2020 14:15:25 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id x15so2927695pfa.1 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=JxozHp1fih8AGBdCSJlfvLz0/tzmNIgEeEr/2IydfAdKGwWEbSZbkmbKPE/6SgqFlk U8dCImclxco/OxnJbfnCj2h2CfRru/sPZdiSadQi6GR4y6Iy8K/KYzC3qEIh9VsbKRET DY7tU3CIU0tt5tRlrph7afeLMyAnw07A5SzSpcy8+I6Zjl/5LZ9QoOm1BdA5bbK6JJ/M knfiG4MIVArB00HkhW3Nzvf7GPRalIEJEVciuK1A7bIcsFgzS/Cc+kaSMYelQ2b7uA9h ZaRECVelfX3hHfWft4hZaQdD8TQc1KNDzpCt/wHF1mNlhMb7YFQqtfRAWqsw0+tLLwJQ uQGA== X-Gm-Message-State: AGi0PuZ3CdO+svF/YVRlOd6vuah6Gs8x6pyFYOLrBYzAD7YgzBoMYyU+ UBm7wVehfBSjwQ1OPdd9nN9Uuw== 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 Cc: kgdb-bugreport@lists.sourceforge.net, mingo@redhat.com, hpa@zytor.com, bp@alien8.de, linux-serial@vger.kernel.org, agross@kernel.org, tglx@linutronix.de, frowand.list@gmail.com, bjorn.andersson@linaro.org, jslaby@suse.com, catalin.marinas@arm.com, corbet@lwn.net, will@kernel.org, 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 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 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 --- 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; } -- 2.26.1.301.g55bc3eb7cb9-goog