Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp888715ybk; Wed, 13 May 2020 16:10:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBheCdW0LBrqpYW3J+K9iGgAtzxfUbShe10tcdgfdDnc0CDVEZLHEQQQthbiciJbbvFKXL X-Received: by 2002:a17:907:42fe:: with SMTP id oa22mr1318029ejb.98.1589411426341; Wed, 13 May 2020 16:10:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589411426; cv=none; d=google.com; s=arc-20160816; b=rnPCGHs2KEBhAbqaUS9SwdpeQ0FqzeKbs6OMoaIjw3KgGkJ0+iIH/sEil4tvd0KkJt wDt0T/KTL+yG8F4rT4XGz9KMi/VuKSzwOJXgVDBUwHO4FShBNL34VSLcmvc0HdErEtKA WDkKDXIaJ+PY9/mV1eYDARG3nVdaacl/70uek2mr4BakBWs1d6edSv6VFb/+BAa3Vcjd gh1TOudE6+FMwPLmDZnpytkXOwSkFldpJ8uMQaZPpBndMKQd0E2bfH2LvMmNfPMT1iTr rZO502Z0MkJwNSytYN82JAjgiSs3GoepwPqhiWXdtTcBnPyE4tjytDXt3fBfA/021k1R w7Sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=qrc+zALKhm7UR0okg2VxygijLhPHdyDYt6UnXc1+qEk=; b=CK+Zkdu4BFhKj+NbEaN0bLiPIE9OND8MaVATkv9Flp5pu5EYnhh8exa8T6T6Z2yCeq Sz1cB1KVFaIHmn5JATWN+hQgaTPXDAyq/1GA4cg+Vq7FzjrffXtjzcDdrtwydfsTvh95 dPCxgKUWqTDBIrAC33+lrp1J+RmR19TrFbF4j41LhaXyY7MSSpSVEnCSPEbygwk7d7Np 8CeTuH0p7FR46XvqgzBknTYxOsCZhbDaFI7ZKnW1zTSeidQFFuLK8OZ1fRPbdFoS2Uij fAvhDXlHNhmIXk1AvKLUthT2K31PzSv9RaN4bgxewPJOOovwnp3vTheoY0MEJ+4T0YZw V1Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Qh7lvFu7; 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 se14si795382ejb.103.2020.05.13.16.10.03; Wed, 13 May 2020 16:10:26 -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=Qh7lvFu7; 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 S1732425AbgEMXId (ORCPT + 99 others); Wed, 13 May 2020 19:08:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1732392AbgEMXIa (ORCPT ); Wed, 13 May 2020 19:08:30 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E7A2C061A0E for ; Wed, 13 May 2020 16:08:29 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id t7so427278plr.0 for ; Wed, 13 May 2020 16:08:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qrc+zALKhm7UR0okg2VxygijLhPHdyDYt6UnXc1+qEk=; b=Qh7lvFu7Q7FSluMhlA+8KOS62pXg1rxQC1Ogk+ACNtMIaCyE9ShN6VB9f9gGDvteW4 gypT5Ev3vDl69jha5hOD76TZn8yRrjhUMxAWk1zqNUDl4SXtliMPJmL50nvFC0c/bC3V lRIsq85AmTyx2GxwUTqokmeiKV/xXeYZWSBXw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qrc+zALKhm7UR0okg2VxygijLhPHdyDYt6UnXc1+qEk=; b=UFQqW5EaG4YW3Iman+edOJsbRC6CYooj4LZfIEe+1W9IASjkBtbqF8yc8zpbZ17uDp J1vPZLHQFnq07yi1H4yh2xC9+vyRQVZW2P9+fv9PVvgmwPakZ7mYh3Ck7bUxoQGQyMzx HAzEZa1k1mnTPEdlsfH6uMj5mvzT3JSJ3CGjlAVDj+aUVKe6K5I2JVr3UnvAC3FF6pHc tFzZiP8BbwVw94Nsjz2rySoQMUabwsS7maSgUYNTHA4h9hTMNBw6/kIoLgQE3/BO9iln h4/nvdRilozYgtmSNshADBrmFvsKgR26cxnMzvQAzSGGqX8z2U6e+iU/0VCesxOwBaYz VxTQ== X-Gm-Message-State: AGi0PuZuc/KWhL1lFOrw5sPVtxvaX2Tl6WhI2DkpaZH9sfAEWeOXbR3F 99xwIGypwdWe0fEb3w1Gkqqw6mktlY0= X-Received: by 2002:a17:90a:ba18:: with SMTP id s24mr39292689pjr.192.1589411308676; Wed, 13 May 2020 16:08:28 -0700 (PDT) Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com. [209.85.216.43]) by smtp.gmail.com with ESMTPSA id q62sm17136421pjh.57.2020.05.13.16.08.27 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 13 May 2020 16:08:28 -0700 (PDT) Received: by mail-pj1-f43.google.com with SMTP id a5so11731147pjh.2 for ; Wed, 13 May 2020 16:08:27 -0700 (PDT) X-Received: by 2002:a1f:9605:: with SMTP id y5mr1422470vkd.75.1589411305040; Wed, 13 May 2020 16:08:25 -0700 (PDT) MIME-Version: 1.0 References: <20200428211351.85055-1-dianders@chromium.org> <20200428141218.v3.5.I22067ad43e77ddfd4b64c2d49030628480f9e8d9@changeid> <20200511145908.GA22040@willie-the-truck> <20200512073552.GA1538@willie-the-truck> <20200513061745.GB17433@willie-the-truck> In-Reply-To: <20200513061745.GB17433@willie-the-truck> From: Doug Anderson Date: Wed, 13 May 2020 16:08:13 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 05/11] arm64: Add call_break_hook() to early_brk64() for early kgdb To: Will Deacon 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Tue, May 12, 2020 at 11:17 PM Will Deacon wrote: > > 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. Posted at: https://lore.kernel.org/r/20200513160501.1.I0b5edf030cc6ebef6ab4829f8867cdaea42485d8@changeid I'll also reply to the v4 version of this patch to point at it. -Doug