Skip to contentSkip to conversation

*** Rename KLP_* to KLP_TRANSITION_* ***

PATCH In review [email protected] 4 participants 6 messages May 7, 2024 – May 9, 2024 Live patching

lore
Share & tools
lore
#0 lore raw

cover *** Rename KLP_* to KLP_TRANSITION_* ***

From: Wardenjohn <[email protected]>

This is the v3 of commit " livepatch: Rename KLP_* to KLP_TRANSITION_* " with the suggestion of @Josh

v1 -> v2 :
Use KLP_TRANSITION_* to replace marcos KLP_*

v2 -> v3 :
Remove the unnecessary comment and fix one typo in the code.

Wardenjohn (1):
livepatch: Rename KLP_* to KLP_TRANSITION_*

 include/linux/livepatch.h     |  6 ++--
 init/init_task.c              |  2 +-
 kernel/livepatch/core.c       |  4 +--
 kernel/livepatch/patch.c      |  4 +--
 kernel/livepatch/transition.c | 54 +++++++++++++++++------------------
 5 files changed, 35 insertions(+), 35 deletions(-)
Signature · 1 line
2.37.3
#1 lore raw

PATCH 1/1 livepatch: Rename KLP_* to KLP_TRANSITION_*

From: Wardenjohn <[email protected]>

The original macros of KLP_* is about the state of the transition. Rename macros of KLP_* to KLP_TRANSITION_* to fix the confusing description of klp transition state.

---
 include/linux/livepatch.h     |  6 ++--
 init/init_task.c              |  2 +-
 kernel/livepatch/core.c       |  4 +--
 kernel/livepatch/patch.c      |  4 +--
 kernel/livepatch/transition.c | 54 +++++++++++++++++------------------
 5 files changed, 35 insertions(+), 35 deletions(-)
include/linux/livepatch.h +3 -3
index 9b9b38e89563..51a258c24ff5 100644
@@ -18,9 +18,9 @@
 #if IS_ENABLED(CONFIG_LIVEPATCH)
 
 /* task patch states */
-#define KLP_UNDEFINED	-1
-#define KLP_UNPATCHED	 0
-#define KLP_PATCHED	 1
+#define KLP_TRANSITION_IDLE		-1
+#define KLP_TRANSITION_UNPATCHED	 0
+#define KLP_TRANSITION_PATCHED		 1
 
 /**
  * struct klp_func - function structure for live patching
init/init_task.c +1 -1
index 2558b719e053..eeb110c65fe2 100644
@@ -199,7 +199,7 @@ struct task_struct init_task __aligned(L1_CACHE_BYTES) = {
 	.trace_recursion = 0,
 #endif
 #ifdef CONFIG_LIVEPATCH
-	.patch_state	= KLP_UNDEFINED,
+	.patch_state	= KLP_TRANSITION_IDLE,
 #endif
 #ifdef CONFIG_SECURITY
 	.security	= NULL,
kernel/livepatch/core.c +2 -2
index ecbc9b6aba3a..52426665eecc 100644
@@ -973,7 +973,7 @@ static int __klp_disable_patch(struct klp_patch *patch)
 	if (klp_transition_patch)
 		return -EBUSY;
 
-	klp_init_transition(patch, KLP_UNPATCHED);
+	klp_init_transition(patch, KLP_TRANSITION_UNPATCHED);
 
 	klp_for_each_object(patch, obj)
 		if (obj->patched)
@@ -1008,7 +1008,7 @@ static int __klp_enable_patch(struct klp_patch *patch)
 
 	pr_notice("enabling patch '%s'\n", patch->mod->name);
 
-	klp_init_transition(patch, KLP_PATCHED);
+	klp_init_transition(patch, KLP_TRANSITION_PATCHED);
 
 	/*
 	 * Enforce the order of the func->transition writes in
kernel/livepatch/patch.c +2 -2
index 4152c71507e2..90408500e5a3 100644
@@ -95,9 +95,9 @@ static void notrace klp_ftrace_handler(unsigned long ip,
 
 		patch_state = current->patch_state;
 
-		WARN_ON_ONCE(patch_state == KLP_UNDEFINED);
+		WARN_ON_ONCE(patch_state == KLP_TRANSITION_IDLE);
 
-		if (patch_state == KLP_UNPATCHED) {
+		if (patch_state == KLP_TRANSITION_UNPATCHED) {
 			/*
 			 * Use the previously patched version of the function.
 			 * If no previous patches exist, continue with the
kernel/livepatch/transition.c +27 -27

178 lines not on this page · raw message

Signature · 1 line
2.37.3
maintainer Reviewed-by Tested-by on v1 1/1
#2 lore raw

Re: [PATCH 1/1] livepatch: Rename KLP_* to KLP_TRANSITION_*

Quoted 7 lines · On Tue 2024-05-07 13:01:11, [email protected] wrote:

From: Wardenjohn <[email protected]>

The original macros of KLP_* is about the state of the transition. Rename macros of KLP_* to KLP_TRANSITION_* to fix the confusing description of klp transition state.

Looks good to me:

Best Regards,
Petr

maintainer Acked-by on v1 1/1
#3 lore raw

Re: [PATCH 1/1] livepatch: Rename KLP_* to KLP_TRANSITION_*

In reply to [email protected]
Quoted 7 lines · On Tue, May 07, 2024 at 01:01:11PM +0800, [email protected] wrote:

From: Wardenjohn <[email protected]>

The original macros of KLP_* is about the state of the transition. Rename macros of KLP_* to KLP_TRANSITION_* to fix the confusing description of klp transition state.

Signature · 1 line
Josh
maintainer Acked-by on v1 1/1
#4 lore raw

Re: [PATCH 1/1] livepatch: Rename KLP_* to KLP_TRANSITION_*

In reply to [email protected]
Quoted 7 lines · On Tue, 7 May 2024, [email protected] wrote:

From: Wardenjohn <[email protected]>

The original macros of KLP_* is about the state of the transition. Rename macros of KLP_* to KLP_TRANSITION_* to fix the confusing description of klp transition state.

M

maintainer
#5 lore raw

Re: [PATCH 1/1] livepatch: Rename KLP_* to KLP_TRANSITION_*

In reply to [email protected]
Quoted 7 lines · On Tue 2024-05-07 13:01:11, [email protected] wrote:

From: Wardenjohn <[email protected]>

The original macros of KLP_* is about the state of the transition. Rename macros of KLP_* to KLP_TRANSITION_* to fix the confusing description of klp transition state.

JFYI, the patch has been comitted into livepatching.git, branch for-10.

Best regards,
Petr