Re: [RFC 00/31] objtool, livepatch: Livepatch module generation

Josh Poimboeuf
2024-09-04T07:09:54Z

On Tue, Sep 03, 2024 at 11:37:39PM -0700, Josh Poimboeuf wrote:
> On Tue, Sep 03, 2024 at 10:26:02PM -0700, Song Liu wrote:
> > Hi Josh,
> >
> > I have attached the config I used for LLVM and gcc.
>
> !IBT is triggering the ORC bug. This should fix it:

Also a CONFIG_MODVERSIONS fix:

diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index 518c70b8db50..643bfba65d48 100755
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -60,7 +60,8 @@ vmlinux_link()
# skip output file argument
shift

- if is_enabled CONFIG_LTO_CLANG || is_enabled CONFIG_X86_KERNEL_IBT; then
+ if is_enabled CONFIG_LTO_CLANG || is_enabled CONFIG_X86_KERNEL_IBT ||
+ is_enabled CONFIG_LIVEPATCH; then
# Use vmlinux.o instead of performing the slow LTO link again.
objs=vmlinux.o
libs=
diff --git a/scripts/livepatch/klp-build b/scripts/livepatch/klp-build
index e16584a4b697..385acb955861 100755
--- a/scripts/livepatch/klp-build
+++ b/scripts/livepatch/klp-build
@@ -234,6 +234,10 @@ diff_objects() {
# status "diff: $rel_file"

"$SRC/tools/objtool/objtool" klp diff "$orig" "$patched" "$output" || die "objtool klp diff failed"
+
+ if [[ $(basename "$output") = "vmlinux.o" ]] && [[ -e .vmlinux.o.cmd ]]; then
+ cp -f .vmlinux.o.cmd "$OUTPUT_DIR"
+ fi
done < <(find "$BUILD_DIR" -type f \( -name vmlinux.o -o -name "*.ko" \) -newer "$timestamp")

local nr_objs="$(find "$OUTPUT_DIR" -type f \( -name vmlinux.o -o -name "*.ko" \) | wc -l)"