From: Ye Weihua yeweihua4@huawei.com
hulk inclusion category: feature bugzilla: 119440 https://gitee.com/openeuler/kernel/issues/I4DDEL
--------------------------------
The force field is divided into three states. KLP_NORMAL_FORCE indicates that a hot patch is installed according to the initial rule. KLP_ENFORCMENT indicates that the hot patch of the function must be installed. KLP_STACK_OPTIMIZE is prepared for stack optimization policy.
Signed-off-by: Ye Weihua yeweihua4@huawei.com Reviewed-by: Kuohai Xu xukuohai@huawei.com Signed-off-by: Chen Jun chenjun102@huawei.com --- arch/arm/kernel/livepatch.c | 2 +- arch/arm64/kernel/livepatch.c | 2 +- arch/powerpc/kernel/livepatch_32.c | 2 +- arch/powerpc/kernel/livepatch_64.c | 2 +- arch/x86/kernel/livepatch.c | 2 +- include/linux/livepatch.h | 4 ++++ 6 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/arch/arm/kernel/livepatch.c b/arch/arm/kernel/livepatch.c index b5fcaf3c4ca7..1dc074e2a0d4 100644 --- a/arch/arm/kernel/livepatch.c +++ b/arch/arm/kernel/livepatch.c @@ -99,7 +99,7 @@ static int klp_check_activeness_func(struct stackframe *frame, void *data) for (obj = patch->objs; obj->funcs; obj++) { for (func = obj->funcs; func->old_name; func++) { if (args->enable) { - if (func->force) + if (func->force == KLP_ENFORCEMENT) continue; /* * When enable, checking the currently diff --git a/arch/arm64/kernel/livepatch.c b/arch/arm64/kernel/livepatch.c index a1cd8ee026d7..10b7d9b99f62 100644 --- a/arch/arm64/kernel/livepatch.c +++ b/arch/arm64/kernel/livepatch.c @@ -104,7 +104,7 @@ static bool klp_check_activeness_func(void *data, unsigned long pc) for (obj = patch->objs; obj->funcs; obj++) { for (func = obj->funcs; func->old_name; func++) { if (args->enable) { - if (func->force) + if (func->force == KLP_ENFORCEMENT) continue; /* * When enable, checking the currently diff --git a/arch/powerpc/kernel/livepatch_32.c b/arch/powerpc/kernel/livepatch_32.c index 35d1885796d4..1d41b8939799 100644 --- a/arch/powerpc/kernel/livepatch_32.c +++ b/arch/powerpc/kernel/livepatch_32.c @@ -93,7 +93,7 @@ static int klp_check_activeness_func(struct stackframe *frame, void *data) for (obj = patch->objs; obj->funcs; obj++) { for (func = obj->funcs; func->old_name; func++) { if (args->enable) { - if (func->force) + if (func->force == KLP_ENFORCEMENT) continue; /* * When enable, checking the currently diff --git a/arch/powerpc/kernel/livepatch_64.c b/arch/powerpc/kernel/livepatch_64.c index 6285635e63fd..55cbb65ca708 100644 --- a/arch/powerpc/kernel/livepatch_64.c +++ b/arch/powerpc/kernel/livepatch_64.c @@ -132,7 +132,7 @@ static int klp_check_activeness_func(struct stackframe *frame, void *data)
/* Check func address in stack */ if (args->enable) { - if (func->force) + if (func->force == KLP_ENFORCEMENT) continue; /* * When enable, checking the currently diff --git a/arch/x86/kernel/livepatch.c b/arch/x86/kernel/livepatch.c index bcfda2490916..52bc0fc2bd6b 100644 --- a/arch/x86/kernel/livepatch.c +++ b/arch/x86/kernel/livepatch.c @@ -90,7 +90,7 @@ static int klp_check_stack_func(struct klp_func *func, #endif
if (enable) { - if (func->force) + if (func->force == KLP_ENFORCEMENT) continue; /* * When enable, checking the currently active diff --git a/include/linux/livepatch.h b/include/linux/livepatch.h index ce32a8da1517..5b4a0864a011 100644 --- a/include/linux/livepatch.h +++ b/include/linux/livepatch.h @@ -23,6 +23,10 @@ #define KLP_UNPATCHED 0 #define KLP_PATCHED 1
+#define KLP_NORMAL_FORCE 0 +#define KLP_ENFORCEMENT 1 +#define KLP_STACK_OPTIMIZE 2 + /** * struct klp_func - function structure for live patching * @old_name: name of the function to be patched