Subject: Re: mmotm 2020-05-13-20-30 uploaded (objtool warnings)

From: Peter Zijlstra <[email-masked]>
Date: Fri, 29 May 2020 18:12:53 +0200

On Fri, May 29, 2020 at 11:05:14AM -0500, Josh Poimboeuf wrote:

> It looks to me like GCC is doing the right thing.  That likely()
> translates to:
> 
> #  define likely(x)	(__branch_check__(x, 1, __builtin_constant_p(x)))
> 
> which becomes:
> 
> #define __branch_check__(x, expect, is_constant) ({			\
> 			long ______r;					\
> 			static struct ftrace_likely_data		\
> 				__aligned(4)				\
> 				__section(_ftrace_annotated_branch)	\
> 				______f = {				\
> 				.data.func = __func__,			\
> 				.data.file = __FILE__,			\
> 				.data.line = __LINE__,			\
> 			};						\
> 			______r = __builtin_expect(!!(x), expect);	\
> 			ftrace_likely_update(&______f, ______r,		\
> 					     expect, is_constant);	\
> 			______r;					\
> 		})
> 
> Here 'x' is the call to user_access_begin().  It evaluates 'x' -- and
> thus calls user_access_begin() -- before the call to
> ftrace_likely_update().
> 
> So it's working as designed, right?  The likely() just needs to be
> changed to likely_notrace().

But if !x (ie we fail user_access_begin()), we should not pass STAC() on
the way to out_err. OTOH if x, we should not be jumping to out_err.

I'm most confused... must not stare at asm for a while.