Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp629583ybk; Fri, 15 May 2020 09:26:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXccqzueVuOeelJMqE1PQUMDV6zZ5ET0TFyx/WzLTp5Bn5dO19i0jvCd7ZanotaXoXxrJJ X-Received: by 2002:a05:6402:1b0e:: with SMTP id by14mr3522957edb.329.1589560005209; Fri, 15 May 2020 09:26:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589560005; cv=none; d=google.com; s=arc-20160816; b=r82pn+B3zKUewUoOyBUL4sLYnHz4eSaG0D6V7mlIu+2BidMwuuKC/ZKe9yIwLshQn6 isXz7SyDz67Ft2idryClS7nG49FeQGuAySmDZgXzaQVc0A9IWb4+DnBGmvzvkc5NxRq/ sanQoalJBa6EGZggyDN9U26yjKSRH/CnEngHhxCEC13Kbs+RLZH8Ld+PVZ8S2ftLti2v bxaTWbYbNTWAkn1k4BlBGZwF+5fM1rC5PD+a7gUGM/M49u+yM0r9vZ2+fZJPQhlLN2dZ ti+DcQ3bWDkcz+4sm1x1mvGh0vvHjj9njtoqjyVkcha1EudFcjnN12WwdIupM9WumQqi dEhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:date:from :dkim-signature; bh=sBTKLmt+G7HKE9vsnUyZ/pBjQDTz5mLNOHvgITKgWpw=; b=sDSjmjbs3babiUpqII0WhJmI01Okhxpsbo975u6UFrjCvtTffwqQWfTSitj5srlXqc zgoVcd8dj7h9ZKbjITHP/n9LdNCc5iDovURf6sFSpfirVYkI/cEn7u8WPZ99dLKdTpYB Q/HFfUyZtKQmmeh8ZIAAx5eEYOUNdSV11bjQRLMDkwTLsTepA3f7AeFJcq6GgZFJNgrA V7lI/PwFg0KK+bhfvn586ZpIZH6xfB/TiFhXDPN6B6wtdtApWqZLIyGQqfAqeQPNonGR fuvh4rElW/OnUcEW1wWIL17FhAM9gksqChHFdGLMBRjQ4FXGSScehjPyvvTk0ZDiQ2By NAJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CLskbifd; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v23si1429792ejw.62.2020.05.15.09.26.22; Fri, 15 May 2020 09:26:45 -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=@gmail.com header.s=20161025 header.b=CLskbifd; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726513AbgEOQYQ (ORCPT + 99 others); Fri, 15 May 2020 12:24:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726188AbgEOQYP (ORCPT ); Fri, 15 May 2020 12:24:15 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AD8FC061A0C for ; Fri, 15 May 2020 09:24:15 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id k7so1076321pjs.5 for ; Fri, 15 May 2020 09:24:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=sBTKLmt+G7HKE9vsnUyZ/pBjQDTz5mLNOHvgITKgWpw=; b=CLskbifdKA1sxChD1enuaKFOQbnss3tOHCsEiZ4/qCeEzKwZUx4Usa/XUEHGpON8xG DOdk4sAV+cPkbiUoibLugT7A/zsnG0evWVJ3xwixa22KFvsYOVmOYJLQBYrNSc4rg2yJ ljOmyD/lyrXvqp3w03OFmM0LHzDL52UNftl533zCX2DM5vOiDm9eAfzQXYtk6bW8elbZ WiNzbu3bqRryeFFPW35r45fSz+0WlbMHykM9Tni46GHymUCG0N7ZdxrAOiP/4Wu9GOA8 4lOh0eJqUIcZf602d8tzWwp5+wvYSxsnUcyoFlPr+PkIsfylNVpiy1Fv44Nf3tOP1dSR EeCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=sBTKLmt+G7HKE9vsnUyZ/pBjQDTz5mLNOHvgITKgWpw=; b=a9cbGiwCHBxAsTzBBAb7wJs+Kt19l47U+etKqoKANjB18eAWDuZVuaBx1tYCyfpFN5 sNcuujCl1ytSvfTTsFJkAVPyLdw9v+fC4Rkft2ljJ5G7tyf+BwQiEd61OSUGDKl2XY3q qaYf8C2uDMpUKjP5kPKxrfxdzR7thiBeUDahw9T7GAga37Z5sRX80/a5BG30cegn9GDt t0RwH5OogM+QFpe05CAU8jNrfMC+MvAYMygUM4iine667q1XAnxEkGwrIHQNZdfO7lMT EV9R3EwwVRzXpyDNUghXNcVBe0AtWPfwjqhlH2RBNSffqBuKE5MakMN8aRo6uxYp48HX eK+Q== X-Gm-Message-State: AOAM530bPHJsVKM9YwOMCrxErzJZxlkwY7HFAk5AYXPgybr31dLEVRAk 2awbwSYXg0UEa28DGeUFTYA= X-Received: by 2002:a17:90b:692:: with SMTP id m18mr4389199pjz.39.1589559854562; Fri, 15 May 2020 09:24:14 -0700 (PDT) Received: from localhost ([2409:10:2e40:5100:6e29:95ff:fe2d:8f34]) by smtp.gmail.com with ESMTPSA id j23sm1914714pjz.13.2020.05.15.09.24.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2020 09:24:13 -0700 (PDT) From: Sergey Senozhatsky X-Google-Original-From: Sergey Senozhatsky Date: Sat, 16 May 2020 01:24:11 +0900 To: Daniel Thompson Cc: Sergey Senozhatsky , Petr Mladek , Sumit Garg , Jason Wessel , Douglas Anderson , kgdb-bugreport@lists.sourceforge.net, Linux Kernel Mailing List , Arnd Bergmann , Andrew Morton , Peter Zijlstra , Steven Rostedt , John Ogness Subject: Re: [PATCH] printk/kdb: Redirect printk messages into kdb in any context Message-ID: <20200515162411.GG42471@jagdpanzerIV.localdomain> References: <1589273314-12060-1-git-send-email-sumit.garg@linaro.org> <20200512142533.ta4uejwmq5gchtlx@holly.lan> <20200514084230.GO17734@linux-b0ei> <20200515085021.GS17734@linux-b0ei> <20200515103308.GD42471@jagdpanzerIV.localdomain> <20200515134806.5cw4xxnxw7k3223l@holly.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200515134806.5cw4xxnxw7k3223l@holly.lan> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (20/05/15 14:48), Daniel Thompson wrote: > On Fri, May 15, 2020 at 07:33:08PM +0900, Sergey Senozhatsky wrote: > > On (20/05/15 10:50), Petr Mladek wrote: [..] > > Is this guaranteed that we never execute this path from NMI? > > Absolutely not. > > The execution context for kdb is pretty much unique... OK, that was what I expected. > we are running a debug mode with all CPUs parked in a holding loop with > interrupts disabled. One CPU is at an unknown exception state and the > others are either handling an IRQ or NMI depending on architecture[1]. Can a CPU be parked while holding the console driver port lock? Hmm, a side note - this also means that we cannot handle it from poll-ing console drivers and need to switch to direct console writes. > However there are a number of factors that IMHO weigh in favour of > allowing kdb to intercept here. > > 1. kgdb/kdb are designed to work from NMI, modulo the bugs that are > undoubtedly present. > > 2. A synchronous breakpoint (including an implicit breakpoint-on-oops) > from any code that executes with irqs disabled will exhibit most of > the same problems as an NMI but without waking up all the NMI logic. > > 3. kdb_trap_printk is only set for *very* narrow time intervals by the > debug master (the single CPU in the system that is *not* in a > holding loop). Thus in all cases the system has already successfully > executed kdb_printf() several times before we ever call the printk() > interception code. > > Or put another way, even if we did tickle a bug speculated about in > #1, it won't be the call to printk() that triggers it; we'd never > get that far! OK. I would appreciate a more detailed commit message: - what do we fix, and what risks do we take. Just for the record. + a small nit: looking at for_each_console() loop -- not all consoles can be invoked at any time and not all consoles are enabled at any time. You _probably_ might want to do what printk does in call_console_drivers() loop. printk also had problems with console callbacks being placed in sections that get discarded, but that's way too niche. -ss