From: Jiri Slaby <jslaby@suse.cz>
To: linux-kernel@vger.kernel.org
Cc: jirislaby@gmail.com, Vojtech Pavlik <vojtech@suse.cz>,
Jiri Kosina <jkosina@suse.cz>, Jiri Slaby <jslaby@suse.cz>,
Michael Matz <matz@suse.de>, Steven Rostedt <rostedt@goodmis.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Ingo Molnar <mingo@redhat.com>
Subject: [PATCH 13/21] kgr: x86: refuse to build without fentry support
Date: Mon, 23 Jun 2014 15:29:27 +0200 [thread overview]
Message-ID: <1403530175-29217-13-git-send-email-jslaby@suse.cz> (raw)
In-Reply-To: <1403530175-29217-1-git-send-email-jslaby@suse.cz>
From: Jiri Kosina <jkosina@suse.cz>
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>
---
arch/x86/include/asm/kgraft.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/x86/include/asm/kgraft.h b/arch/x86/include/asm/kgraft.h
index 5e40ba1a0753..6fc57a85d12c 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)
--
2.0.0
next prev parent reply other threads:[~2014-06-23 13:29 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-23 13:29 [PATCH 01/21] ftrace: Add function to find fentry of function Jiri Slaby
2014-06-23 13:29 ` [PATCH 02/21] ftrace: Make ftrace_is_dead available globally Jiri Slaby
2014-06-23 13:29 ` [PATCH 03/21] kgr: initial code Jiri Slaby
2014-06-23 13:29 ` [PATCH 04/21] kgr: add testing kgraft patch Jiri Slaby
2014-06-23 13:29 ` [PATCH 05/21] kgr: update Kconfig documentation Jiri Slaby
2014-06-23 13:29 ` [PATCH 06/21] kgr: add Documentation Jiri Slaby
2014-06-23 13:29 ` [PATCH 07/21] kgr: trigger the first check earlier Jiri Slaby
2014-06-23 13:29 ` [PATCH 08/21] kgr: sched.h, introduce kgr_task_safe helper Jiri Slaby
2014-06-23 13:29 ` [PATCH 09/21] kgr: mark task_safe in some kthreads Jiri Slaby
2014-06-23 13:29 ` [PATCH 10/21] kgr: kthreads support Jiri Slaby
2014-06-23 13:29 ` [PATCH 11/21] kgr: handle irqs Jiri Slaby
2014-06-23 13:29 ` [PATCH 12/21] kgr: add MAINTAINERS entry Jiri Slaby
2014-06-23 13:29 ` Jiri Slaby [this message]
2014-06-23 13:29 ` [PATCH 14/21] kgr: add procfs interface for per-process 'kgr_in_progress' Jiri Slaby
2014-06-23 13:29 ` [PATCH 15/21] kgr: make a per-process 'in progress' flag a single bit Jiri Slaby
2014-06-23 13:29 ` [PATCH 16/21] kgr: add support for missing functions Jiri Slaby
2014-06-23 13:29 ` [PATCH 17/21] kgr: exercise non-present function Jiri Slaby
2014-06-23 13:29 ` [PATCH 18/21] kgr: fix race of stub and patching Jiri Slaby
2014-06-23 13:29 ` [PATCH 19/21] kgr: expose global 'in_progress' state through procfs Jiri Slaby
2014-06-23 13:29 ` [PATCH 20/21] kgr: rephrase the "kGraft failed" message Jiri Slaby
2014-06-23 13:29 ` [PATCH 21/21] kgr: x86: optimize handling of CPU-bound tasks Jiri Slaby
2014-06-23 13:51 ` [PATCH 00/21] kGraft Jiri Slaby
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1403530175-29217-13-git-send-email-jslaby@suse.cz \
--to=jslaby@suse.cz \
--cc=fweisbec@gmail.com \
--cc=jirislaby@gmail.com \
--cc=jkosina@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=matz@suse.de \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
--cc=vojtech@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®