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));

Thanks,

        tglx

Reply via email to