Messages in this thread | | | From | Thomas Gleixner <> | Subject | Re: [PATCH v4 7/9] kentry: Add debugging checks for proper kentry API usage | Date | Fri, 19 Mar 2021 19:16:48 +0100 |
| |
On Fri, Mar 19 2021 at 17:17, Thomas Gleixner wrote:
> On Wed, Mar 17 2021 at 11:12, Andy Lutomirski wrote: >> + >> +#define DEBUG_ENTRY_WARN_ONCE(condition, format...) do {} while (0) > > So we have a stub for !DEBUG > >> +static __always_inline void kentry_cpu_depth_add(unsigned int n) {} >> +static void kentry_cpu_depth_check(unsigned int n) {} >> +static __always_inline void kentry_cpu_depth_sub(unsigned int n) {} >> + >> +#endif >> + >> /* See comment for enter_from_user_mode() in entry-common.h */ >> static __always_inline void __enter_from_user_mode(struct pt_regs *regs) >> { >> + kentry_cpu_depth_add(1); >> arch_check_user_regs(regs); >> lockdep_hardirqs_off(CALLER_ADDR0); >> >> @@ -22,6 +78,14 @@ static __always_inline void __enter_from_user_mode(struct pt_regs *regs) >> >> instrumentation_begin(); >> trace_hardirqs_off_finish(); >> + >> +#ifdef CONFIG_DEBUG_ENTRY > > Why do we need that #ifdeffery all over the place? > >> + DEBUG_ENTRY_WARN_ONCE( >> + this_cpu_read(kentry_cpu_depth) != 1, >> + "kentry: __enter_from_user_mode() called while kentry thought the CPU was in the kernel (%u)", >> + this_cpu_read(kentry_cpu_depth));
Because you directly access kentry_cpu_depth which makes the compiler unhappy.
And of course at the other place where you guard it with IS_ENABLED() it fails to build with CONFIG_DEBUG_ENTRY=n
kernel/entry/common.c:158:10: error: ‘struct task_struct’ has no member named ‘kentry_in_syscall’ current->kentry_in_syscall = true;
This is V4 of this series... Oh well.
tglx
| |