From 1d5cc0de3be2306f38a378fd4fbc235abb12e0ed Mon Sep 17 00:00:00 2001 From: qjl21 <18810075699@163.com> Date: Sat, 16 May 2026 18:15:48 +0800 Subject: [PATCH 1/2] kpatch: add support for CONFIG_LIVEPATCH_WO_FTRACE on openEuler 6.6 openEuler 6.6 introduces ftrace-less livepatch via the kernel config CONFIG_LIVEPATCH_WO_FTRACE=y. When this option is enabled, CONFIG_LIVEPATCH_FTRACE is not set and the kernel applies live patches without relying on ftrace trampolines. Two changes are required to handle this configuration: kpatch-build: detect CONFIG_LIVEPATCH_WO_FTRACE=y in the target kernel config and automatically export NO_PROFILING_CALLS=1, which suppresses the ftrace-based profiling instrumentation that is incompatible with ftrace-less livepatch. livepatch-patch-hook.c: introduce the HAVE_WO_FTRACE_ENABLE helper macro when CONFIG_LIVEPATCH_WO_FTRACE is defined, and guard the klp_enable_patch() call with it so the correct activation path is selected at compile time. Signed-off-by: qujingling <18810075699@163.com> --- kmod/patch/livepatch-patch-hook.c | 7 +++++++ kpatch-build/kpatch-build | 2 ++ 2 files changed, 9 insertions(+) diff --git a/kmod/patch/livepatch-patch-hook.c b/kmod/patch/livepatch-patch-hook.c index 3d13ab97e..8878a4bfc 100644 --- a/kmod/patch/livepatch-patch-hook.c +++ b/kmod/patch/livepatch-patch-hook.c @@ -86,6 +86,11 @@ #define KLP_REPLACE_ENABLE true #endif + +#ifdef CONFIG_LIVEPATCH_WO_FTRACE +#define HAVE_WO_FTRACE_ENABLE +#endif + /* * There are quite a few similar structures at play in this file: * - livepatch.h structs prefixed with klp_* @@ -576,6 +581,7 @@ static int __init patch_init(void) } #endif +#if defined(HAVE_WO_FTRACE_ENABLE) ret = klp_enable_patch(lpatch); if (ret) { #ifndef HAVE_SIMPLE_ENABLE @@ -584,6 +590,7 @@ static int __init patch_init(void) patch_free_livepatch(lpatch); return ret; } +#endif return 0; out: diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build index 57c3f7265..a48fe3697 100755 --- a/kpatch-build/kpatch-build +++ b/kpatch-build/kpatch-build @@ -1232,6 +1232,8 @@ else KBUILD_EXTRA_SYMBOLS="$SYMVERSFILE" fi +grep -q "CONFIG_LIVEPATCH_WO_FTRACE=y" "$CONFIGFILE" && export NO_PROFILING_CALLS=1 + # unsupported kernel option checking [[ -n "$CONFIG_DEBUG_INFO_SPLIT" ]] && die "kernel option 'CONFIG_DEBUG_INFO_SPLIT' not supported" [[ -n "$CONFIG_GCC_PLUGIN_LATENT_ENTROPY" ]] && die "kernel option 'CONFIG_GCC_PLUGIN_LATENT_ENTROPY' not supported" From eeffe76e041679410a7727e164e983407afed5c6 Mon Sep 17 00:00:00 2001 From: qjl21 <18810075699@163.com> Date: Sat, 16 May 2026 18:14:54 +0800 Subject: [PATCH 2/2] kpatch-build: skip CONFIG_LIVEPATCH_PER_TASK_CONSISTENCY check on kernel >= 6.6 CONFIG_LIVEPATCH_PER_TASK_CONSISTENCY was removed in the 6.6 kernel. On openEuler 6.6, the per-task consistency model is no longer a separate Kconfig symbol; the kernel instead uses CONFIG_LIVEPATCH_STOP_MACHINE_CONSISTENCY and CONFIG_LIVEPATCH_WO_FTRACE to describe its livepatch mechanism. The existing check unconditionally fails when building against an openEuler 6.6 kernel because the config option simply does not appear in the .config file, even though the kernel is correctly configured for live patching. Guard the check with a kernel version comparison so that it only fires on kernels older than 6.6, where CONFIG_LIVEPATCH_PER_TASK_CONSISTENCY is still the expected indicator of a supported livepatch configuration. Signed-off-by: qujingling <18810075699@163.com> --- kpatch-build/kpatch-build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build index a48fe3697..9d54006e8 100755 --- a/kpatch-build/kpatch-build +++ b/kpatch-build/kpatch-build @@ -1194,7 +1194,7 @@ trace_off "reading .config" source "$CONFIGFILE" trace_on -[[ "$DISTRO" = openEuler ]] && [[ -z "$CONFIG_LIVEPATCH_PER_TASK_CONSISTENCY" ]] && \ +[[ "$DISTRO" = openEuler ]] && ! kernel_version_gte 6.6.0 && [[ -z "$CONFIG_LIVEPATCH_PER_TASK_CONSISTENCY" ]] && \ die "openEuler kernel doesn't have 'CONFIG_LIVEPATCH_PER_TASK_CONSISTENCY' enabled" [[ -z "$CONFIG_DEBUG_INFO" ]] && die "kernel doesn't have 'CONFIG_DEBUG_INFO' enabled"