Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752869AbbEDLlL (ORCPT ); Mon, 4 May 2015 07:41:11 -0400 Received: from ip4-83-240-67-251.cust.nbox.cz ([83.240.67.251]:50907 "EHLO ip4-83-240-18-248.cust.nbox.cz" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752555AbbEDLk2 (ORCPT ); Mon, 4 May 2015 07:40:28 -0400 From: Jiri Slaby To: live-patching@vger.kernel.org Cc: jpoimboe@redhat.com, sjenning@redhat.com, jkosina@suse.cz, vojtech@suse.cz, mingo@redhat.com, linux-kernel@vger.kernel.org, Jiri Slaby Subject: [RFC kgr on klp 7/9] livepatch: propagate the patch status to functions Date: Mon, 4 May 2015 13:40:23 +0200 Message-Id: <1430739625-4658-7-git-send-email-jslaby@suse.cz> X-Mailer: git-send-email 2.3.5 In-Reply-To: <1430739625-4658-1-git-send-email-jslaby@suse.cz> References: <1430739625-4658-1-git-send-email-jslaby@suse.cz> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3807 Lines: 134 We will need to propagate few different target states in the next patch adding kgraft-like patching. And this will make it easy. So this is only a preparation which does not really change the behaviour. Signed-off-by: Jiri Slaby --- kernel/livepatch/core.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c index 87d94aadfebf..5e89ea74cadb 100644 --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c @@ -330,7 +330,7 @@ static void notrace klp_ftrace_handler(unsigned long ip, rcu_read_unlock(); } -static void klp_disable_func(struct klp_func *func) +static void klp_disable_func(struct klp_func *func, enum klp_state dstate) { struct klp_ops *ops; @@ -354,7 +354,7 @@ static void klp_disable_func(struct klp_func *func) list_del_rcu(&func->stack_node); } - func->state = KLP_DISABLED; + func->state = dstate; } static int klp_prepare_enable_func(struct klp_func *func) @@ -410,7 +410,7 @@ err: return ret; } -static void klp_enable_func(struct klp_func *func) +static void klp_enable_func(struct klp_func *func, enum klp_state dstate) { struct klp_ops *ops; @@ -420,18 +420,18 @@ static void klp_enable_func(struct klp_func *func) list_add_rcu(&func->stack_node, &ops->func_stack); - func->state = KLP_ENABLED; + func->state = dstate; } -static void klp_disable_object(struct klp_object *obj) +static void klp_disable_object(struct klp_object *obj, enum klp_state dstate) { struct klp_func *func; klp_for_each_func(obj, func) if (func->state != KLP_DISABLED) - klp_disable_func(func); + klp_disable_func(func, dstate); - obj->state = KLP_DISABLED; + obj->state = dstate; } static int klp_prepare_enable_object(struct klp_object *obj) @@ -448,7 +448,7 @@ static int klp_prepare_enable_object(struct klp_object *obj) klp_for_each_func(obj, func) { ret = klp_prepare_enable_func(func); if (ret) { - klp_disable_object(obj); + klp_disable_object(obj, KLP_DISABLED); return ret; } } @@ -457,14 +457,14 @@ static int klp_prepare_enable_object(struct klp_object *obj) return 0; } -static void klp_enable_object(struct klp_object *obj) +static void klp_enable_object(struct klp_object *obj, enum klp_state dstate) { struct klp_func *func; klp_for_each_func(obj, func) - klp_enable_func(func); + klp_enable_func(func, dstate); - obj->state = KLP_ENABLED; + obj->state = dstate; } static int __klp_disable_patch(struct klp_patch *patch) @@ -480,7 +480,7 @@ static int __klp_disable_patch(struct klp_patch *patch) klp_for_each_object(patch, obj) { if (obj->state == KLP_PREPARED || obj->state == KLP_ENABLED) - klp_disable_object(obj); + klp_disable_object(obj, KLP_DISABLED); } patch->state = KLP_DISABLED; @@ -551,7 +551,7 @@ static int __klp_enable_patch(struct klp_patch *patch) if (!klp_is_object_loaded(obj)) continue; - klp_enable_object(obj); + klp_enable_object(obj, KLP_ENABLED); } patch->state = KLP_ENABLED; @@ -964,7 +964,7 @@ static void klp_module_notify_coming(struct klp_patch *patch, if (ret) goto err; - klp_enable_object(obj); + klp_enable_object(obj, KLP_ENABLED); return; err: @@ -984,7 +984,7 @@ static void klp_module_notify_going(struct klp_patch *patch, pr_notice("reverting patch '%s' on unloading module '%s'\n", pmod->name, mod->name); - klp_disable_object(obj); + klp_disable_object(obj, KLP_DISABLED); disabled: klp_free_object_loaded(obj); -- 2.3.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/