* [PATCH v4] arm64: Implement HAVE_LIVEPATCH
@ 2025-06-17 17:37 Song Liu
2025-06-26 13:21 ` Will Deacon
0 siblings, 1 reply; 4+ messages in thread
From: Song Liu @ 2025-06-17 17:37 UTC (permalink / raw)
To: live-patching, linux-kernel, linux-arm-kernel
Cc: jpoimboe, jikos, mbenes, pmladek, joe.lawrence, catalin.marinas,
will, dylanbhatch, fj6611ie, mark.rutland, kernel-team, Song Liu,
Suraj Jitindar Singh, Torsten Duwe, Breno Leitao,
Andrea della Porta
This is largely based on [1] by Suraj Jitindar Singh.
Test coverage:
- Passed manual tests with samples/livepatch.
- Passed all but test-kprobe.sh in selftests/livepatch.
test-kprobe.sh is expected to fail, because arm64 doesn't have
KPROBES_ON_FTRACE.
- Passed tests with kpatch-build [2]. (This version includes commits that
are not merged to upstream kpatch yet).
[1] https://lore.kernel.org/all/20210604235930.603-1-surajjs@amazon.com/
[2] https://github.com/liu-song-6/kpatch/tree/fb-6.13
Cc: Suraj Jitindar Singh <surajjs@amazon.com>
Cc: Torsten Duwe <duwe@suse.de>
Acked-by: Miroslav Benes <mbenes@suse.cz>
Tested-by: Breno Leitao <leitao@debian.org>
Tested-by: Andrea della Porta <andrea.porta@suse.com>
Signed-off-by: Song Liu <song@kernel.org>
---
Note: This patch depends on [3] and [4].
[3] https://lore.kernel.org/linux-arm-kernel/20250521111000.2237470-2-mark.rutland@arm.com/
[4] https://lore.kernel.org/linux-arm-kernel/20250603223417.3700218-1-dylanbhatch@google.com/
Changes v3 => v4:
1. Only keep 2/2 from v3, as 1/2 is now included in [3].
2. Change TIF_PATCH_PENDING from 7 to 13.
v3: https://lore.kernel.org/linux-arm-kernel/20250320171559.3423224-1-song@kernel.org/
Changes v2 => v3:
1. Remove a redundant check for -ENOENT. (Josh Poimboeuf)
2. Add Tested-by and Acked-by on v1. (I forgot to add them in v2.)
v2: https://lore.kernel.org/live-patching/20250319213707.1784775-1-song@kernel.org/
Changes v1 => v2:
1. Rework arch_stack_walk_reliable().
v1: https://lore.kernel.org/live-patching/20250308012742.3208215-1-song@kernel.org/
---
arch/arm64/Kconfig | 3 +++
arch/arm64/include/asm/thread_info.h | 5 ++++-
arch/arm64/kernel/entry-common.c | 4 ++++
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index b7462424aa59..110218542920 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -280,6 +280,7 @@ config ARM64
select USER_STACKTRACE_SUPPORT
select VDSO_GETRANDOM
select HAVE_RELIABLE_STACKTRACE
+ select HAVE_LIVEPATCH
help
ARM 64-bit (AArch64) Linux support.
@@ -2499,3 +2500,5 @@ endmenu # "CPU Power Management"
source "drivers/acpi/Kconfig"
source "arch/arm64/kvm/Kconfig"
+
+source "kernel/livepatch/Kconfig"
diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h
index 1269c2487574..f241b8601ebd 100644
--- a/arch/arm64/include/asm/thread_info.h
+++ b/arch/arm64/include/asm/thread_info.h
@@ -70,6 +70,7 @@ void arch_setup_new_exec(void);
#define TIF_SYSCALL_TRACEPOINT 10 /* syscall tracepoint for ftrace */
#define TIF_SECCOMP 11 /* syscall secure computing */
#define TIF_SYSCALL_EMU 12 /* syscall emulation active */
+#define TIF_PATCH_PENDING 13 /* pending live patching update */
#define TIF_MEMDIE 18 /* is terminating due to OOM killer */
#define TIF_FREEZE 19
#define TIF_RESTORE_SIGMASK 20
@@ -96,6 +97,7 @@ void arch_setup_new_exec(void);
#define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
#define _TIF_SECCOMP (1 << TIF_SECCOMP)
#define _TIF_SYSCALL_EMU (1 << TIF_SYSCALL_EMU)
+#define _TIF_PATCH_PENDING (1 << TIF_PATCH_PENDING)
#define _TIF_UPROBE (1 << TIF_UPROBE)
#define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP)
#define _TIF_32BIT (1 << TIF_32BIT)
@@ -107,7 +109,8 @@ void arch_setup_new_exec(void);
#define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_NEED_RESCHED_LAZY | \
_TIF_NOTIFY_RESUME | _TIF_FOREIGN_FPSTATE | \
_TIF_UPROBE | _TIF_MTE_ASYNC_FAULT | \
- _TIF_NOTIFY_SIGNAL | _TIF_SIGPENDING)
+ _TIF_NOTIFY_SIGNAL | _TIF_SIGPENDING | \
+ _TIF_PATCH_PENDING)
#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
_TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | \
diff --git a/arch/arm64/kernel/entry-common.c b/arch/arm64/kernel/entry-common.c
index 7c1970b341b8..a56878d7c733 100644
--- a/arch/arm64/kernel/entry-common.c
+++ b/arch/arm64/kernel/entry-common.c
@@ -8,6 +8,7 @@
#include <linux/context_tracking.h>
#include <linux/kasan.h>
#include <linux/linkage.h>
+#include <linux/livepatch.h>
#include <linux/lockdep.h>
#include <linux/ptrace.h>
#include <linux/resume_user_mode.h>
@@ -144,6 +145,9 @@ static void do_notify_resume(struct pt_regs *regs, unsigned long thread_flags)
(void __user *)NULL, current);
}
+ if (thread_flags & _TIF_PATCH_PENDING)
+ klp_update_patch_state(current);
+
if (thread_flags & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL))
do_signal(regs);
--
2.47.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v4] arm64: Implement HAVE_LIVEPATCH
2025-06-17 17:37 [PATCH v4] arm64: Implement HAVE_LIVEPATCH Song Liu
@ 2025-06-26 13:21 ` Will Deacon
2025-06-26 14:55 ` Song Liu
0 siblings, 1 reply; 4+ messages in thread
From: Will Deacon @ 2025-06-26 13:21 UTC (permalink / raw)
To: Song Liu
Cc: live-patching, linux-kernel, linux-arm-kernel, jpoimboe, jikos,
mbenes, pmladek, joe.lawrence, catalin.marinas, dylanbhatch,
fj6611ie, mark.rutland, kernel-team, Suraj Jitindar Singh,
Torsten Duwe, Breno Leitao, Andrea della Porta
On Tue, Jun 17, 2025 at 10:37:34AM -0700, Song Liu wrote:
> This is largely based on [1] by Suraj Jitindar Singh.
I think it would be useful to preserve at least some parts of the
original commit message here so that folks don't have to pull it out
of the list archives if they want to see more about the rationale.
That aside, the code looks good to me. The sooner we can move over to
the generic entry code, the better.
Acked-by: Will Deacon <will@kernel.org>
Will
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v4] arm64: Implement HAVE_LIVEPATCH
2025-06-26 13:21 ` Will Deacon
@ 2025-06-26 14:55 ` Song Liu
2025-06-30 17:16 ` Catalin Marinas
0 siblings, 1 reply; 4+ messages in thread
From: Song Liu @ 2025-06-26 14:55 UTC (permalink / raw)
To: Will Deacon
Cc: live-patching, linux-kernel, linux-arm-kernel, jpoimboe, jikos,
mbenes, pmladek, joe.lawrence, catalin.marinas, dylanbhatch,
fj6611ie, mark.rutland, kernel-team, Suraj Jitindar Singh,
Torsten Duwe, Breno Leitao, Andrea della Porta
Hi Will,
Thanks for your kind review!
On Thu, Jun 26, 2025 at 6:21 AM Will Deacon <will@kernel.org> wrote:
>
> On Tue, Jun 17, 2025 at 10:37:34AM -0700, Song Liu wrote:
> > This is largely based on [1] by Suraj Jitindar Singh.
>
> I think it would be useful to preserve at least some parts of the
> original commit message here so that folks don't have to pull it out
> of the list archives if they want to see more about the rationale.
The relevant message from the original commit message is:
Allocate a task flag used to represent the patch pending state for the
task.
Shall I respin this patch to add this? Or maybe Catalin can add
this while applying the patch?
Thanks,
Song
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v4] arm64: Implement HAVE_LIVEPATCH
2025-06-26 14:55 ` Song Liu
@ 2025-06-30 17:16 ` Catalin Marinas
0 siblings, 0 replies; 4+ messages in thread
From: Catalin Marinas @ 2025-06-30 17:16 UTC (permalink / raw)
To: Song Liu
Cc: Will Deacon, live-patching, linux-kernel, linux-arm-kernel,
jpoimboe, jikos, mbenes, pmladek, joe.lawrence, dylanbhatch,
fj6611ie, mark.rutland, kernel-team, Suraj Jitindar Singh,
Torsten Duwe, Breno Leitao, Andrea della Porta
On Thu, Jun 26, 2025 at 07:55:28AM -0700, Song Liu wrote:
> On Thu, Jun 26, 2025 at 6:21 AM Will Deacon <will@kernel.org> wrote:
> > On Tue, Jun 17, 2025 at 10:37:34AM -0700, Song Liu wrote:
> > > This is largely based on [1] by Suraj Jitindar Singh.
> >
> > I think it would be useful to preserve at least some parts of the
> > original commit message here so that folks don't have to pull it out
> > of the list archives if they want to see more about the rationale.
>
> The relevant message from the original commit message is:
>
> Allocate a task flag used to represent the patch pending state for the
> task.
>
> Shall I respin this patch to add this? Or maybe Catalin can add
> this while applying the patch?
Please repost with a more meaningful description and a justification why
a new thread flag is needed.
Thanks.
--
Catalin
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-06-30 17:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-17 17:37 [PATCH v4] arm64: Implement HAVE_LIVEPATCH Song Liu
2025-06-26 13:21 ` Will Deacon
2025-06-26 14:55 ` Song Liu
2025-06-30 17:16 ` Catalin Marinas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).