Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2545719rdh; Wed, 27 Sep 2023 06:05:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFajC2mzGJn3s7cyBEGWW+2AyryFxBQxYO6nuT9HfNfx+VfHrYmSw7wmZVAiwkqxArqDfg2 X-Received: by 2002:a05:6a00:1ac7:b0:68e:41e9:10be with SMTP id f7-20020a056a001ac700b0068e41e910bemr2159295pfv.20.1695819914605; Wed, 27 Sep 2023 06:05:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695819914; cv=none; d=google.com; s=arc-20160816; b=gQ6kd8pOemdYcUlYE/b9jzVNk20KELKlphTE+5yc3/XvVFWiLo2LLyrEKzlzYs3oBK VV+d2SfpmIL1yNfgMFZsMJ6UGAO64u4V6ZdrXs2Nt3LBhZjWC0iuWqy1Fapm70MuHhjf aS9w7NLWJhmyQOooj1Do2MYv5258pdHW+DZeHxSNvxJqJQDPh5vChHwjIBQY2RWX3O8A VilE3nNREy58TOpULhXi3kf2Cd8+8Mj09sMFqvt7Gkc1piGvTeVs/cZAJy/s98sI7AXl ZHl3WOsIGR+TDpdmg0e42x1yWRAJqaKc/gnGQ+yJcejEFicy6qfQuG+C6VIQj1/eRkj6 0sgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=KTfs5yhlTCE0o2SXh5aaYXX3rf4gvBwg1JvGvr+LWu0=; fh=7kNYB8Is7zRQnEEv56zEyvp6OFJiQ8ccfhadECgaJ2A=; b=yQcTEmc6jhN6SK/MThCGcbYF7PmB/xHSl+TyU2HvMNA4w4tSTxPXbnSnqnwIzU/ThC ogPaTM+Zq0Kr6Iv2/DdFCe0EqcipgiI0mY3WelHC9MANAO/kycqHzZf465+lBreTOKmM VzEW82/7xr9NLjHia4tbJybMHb5DQ9xfaxFLnFFJRP6NhHGH4SoC4L8IRRoBeRQG7jO9 AFBFsleuTviQIbqw7vKOefBkgM72sUiQkWgfCKQYoo0/MqBzjECnRdJTJYB9uAFdCf7+ 9Dv6nn2pwjQptGPEBzOY/GGAHxNgFL/Nm8/Ooq7yMXALKcNzP4FY8TAlbg+aXor6nEPV PzFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=DnSiAjjZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id z14-20020a056a001d8e00b00690c23d353asi15462472pfw.217.2023.09.27.06.05.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 06:05:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=DnSiAjjZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 2333D825ED86; Wed, 27 Sep 2023 05:02:45 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230496AbjI0MCX (ORCPT + 99 others); Wed, 27 Sep 2023 08:02:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229901AbjI0MCW (ORCPT ); Wed, 27 Sep 2023 08:02:22 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2AF012A for ; Wed, 27 Sep 2023 05:02:20 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 75E081F88F; Wed, 27 Sep 2023 12:02:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1695816139; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=KTfs5yhlTCE0o2SXh5aaYXX3rf4gvBwg1JvGvr+LWu0=; b=DnSiAjjZuQTTj/CXNknIWTwmVKSVt+USmsNxtwCRXOFOMBIQRyOA4Lsgeqi3Bx1OVwRYhF wqQixbUJdiydkqyv5nEiNxxT7G2vfmx6R54rpr4XvI2ZEIa8E2kITKOQejvIywOWPSYVl1 HkMCGmwEtSgW0oIxctaR8RCwauPhjSE= Received: from suse.cz (pmladek.udp.ovpn2.prg.suse.de [10.100.201.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id D9F262C142; Wed, 27 Sep 2023 12:02:18 +0000 (UTC) Date: Wed, 27 Sep 2023 14:02:17 +0200 From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Kees Cook , Luis Chamberlain , Andrew Morton , Peter Zijlstra , Josh Poimboeuf , Andy Shevchenko , "Guilherme G. Piccoli" , Arnd Bergmann Subject: Re: [PATCH printk v2 08/11] panic: Add atomic write enforcement to warn/panic Message-ID: References: <20230919230856.661435-1-john.ogness@linutronix.de> <20230919230856.661435-9-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230919230856.661435-9-john.ogness@linutronix.de> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 27 Sep 2023 05:02:45 -0700 (PDT) On Wed 2023-09-20 01:14:53, John Ogness wrote: > From: Thomas Gleixner > > Invoke the atomic write enforcement functions for warn/panic to > ensure that the information gets out to the consoles. > > For the panic case, add explicit intermediate atomic flush > calls to ensure immediate flushing at important points. > Otherwise the atomic flushing only occurs when dropping out of > the elevated priority, which for panic may never happen. It would be great to avoid the need for the explicit flushes except for the final unsafe one. Otherwise, we would play another Whack-a-mole game. People would report that panic() failed and they needed to add another explicit flush to find the culprit... > It is important to note that if there are any legacy consoles > registered, they will be attempting to directly print from the > printk-caller context, which may jeopardize the reliability of > the atomic consoles. Optimally there should be no legacy > consoles registered. > --- a/kernel/panic.c > +++ b/kernel/panic.c > @@ -275,6 +275,7 @@ static void panic_other_cpus_shutdown(bool crash_kexec) > */ > void panic(const char *fmt, ...) > { > + enum nbcon_prio prev_prio; > static char buf[1024]; > va_list args; > long i, i_next = 0, len; > @@ -322,6 +323,8 @@ void panic(const char *fmt, ...) > if (old_cpu != PANIC_CPU_INVALID && old_cpu != this_cpu) > panic_smp_self_stop(); > > + prev_prio = nbcon_atomic_enter(NBCON_PRIO_PANIC); > + It would make sense to flush nbcon consoles the safe way at this point before we allow dangerous games for legacy consoles via bust_spinlock(). > console_verbose(); > bust_spinlocks(1); > va_start(args, fmt); > @@ -382,6 +385,8 @@ void panic(const char *fmt, ...) > if (_crash_kexec_post_notifiers) > __crash_kexec(NULL); > > + nbcon_atomic_flush_all(); There should be one more safe flush after dump_stack() just in case the kexec fails. The legacy consoles also tried to flush the consoles in each called printk(). ... I do not want to review or comment each added or needed nbcon_atomic_flush_all(). I hope that they won't be needed in the end. Best Regards, Petr