aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2014-04-18 14:47:13 +0200
committerJiri Slaby <jslaby@suse.cz>2014-09-12 10:15:19 +0200
commitbd4bc097c72937d18036f1312a4d79ed0bea9991 (patch)
tree88210b9d5de19359079b546b055d9cb53891c68c
parent050534532d2fdacfe5233c56ab6dc04c36612638 (diff)
downloadkgraft-bd4bc097c72937d18036f1312a4d79ed0bea9991.tar.gz
kgr: x86: refuse to build without fentry support
The only reliable way for function redirection through ftrace_ops (when modifying pt_regs->rip in the handler) is fentry. The alternative -- mcount -- is problematic in several ways. Namely the caller's function prologue (that has already been executed by the time mcount callsite has been reached) is not known to the callee, and can be completely incompatible to the calee, resulting in a havoc on return from the function. fentry doesn't suffer from this, as it's located at the very beginning of the function, even before prologue has been executed, and therefore callee is the owner of both function prologue and epilogue. Fixing mcount to properly fix everything up would be non-trivial, and Steven is not in favor of doing that. Both kGraft and upstream kernel (patch to be submitted) should error out when this unsupported and non-working configuration is detected. According to Michael Matz, the -mfentry gcc option is x86 specific. Other architectures insert the respective profile calls before the prologue by default. Signed-off-by: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Michael Matz <matz@suse.de> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@redhat.com>
-rw-r--r--arch/x86/include/asm/kgraft.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/arch/x86/include/asm/kgraft.h b/arch/x86/include/asm/kgraft.h
index 5e40ba1a0753c..6fc57a85d12cc 100644
--- a/arch/x86/include/asm/kgraft.h
+++ b/arch/x86/include/asm/kgraft.h
@@ -17,6 +17,10 @@
#ifndef ASM_KGR_H
#define ASM_KGR_H
+#ifndef CC_USING_FENTRY
+#error Your compiler has to support -mfentry for kGraft to work on x86
+#endif
+
#include <asm/ptrace.h>
static inline void kgr_set_regs_ip(struct pt_regs *regs, unsigned long ip)