Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2501879ybk; Tue, 12 May 2020 00:37:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+GMOAyaTkMWmTGR4ifewPe2xWY7sYkr9tmxnF3ZU3GKDFVFZLQRngA3DSKZLyecM8sMZ5 X-Received: by 2002:a50:ee04:: with SMTP id g4mr7909327eds.221.1589269071221; Tue, 12 May 2020 00:37:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589269071; cv=none; d=google.com; s=arc-20160816; b=EAC9dqmeyHivUWjzxq8lKQ3GWjPcLCr26SRUgK2iAltx02ri8ZRlsQ4RnaWE0GVZes 4ZWhKVUfoH7nJMilB7o/+uPqd/dP146Mi3uD5oLm7Zqjmf6PWO0k0TVihbCz/HaADRai dHqdrbapvfFqgAGVHzgeA3ykx88Y79HgCISTsK2QfYJ5H7dM9h2IhVMn19+saMhOrahp TFeaj3aI7dYwUs4p3TnwOTFqRrro+A3OQF2yz47csUSqzDg9HPnaaHUyc3lEaOAWtywJ /87ECWieT+2pf851JrkRjp0+rP95DPq7Vizww3bQAIFfLQLlByT+3Z75Iwg4DjfBlmXj nY0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=iuxyBRhcTAWti4uvr2GZ9BGzC4ldjBNr8rfTA9yCuOc=; b=Sy+0cVH8EADlMDrNW6zxRTRogIRpSN3jz5qZ6tlBmM5jChFCPe7+RxW8Xb++1g3/Hn sso/rhIEquLgQSeIAtd1oStBSZKeZMrakPWBdhui9ln1Srw6TKufp8R8ZnD6ixRixgDn 86jzlCYa8xXJHrQVPJ3xwmr4/q2ZlDYabAZ0FZ/QmANC7o4G+Ez7qGUQyewHf+S3KRoy SwFzp0YJRUVfOGF/YDxuJqYsMYnv6A+53KCzEQfrvh7BxowBA23awbYFlQmBiG5ABrA6 oQu7Zeg+z3zqyqWQEPyP82P2xf+hg9H/FfCCCfnwrf3zddzKMjCkrYWEYpgVy5uOxyXZ n39Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=t5R7cSJl; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j19si7279528eds.208.2020.05.12.00.37.27; Tue, 12 May 2020 00:37:51 -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=@kernel.org header.s=default header.b=t5R7cSJl; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729008AbgELHgC (ORCPT + 99 others); Tue, 12 May 2020 03:36:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:42314 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728949AbgELHgB (ORCPT ); Tue, 12 May 2020 03:36:01 -0400 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B5F32206B7; Tue, 12 May 2020 07:35:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589268960; bh=mwdUCDRsQcd4tBUSrGY2SY7Tr80S7IIqcEq7gM+QFyo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=t5R7cSJlDsOP/Rq15vISPrYY6nRgt0EcIH9XTuDyRC2GPJ6DWnRnmhKdfTiy4a30Y VJDL7O2w+OjJd6KbOlyAT9++Kn8lwIjNjkC+57eIGAzvYLg5+3SymfzalRlvTKRmLj Akz/XtkhIvyCU63jhozKZ3BdSOgowTXCmGBDg64I= Date: Tue, 12 May 2020 08:35:53 +0100 From: Will Deacon To: Doug Anderson Cc: Jason Wessel , Daniel Thompson , Greg Kroah-Hartman , Andy Gross , kgdb-bugreport@lists.sourceforge.net, Catalin Marinas , linux-serial@vger.kernel.org, Sumit Garg , Jonathan Corbet , Ingo Molnar , "H. Peter Anvin" , Thomas Gleixner , Frank Rowand , bp@alien8.de, Bjorn Andersson , Jiri Slaby , Alexios Zavras , Allison Randal , Dave Martin , "Eric W. Biederman" , James Morse , Mark Rutland , Masami Hiramatsu , jinho lim , Linux ARM , LKML Subject: Re: [PATCH v3 05/11] arm64: Add call_break_hook() to early_brk64() for early kgdb Message-ID: <20200512073552.GA1538@willie-the-truck> References: <20200428211351.85055-1-dianders@chromium.org> <20200428141218.v3.5.I22067ad43e77ddfd4b64c2d49030628480f9e8d9@changeid> <20200511145908.GA22040@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 11, 2020 at 03:45:02PM -0700, Doug Anderson wrote: > On Mon, May 11, 2020 at 7:59 AM Will Deacon wrote: > > On Tue, Apr 28, 2020 at 02:13:45PM -0700, Douglas Anderson wrote: > > > 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; > > > > I think this just means we're not running debug_traps_init() early enough, > > and actually the KASAN early handler is unnecessary too. > > > > If we call debug_traps_init() directly from setup_arch() and drop the > > arch_initcall(), can we then drop early_brk64 entirely? > > It seems to work in my testing. ...but the worry I have is the > comment right before trap_init(). It says: > > /* This registration must happen early, before debug_traps_init(). */ I /think/ the reason for this is because debug_traps_init() replaces the BRK vector, so if that runs before the break hooks have been registered for e.g. BUG() then BUG() won't work during that window. Hmm, so dropping early_brk64 is problematic after all. Damn. Is trap_init() early enough for you? If so, we could call debug_traps_init() from traps_init() after registering the break hooks. Will