Skip to content

Conversation

@chenlei0x
Copy link

Hi,

I have tried to send this patch to mailing-list.

We are trying to add aarch64 support for kpatch.

kernel-patch directory contains the patch that should be applied to kernel(tested on 4.14)
User should do that before using kpatch.

Need your comments, thanks.

@jpoimboe
Copy link
Member

Thanks for sharing this @betacoo. The create-diff-object changes look reasonable. However, I don't think we want to support out-of-tree kernel patches. Also, kpatch.ko is pretty much deprecated in favor of CONFIG_LIVEPATCH upstream.

There has been some arm64 activity in the upstream kernel for livepatch and objtool. So hopefully Linux arm64 CONFIG_LIVEPATCH will be a reality in the near future. Then we can revisit these create-diff-object changes. At that point we will also need some integration and unit tests.

@joe-lawrence
Copy link
Contributor

Hi @betacoo, fwiw, the arm64-support.patch doesn't apply cleanly to upstream v4.14:

% git checkout v4.14
HEAD is now at bebc6082da0a Linux 4.14

% patch --dry-run -p1 < ~/src/kpatch/github-kpatch/kernel-patch/arm64-support.patch 
checking file arch/arm64/Kconfig
checking file arch/arm64/Makefile
Hunk #1 succeeded at 82 with fuzz 1 (offset -1 lines).
checking file arch/arm64/include/asm/ftrace.h
checking file arch/arm64/include/asm/module.h
Hunk #1 FAILED at 32.
1 out of 1 hunk FAILED
checking file arch/arm64/kernel/Makefile
checking file arch/arm64/kernel/arm64ksyms.c
checking file arch/arm64/kernel/entry-ftrace.S
Hunk #2 succeeded at 130 (offset 1 line).
Hunk #3 succeeded at 170 (offset 1 line).
Hunk #4 succeeded at 328 (offset 1 line).
checking file arch/arm64/kernel/ftrace.c
Hunk #2 FAILED at 110.
Hunk #3 FAILED at 130.
Hunk #4 succeeded at 165 (offset -2 lines).
Hunk #5 succeeded at 215 (offset -2 lines).
2 out of 5 hunks FAILED
checking file arch/arm64/kernel/module-plts.c
Hunk #1 FAILED at 190.
1 out of 1 hunk FAILED
checking file arch/arm64/kernel/module.c
checking file drivers/firmware/efi/libstub/Makefile
Hunk #1 FAILED at 11.
1 out of 1 hunk FAILED
checking file include/asm-generic/vmlinux.lds.h
can't find file to patch at input line 719
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
|index 4be464a..29aad2a 100644
|--- a/include/linux/compiler_types.h
|+++ b/include/linux/compiler_types.h
--------------------------
File to patch:

It looks like include/linux/compiler_types.h only goes back to v4.15. Is arm64-support.patch based on another upstream release or perhaps a distro-kernel?

@chenlei0x
Copy link
Author

Thanks for sharing this @betacoo. The create-diff-object changes look reasonable. However, I don't think we want to support out-of-tree kernel patches. Also, kpatch.ko is pretty much deprecated in favor of CONFIG_LIVEPATCH upstream.

There has been some arm64 activity in the upstream kernel for livepatch and objtool. So hopefully Linux arm64 CONFIG_LIVEPATCH will be a reality in the near future. Then we can revisit these create-diff-object changes. At that point we will also need some integration and unit tests.

@jpoimboe
Thanks for your review.
I know it's not a good way to maintain an Out-of-tree kernel patch. But it will work when a kernel runs without LIVEPATCH support.

It seems that I should close this PR....

@chenlei0x
Copy link
Author

Hi @joe-lawrence
I'm using 4.14.134 kernel version for testing.
This is the download link
https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.14.134.tar.xz

@joe-lawrence
Copy link
Contributor

Hi @joe-lawrence
I'm using 4.14.134 kernel version for testing.
This is the download link
https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.14.134.tar.xz

Thanks for the link to that specific stable kernel version. The patch now applies, however doesn't build for me:

arch/arm64/kernel/ftrace.c: In function ‘install_ftrace_trampoline’:
arch/arm64/kernel/ftrace.c:85:15: error: too many arguments to function ‘get_plt_entry’
  trampoline = get_plt_entry(*addr, mod_trampoline);
               ^~~~~~~~~~~~~
In file included from ./include/linux/module.h:24,
                 from arch/arm64/kernel/ftrace.c:13:
./arch/arm64/include/asm/module.h:64:32: note: declared here
 static inline struct plt_entry get_plt_entry(u64 val)
                                ^~~~~~~~~~~~~

Do I need to backport further patches to 4.14.134?

@chenlei0x
Copy link
Author

chenlei0x commented Aug 2, 2019

@joe-lawrence @jpoimboe
Sorry for the trouble.
This is our base kernel version, we have already back-ported many patches.
I have to admit that maintaining a kernel patch in this project is really ugly.
It's time to close this pr and dig into kernel live patch.

Thanks for your review.

@chenlei0x chenlei0x closed this Aug 2, 2019
keiya-nobuta added a commit to keiya-nobuta/kpatch that referenced this pull request Oct 6, 2021
This commit is still dirty, and is jumbling cut & pasted referring
to dynup#1010 and dynup#1206.
keiya-nobuta added a commit to keiya-nobuta/kpatch that referenced this pull request Oct 6, 2021
This commit is still dirty, and is jumbling cut & pasted referring
to dynup#1010 and dynup#1203.
keiya-nobuta added a commit to keiya-nobuta/kpatch that referenced this pull request Oct 6, 2021
This commit is still dirty because I'm jumbling cut & pasted
referring to dynup#1010 and dynup#1203.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants