Re: [PATCH] x86/traps: add CONFIG_BUG to the use of __warn()

From: Peter Zijlstra
Date: Mon Apr 25 2022 - 14:25:59 EST


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.