Commit b9dfe0be authored by Jiri Kosina's avatar Jiri Kosina

livepatch: handle ancient compilers with more grace

We are aborting a build in case when gcc doesn't support fentry on x86_64
(regs->ip modification can't really reliably work with mcount).

This however breaks allmodconfig for people with older gccs that don't
support -mfentry.

Turn the build-time failure into runtime failure, resulting in the whole
infrastructure not being initialized if CC_USING_FENTRY is unset.
Reported-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Acked-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
parent 83ac237a
...@@ -25,9 +25,13 @@ ...@@ -25,9 +25,13 @@
#include <linux/ftrace.h> #include <linux/ftrace.h>
#ifdef CONFIG_LIVE_PATCHING #ifdef CONFIG_LIVE_PATCHING
static inline int klp_check_compiler_support(void)
{
#ifndef CC_USING_FENTRY #ifndef CC_USING_FENTRY
#error Your compiler must support -mfentry for live patching to work return 1;
#endif #endif
return 0;
}
extern int klp_write_module_reloc(struct module *mod, unsigned long type, extern int klp_write_module_reloc(struct module *mod, unsigned long type,
unsigned long loc, unsigned long value); unsigned long loc, unsigned long value);
......
...@@ -911,6 +911,12 @@ static int klp_init(void) ...@@ -911,6 +911,12 @@ static int klp_init(void)
{ {
int ret; int ret;
ret = klp_check_compiler_support();
if (ret) {
pr_info("Your compiler is too old; turning off.\n");
return -EINVAL;
}
ret = register_module_notifier(&klp_module_nb); ret = register_module_notifier(&klp_module_nb);
if (ret) if (ret)
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment