Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp280841ybk; Tue, 12 May 2020 23:20:17 -0700 (PDT) X-Google-Smtp-Source: APiQypIG0eYOISyM88cdi+F42A38n6K+9za2AaMUNjGPcyVmY5DAed4ku/5Y2BcJF6ynFEOf3IJU X-Received: by 2002:aa7:c3d3:: with SMTP id l19mr20543369edr.14.1589350817300; Tue, 12 May 2020 23:20:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589350817; cv=none; d=google.com; s=arc-20160816; b=Y4XtVUksYCrL+h9MqAslO+ffaCh+S19f12t98WrB1AbKqZ9QXWigvhZ+5py+2pAtML cbA894J1Uktz87dthIPVnQjnQ+WP09AIhLxBlJ7mxa9TrE2IWNNEEeZSq2LjSi/BFIaE 3Ll0ukznwqbWZZ/dyUMOGIEL/P06bNHJ+3rV+EM6fzEeuhQDA53Z+vkxgztaZmg2ItlX 5lQ6soYr4hfRGtK5Pj9ntnSkTEUuqNQGhHwnY3TaKcN0ItA9FC9MXkIYNjxVN771OjPB STkPDzphjV4s2XDRePWkiaI81ZzJa5Wh4c4eaob7eZpSXaFgGhcAF7eN9kcv5A+MEZGa w46Q== 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=/7v0xyCKFiTjI8QbMW1wywPsZCk1xedkZTlTjtJ8yNo=; b=LN4I6zKmMLIn8obn/BHnvc8qxi/ub1ueuuyNcI5h06yBcoblYuXsaLDzp3fGcy0PuI 0iCW5D8V9/wW1rPZm/V84KJFLfT9FUBozFOkKfqfXQjRmdB9idn59CtNxNR64RkbuN/A cqWOrrPdoAm6TC5RE78Ug4wxXMLsENzWHcrvw8TS+pQ92h+GlgYv6oAXXyP1E6XRoHzW sicA2boQK7Y6OzPnqFn3ayHjBwL6TOm92LYxCcEyIi+VZSjZ5pXdgeyDyQJ7pnG/yvlT 6lvcpzFrcr7NRCno4s/pCkCYe+SNgJCS3qtbjEYzxkyKyAknrArCC9PLmeKu2mDDgH7M 97Qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="hr/mqpP2"; 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 u8si2752973edl.504.2020.05.12.23.19.53; Tue, 12 May 2020 23:20:17 -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="hr/mqpP2"; 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 S1729376AbgEMGRy (ORCPT + 99 others); Wed, 13 May 2020 02:17:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:42830 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728803AbgEMGRy (ORCPT ); Wed, 13 May 2020 02:17:54 -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 265FA206B7; Wed, 13 May 2020 06:17:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589350673; bh=MzICw58ueTIcZPjAHA1rhxAPW7fC1iatHDfRyo1z5vE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=hr/mqpP2SnBe6bfko189D9OZLbaZn2kNpTtaq0L1QMOc59QWkBDFGPsMR47i7Z8lD Fg5kVOp0tCi4w7QBCfhfzhGwqWLKyCKK1/pU5h5Arvyoqr43jzuxE3OpAsNn1BQ9SB /nVwh0/GHj1ZLwjRcTmxDMkfwQDA+/0NMipcG8kA= Date: Wed, 13 May 2020 07:17:46 +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: <20200513061745.GB17433@willie-the-truck> References: <20200428211351.85055-1-dianders@chromium.org> <20200428141218.v3.5.I22067ad43e77ddfd4b64c2d49030628480f9e8d9@changeid> <20200511145908.GA22040@willie-the-truck> <20200512073552.GA1538@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 Hey Doug, On Tue, May 12, 2020 at 08:27:50AM -0700, Doug Anderson wrote: > On Tue, May 12, 2020 at 12:36 AM Will Deacon wrote: > > 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/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. > > "Early enough" is a subjective term, of course. The earlier we can > init, the earlier we can drop into the debugger. ...but, of course, > everyone thinks their feature is the most important and should be > first, so let's see... > > Certainly if we waited until trap_init() it wouldn't be early enough > to set "ARCH_HAS_EARLY_DEBUG". Setting that means that debugging is > ready when early params are parsed and those happen at the start of > setup_arch(). The call to trap_init() happens a bit later. > > If we decide that we just don't care about getting > "ARCH_HAS_EARLY_DEBUG" to work then the earliest we'll be able to > break into the debugger (via kgdbwait) is dbg_late_init(). That > _does_ happen after trap_init() so your solution would work. > > As a person who spends most of his time in driver land, it wouldn't be > the end of the world to wait for dbg_late_init(). That's still much > earlier than most code I'd ever debug. ...and, bonus points is that > if we hit a crash any time after earlyparams we _will_ still drop into > the debugger. It's only breakpoints that won't be available until > dbg_late_init(). > > > tl;dr: > > * If we care about "kgdbwait" and breakpoints working as early as > possible then we need my patch. > > * If we are OK w/ a slightly later "kgdbwait" then I think we can move > debug_traps_init() to trap_init() and get rid of the early version. > > > Please let me know which way you'd like to proceed. Let's go with the trap_init() approach for now, and we can revisit it later if somebody has a compelling reason to initialise things earlier. However, I don't think you can remove early_brk64(), as it's needed for BUG() to work correctly. Will