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: 11534837 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 D945E1392 for ; Thu, 7 May 2020 20:09:15 +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 85DEC2173E for ; Thu, 7 May 2020 20:09:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="LmZ5Mh1Q"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="oGL2HmBj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 85DEC2173E 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=rmVBrLI+AI0zGjv0I+Z4jsPe2pYe6EbA0qHgmzho5aM=; b=LmZ5Mh1QsnwyLw b6hkceJrLUVKWKmKkSRe/UHiLZ0PC/0wx5E1vl+B2zBsEnnfqfDntHiLh3CLAhE46XS94ffGNOOTm yL5AQkd30tXbtwZNhiIKNszSDcX36AaGdk5TVR6vCwcOo9ih1gX0A9DXrnXEevV/R8MnReQcsy2xN OkFTqiKiRLFSoRmYJ9KRq8TYNXR2OjgTkx6CuqB1k02Aj+YXnzR0gd+niespJ2eJGfDTLuWdceCt+ A7uVnVci7Sdrg4Smr+M7vFyZHHGkSqPQlVMOcHDgF5QbwOTio92+rkhrvTaMoceV0kM2jayqBOyl1 fA2cAzxGikvgIlmO2w3g==; 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 1jWmpT-0000BR-7K; Thu, 07 May 2020 20:09:11 +0000 Received: from mail-pj1-x1042.google.com ([2607:f8b0:4864:20::1042]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jWmpP-00006o-KN for linux-arm-kernel@lists.infradead.org; Thu, 07 May 2020 20:09:09 +0000 Received: by mail-pj1-x1042.google.com with SMTP id h12so4215408pjz.1 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=YhtR8E1SN5RMCHcKPynCnNEN22IlTNDQb6vx9XssS6j5fQJd2kYlAyJ+LqovA0Idt0 n2IKDaPJeUSWdipSwbWti7b8nYfOW9L3Y+V3o6EtYZQJDrtWFJuyfOAkpud1g+pCPGcc Dd6uiFZjtapHUJjymqjNrn4PsSGCxABRD5rr4a8feutE0RgPgUfzkZZvMxNzqOahsU9C Sefiy0NFFIx1B7+ItSbM0tyK1ptOmmz+kgurcejj/C7X4EDjrS/NnPlxPgHzwuFLU6K6 oBvn8nb/ynjVaXyZJkFgL0OiRrq5kpEabXRw+r0DYXz67QJ3Fq3xpMeVIlEDjURUrVBI X0Fg== X-Gm-Message-State: AGi0PuZiuDaC5Ta1jucvirpeFq1g9LIGaMNzjx+HNRi8gAOo3VitGWd4 5VcLoBkwoIXbrdickPGYGdGEwg== 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200507_130907_745107_96AE206F X-CRM114-Status: GOOD ( 14.85 ) 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:1042 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_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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 , sumit.garg@linaro.org, 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: 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; }