* [PATCH] x86/traps: add CONFIG_BUG to the use of __warn() @ 2022-04-25 5:59 Stephen Zhang 2022-04-25 16:05 ` Dave Hansen 0 siblings, 1 reply; 5+ messages in thread From: Stephen Zhang @ 2022-04-25 5:59 UTC (permalink / raw) To: tglx, mingo, bp, dave.hansen, x86 Cc: hpa, peterz, laijs, lihuafei1, fenghua.yu, chang.seok.bae, zhangshida, linux-kernel From: zhangshida <zhangshida@kylinos.cn> __warn() is declared when CONFIG_BUG is defined, so add CONFIG_BUG when used. Signed-off-by: zhangshida <zhangshida@kylinos.cn> --- arch/x86/kernel/traps.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index 1563fb995005..81cc28a59c24 100644 --- 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 return; } BUG(); -- 2.25.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] x86/traps: add CONFIG_BUG to the use of __warn() 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 0 siblings, 1 reply; 5+ messages in thread From: Dave Hansen @ 2022-04-25 16:05 UTC (permalink / raw) To: Stephen Zhang, tglx, mingo, bp, dave.hansen, x86 Cc: hpa, peterz, laijs, lihuafei1, fenghua.yu, chang.seok.bae, zhangshida, linux-kernel 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. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86/traps: add CONFIG_BUG to the use of __warn() 2022-04-25 16:05 ` Dave Hansen @ 2022-04-25 18:24 ` Peter Zijlstra 2022-04-25 19:28 ` Peter Zijlstra 0 siblings, 1 reply; 5+ messages in thread From: Peter Zijlstra @ 2022-04-25 18:24 UTC (permalink / raw) To: Dave Hansen Cc: Stephen Zhang, tglx, mingo, bp, dave.hansen, x86, hpa, laijs, lihuafei1, fenghua.yu, chang.seok.bae, zhangshida, linux-kernel 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. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86/traps: add CONFIG_BUG to the use of __warn() 2022-04-25 18:24 ` Peter Zijlstra @ 2022-04-25 19:28 ` Peter Zijlstra 2022-04-26 1:23 ` Stephen Zhang 0 siblings, 1 reply; 5+ messages in thread From: Peter Zijlstra @ 2022-04-25 19:28 UTC (permalink / raw) To: Dave Hansen Cc: Stephen Zhang, tglx, mingo, bp, dave.hansen, x86, hpa, laijs, lihuafei1, fenghua.yu, chang.seok.bae, zhangshida, linux-kernel 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) ({ \ ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] x86/traps: add CONFIG_BUG to the use of __warn() 2022-04-25 19:28 ` Peter Zijlstra @ 2022-04-26 1:23 ` Stephen Zhang 0 siblings, 0 replies; 5+ messages in thread From: Stephen Zhang @ 2022-04-26 1:23 UTC (permalink / raw) To: Peter Zijlstra Cc: Dave Hansen, tglx, mingo, bp, dave.hansen, x86, hpa, laijs, lihuafei1, fenghua.yu, chang.seok.bae, zhangshida, linux-kernel > 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) ({ \ Thanks.I will make a new version based on this suggestion. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-04-26 1:24 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 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 2022-04-26 1:23 ` Stephen Zhang
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).