History

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.

Jiri Kosina committed 11 years ago

Commit b9dfe0b1 parent 83ac2372 files · +11 −1Browse files

Unified · Split

2 files
  1. arch/x86/include/asm/livepatch.h +5 −1
  2. kernel/livepatch/core.c +6 −0
arch/x86/include/asm/livepatch.h+5−1
@@ -25,9 +25,13 @@ · 24 unmodified lines
2525 #include <linux/ftrace.h>
2626
2727 #ifdef CONFIG_LIVE_PATCHING
28+static inline int klp_check_compiler_support(void)
29+{
2830 #ifndef CC_USING_FENTRY
29−#error Your compiler must support -mfentry for live patching to work
31+ return 1;
3032 #endif
33+ return 0;
34+}
3135 extern int klp_write_module_reloc(struct module *mod, unsigned long type,
3236 unsigned long loc, unsigned long value);
3337
kernel/livepatch/core.c+6−0
@@ -911,6 +911,12 @@ static int klp_init(void) · 910 unmodified lines
911911 {
912912 int ret;
913913
914+ ret = klp_check_compiler_support();
915+ if (ret) {
916+ pr_info("Your compiler is too old; turning off.\n");
917+ return -EINVAL;
918+ }
919+
914920 ret = register_module_notifier(&klp_module_nb);
915921 if (ret)
916922 return ret;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t