All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Dave Hansen <dave.hansen@intel.com>
Cc: Stephen Zhang <starzhangzsd@gmail.com>,
	tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
	dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com,
	laijs@linux.alibaba.com, lihuafei1@huawei.com,
	fenghua.yu@intel.com, chang.seok.bae@intel.com,
	zhangshida@kylinos.cn, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86/traps: add CONFIG_BUG to the use of __warn()
Date: Mon, 25 Apr 2022 21:28:56 +0200	[thread overview]
Message-ID: <20220425192856.GG2762@worktop.programming.kicks-ass.net> (raw)
In-Reply-To: <20220425182456.GL2731@worktop.programming.kicks-ass.net>

On Mon, Apr 25, 2022 at 08:24:56PM +0200, Peter Zijlstra wrote:
> On Mon, Apr 25, 2022 at 09:05:17AM -0700, Dave Hansen wrote:
> > On 4/24/22 22:59, Stephen Zhang wrote:
> > > --- a/arch/x86/kernel/traps.c
> > > +++ b/arch/x86/kernel/traps.c
> > > @@ -246,7 +246,9 @@ DEFINE_IDTENTRY_ERRORCODE(exc_control_protection)
> > >  	pr_err("Missing ENDBR: %pS\n", (void *)instruction_pointer(regs));
> > >  	if (!ibt_fatal) {
> > >  		printk(KERN_DEFAULT CUT_HERE);
> > > +#ifdef CONFIG_BUG
> > >  		__warn(__FILE__, __LINE__, (void *)regs->ip, TAINT_WARN, regs, NULL);
> > > +#endif
> > 
> > This really should be done with an #ifdef'd stub in in bug.h, not an
> > #ifdef at every call site.  I assume there was a good reason for not
> > using the normal WARN*() macros.
> 
> I think the idea was to have the pr_err() unconditional, and if you have
> the fancy crap on also print a full backtrace or something.
> 
> But yeah, a few stubs in bug.h ought to make this go away too.

As pointed out by Boris, __warn is actually uncondtionally defined in
panic.c, the below seems to build.

---
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index edb0e2a602a8..ba1f860af38b 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -21,6 +21,12 @@
 #include <linux/panic.h>
 #include <linux/printk.h>
 
+struct warn_args;
+struct pt_regs;
+
+void __warn(const char *file, int line, void *caller, unsigned taint,
+	    struct pt_regs *regs, struct warn_args *args);
+
 #ifdef CONFIG_BUG
 
 #ifdef CONFIG_GENERIC_BUG
@@ -110,11 +116,6 @@ extern __printf(1, 2) void __warn_printk(const char *fmt, ...);
 #endif
 
 /* used internally by panic.c */
-struct warn_args;
-struct pt_regs;
-
-void __warn(const char *file, int line, void *caller, unsigned taint,
-	    struct pt_regs *regs, struct warn_args *args);
 
 #ifndef WARN_ON
 #define WARN_ON(condition) ({						\

  reply	other threads:[~2022-04-25 19:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-25  5:59 [PATCH] x86/traps: add CONFIG_BUG to the use of __warn() Stephen Zhang
2022-04-25 16:05 ` Dave Hansen
2022-04-25 18:24   ` Peter Zijlstra
2022-04-25 19:28     ` Peter Zijlstra [this message]
2022-04-26  1:23       ` Stephen Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220425192856.GG2762@worktop.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=bp@alien8.de \
    --cc=chang.seok.bae@intel.com \
    --cc=dave.hansen@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=fenghua.yu@intel.com \
    --cc=hpa@zytor.com \
    --cc=laijs@linux.alibaba.com \
    --cc=lihuafei1@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=starzhangzsd@gmail.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=zhangshida@kylinos.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.