[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAPhsuW6V-Scxv0yqyxmGW7e5XHmkSsHuSCdQ2qfKVbHpqu92xg@mail.gmail.com>
Date: Tue, 3 Sep 2024 10:32:00 -0700
From: Song Liu <song@...nel.org>
To: Josh Poimboeuf <jpoimboe@...nel.org>
Cc: live-patching@...r.kernel.org, linux-kernel@...r.kernel.org,
x86@...nel.org, Miroslav Benes <mbenes@...e.cz>, Petr Mladek <pmladek@...e.com>,
Joe Lawrence <joe.lawrence@...hat.com>, Jiri Kosina <jikos@...nel.org>,
Peter Zijlstra <peterz@...radead.org>, Marcos Paulo de Souza <mpdesouza@...e.com>
Subject: Re: [RFC 00/31] objtool, livepatch: Livepatch module generation
Hi Josh,
Thanks for the patchset! We really need this work so that we can undo our
hack for LTO enabled kernels.
On Mon, Sep 2, 2024 at 9:00 PM Josh Poimboeuf <jpoimboe@...nel.org> wrote:
>
> Hi,
>
> Here's a new way to build livepatch modules called klp-build.
>
> I started working on it when I realized that objtool already does 99% of
> the work needed for detecting function changes.
>
> This is similar in concept to kpatch-build, but the implementation is
> much cleaner.
>
> Personally I still have reservations about the "source-based" approach
> (klp-convert and friends), including the fragility and performance
> concerns of -flive-patching. I would submit that klp-build might be
> considered the "official" way to make livepatch modules.
>
> Please try it out and let me know what you think. Based on v6.10.
>
> Also avaiable at:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/jpoimboe/linux.git klp-build-rfc
I tried to compile the code in this branch with gcc-12 and llvm-18. Some
of these errors are easy to fix (attached below). But some are trickier, for
example:
with gcc-12:
...
BTFIDS vmlinux
NM System.map
SORTTAB vmlinux
incomplete ORC unwind tables in file: vmlinux
Failed to sort kernel tables
with clang-18:
<instantiation>:4:1: error: symbol '__alt_0' is already defined
4 | __alt_0:
| ^
<instantiation>:4:1: error: symbol '__alt_1' is already defined
4 | __alt_1:
| ^
Thanks,
Song
Fix/hack I have on top of this branch:
diff --git i/tools/objtool/check.c w/tools/objtool/check.c
index f55dec2932de..5c4152d60780 100644
--- i/tools/objtool/check.c
+++ w/tools/objtool/check.c
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2015-2017 Josh Poimboeuf <jpoimboe@...hat.com>
*/
-
+#define _GNU_SOURCE
#include <string.h>
#include <stdlib.h>
#include <inttypes.h>
@@ -1519,7 +1519,7 @@ static void add_jump_destinations(struct
objtool_file *file)
struct reloc *reloc;
for_each_insn(file, insn) {
- struct instruction *dest_insn;
+ struct instruction *dest_insn = NULL;
struct section *dest_sec = NULL;
struct symbol *dest_sym = NULL;
unsigned long dest_off;
diff --git i/tools/objtool/elf.c w/tools/objtool/elf.c
index 7960921996bd..462ce897ff29 100644
--- i/tools/objtool/elf.c
+++ w/tools/objtool/elf.c
@@ -468,10 +468,8 @@ static void elf_add_symbol(struct elf *elf,
struct symbol *sym)
*
* TODO: is this still true?
*/
-#if 0
- if (sym->type == STT_NOTYPE && !sym->len)
+ if (sym->type == STT_NOTYPE && !sym->len && false)
__sym_remove(sym, &sym->sec->symbol_tree);
-#endif
sym->demangled_name = demangle_name(sym);
}
diff --git i/tools/objtool/klp-diff.c w/tools/objtool/klp-diff.c
index 76296e38f9ff..4a3f4172f4a5 100644
--- i/tools/objtool/klp-diff.c
+++ w/tools/objtool/klp-diff.c
@@ -2,6 +2,7 @@
/*
* Copyright (C) 2024 Josh Poimboeuf <jpoimboe@...nel.org>
*/
+#define _GNU_SOURCE
#include <libgen.h>
#include <stdio.h>
#include <objtool/objtool.h>
@@ -1109,4 +1110,3 @@ int cmd_klp_diff(int argc, const char **argv)
elf_write(elf_out);
return 0;
}
-
Powered by blists - more mailing lists