Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp520593ybk; Fri, 15 May 2020 06:52:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxl69YOM0Cd5AnPEvm42CpUp7yVhSBk24dbgdiHhtQTtZbKYeg6u6Qrs0JlfOM7O21HpVJT X-Received: by 2002:a17:906:4a8b:: with SMTP id x11mr2978360eju.107.1589550726744; Fri, 15 May 2020 06:52:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589550726; cv=none; d=google.com; s=arc-20160816; b=oPZY5+3Xtt/Tt2M6kd8J+Ps7uCcTd0pScdZDigEmt5F5B82HbRPkzWgLqJK34hjBld Y+G6O1UTGGzbRfwWbaZKIloKfEUUSaCh0XKrf0/xvguXSqOrHDofih0CG49m9ima8Z44 6JogK5RVDs4G/UOBvYcJ2iG954wgHtJVeEM31reVhRKXEs2tQBi64aGmBzteuj/ElOIs vBB5LoOKkbz1r7ywBlzfJfJeMZpUPIEVJQpHOoRJKZSy/PlBxOk71peiy4Zm6kd8by87 R0/X/6CskeRkS8fF6hV5fgU7tuoCfcFVjfaL17LZvqCSksGuqKDPmnJB9xH8wZCOroOp O+eQ== 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:from:date :dkim-signature; bh=3qkYfWFETK6zBf4wXa1Hi398hQXeE5GebQwhI+ncIdg=; b=PlsDqs8Sxb33Zg+HyokCNWmhRDlyb119Ul9B/Y1pK+igrMIEcLv1AMwtp6xfUDtmGL MorjpgR+1BIj9pUt9D7PeTB67dmqnmAvj22DneRQEX3w5saQZ0TdnK1+vuUwfbeBFPKo f08ossm6KxG94SbjECHC9KuYiL59vPIC6330PRYBStWWVCqHs0kCacpruFJVhzfJF0BX KarW7ja6+R5na4r2+AsUMla5wBosV8ACgn3vRe0fDueGfmi72AGhRsoqwzicaZ0FDD9u 7+dP8ZKApK/B1WPO+GdtpBvNJ+RyjmleCbNwjWUrrefGC7gD0irXVEpmmj63CHdoigVU VvFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eZtjbP6N; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z13si1219102eju.18.2020.05.15.06.51.43; Fri, 15 May 2020 06:52:06 -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=@linaro.org header.s=google header.b=eZtjbP6N; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726188AbgEONsU (ORCPT + 99 others); Fri, 15 May 2020 09:48:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726141AbgEONsU (ORCPT ); Fri, 15 May 2020 09:48:20 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0596FC061A0C for ; Fri, 15 May 2020 06:48:19 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id g12so2736839wmh.3 for ; Fri, 15 May 2020 06:48:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=3qkYfWFETK6zBf4wXa1Hi398hQXeE5GebQwhI+ncIdg=; b=eZtjbP6NRTFnwBBzAQ/7vAIDOd0g+tBLTmdd6At7C7aKYpemjjiVaON1bhVUUka4xC fdspZ0DuMKB3IXzMrf+3fR3wLygypG8KaN12CdmaGZQ2FmwH8pUXNlPKBbDgCvg+59/j zdeM6ghctOvVndEqGsVetE7otExcx/34sd2COmwwEw61Dpsn5VAnv01ICh9OtH7azKr5 zBESlD1TJsEj1W/APW4a22VPev9cTkzEPtO03frS2BuR/1czA3sk57k9hWopVbsnhyG9 wqtB3qgQZXTGqNyRM5daJvWnvCqQLbaNTpxQNJZCUtyDUArxuTHxqwaKZ6mT9iu9bYfs 5B3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=3qkYfWFETK6zBf4wXa1Hi398hQXeE5GebQwhI+ncIdg=; b=IQImSgb3xKmFszSSoOUj2fGfvtOEIEURklQrXOG+50HkHpO/1cC9vfVy8ayA9OFZmM e2uht1ewSUZyCnNyVpIimAkbwcLBFfjg94cImccDg8afM28YW/qwhj4cwgsL+QPuTKMG Bpw5r0wDdJxThaEhLZs9ut/zNA5ghz4W4lccHe6a2QZi5+q/vs5LwPnWLwyxfEMKV3d3 YNKkDGONmgZ6PCPZuHUPyyRIF2xaPKzTZ6nz/t/hHvLP4Wbjtobaom7SrUBV3KMVJbFx VCxNbdMG+usIgkGSmKu4JEdx7ntmyDxjXA1tLodxKE4KVRax8IFJi+4Poj8SLysnd9s3 6qvg== X-Gm-Message-State: AOAM530kn2eOUpdBPTAORbE2h8iU2V2087O43e5Ox/hu7Mc6tPzS8dXC MQnWl+B0sYp0LG6nqjy1gs3Yfw== X-Received: by 2002:a1c:a952:: with SMTP id s79mr4008010wme.153.1589550489338; Fri, 15 May 2020 06:48:09 -0700 (PDT) Received: from holly.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id s12sm3556478wmc.7.2020.05.15.06.48.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2020 06:48:08 -0700 (PDT) Date: Fri, 15 May 2020 14:48:06 +0100 From: Daniel Thompson To: Sergey Senozhatsky Cc: 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: <20200515134806.5cw4xxnxw7k3223l@holly.lan> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200515103308.GD42471@jagdpanzerIV.localdomain> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 15, 2020 at 07:33:08PM +0900, Sergey Senozhatsky wrote: > On (20/05/15 10:50), Petr Mladek wrote: > > kdb is able to stop kernel even in NMI context where printk() is redirected > > to the printk_safe() lockless variant. Move the check and redirect to kdb > > even in this case. > > Can I please have some context what problem does this solve? > I can see that vkdb_printf() calls into console drivers: > > for_each_console(c) { > c->write(c, cp, retlen - (cp - kdb_buffer)); > touch_nmi_watchdog(); > } > > Is this guaranteed that we never execute this path from NMI? Absolutely not. The execution context for kdb is pretty much unique... 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]. 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! > If so, can this please be added to the commit message? A more > detailed commit message will help a lot. I suspect Petr might prefer any future flames about kdb_printf() to be pointed at me rather than him ;-) so if adding anything to the commit message then I'd suggest it be based on the reasoning in #3 above. Daniel.