x86/uaccess, ftrace: Fix ftrace_likely_update() vs. SMAP

[ Upstream commit 4a6c91fbdef846ec7250b82f2eeeb87ac5f18cf9 ]

For CONFIG_TRACE_BRANCH_PROFILING=y the likely/unlikely things get
overloaded and generate callouts to this code, and thus also when
AC=1.

Make it safe.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Peter Zijlstra 2019-03-07 11:09:13 +01:00 committed by Greg Kroah-Hartman
parent da30c277c4
commit 1a3188d737

View file

@ -205,6 +205,8 @@ void trace_likely_condition(struct ftrace_likely_data *f, int val, int expect)
void ftrace_likely_update(struct ftrace_likely_data *f, int val, void ftrace_likely_update(struct ftrace_likely_data *f, int val,
int expect, int is_constant) int expect, int is_constant)
{ {
unsigned long flags = user_access_save();
/* A constant is always correct */ /* A constant is always correct */
if (is_constant) { if (is_constant) {
f->constant++; f->constant++;
@ -223,6 +225,8 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
f->data.correct++; f->data.correct++;
else else
f->data.incorrect++; f->data.incorrect++;
user_access_restore(flags);
} }
EXPORT_SYMBOL(ftrace_likely_update); EXPORT_SYMBOL(ftrace_likely_update);