Move the definition of the code to be written from
__jump_label_transform() to a specialized function.

Signed-off-by: Daniel Bristot de Oliveira <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Pavel Tatashin <[email protected]>
Cc: Masami Hiramatsu <[email protected]>
Cc: "Steven Rostedt (VMware)" <[email protected]>
Cc: Zhou Chengming <[email protected]>
Cc: Jiri Kosina <[email protected]>
Cc: Josh Poimboeuf <[email protected]>
Cc: "Peter Zijlstra (Intel)" <[email protected]>
Cc: Chris von Recklinghausen <[email protected]>
Cc: Jason Baron <[email protected]>
Cc: Scott Wood <[email protected]>
Cc: Marcelo Tosatti <[email protected]>
Cc: Clark Williams <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
 arch/x86/kernel/jump_label.c | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c
index a11d836d9aaa..de588ff47f81 100644
--- a/arch/x86/kernel/jump_label.c
+++ b/arch/x86/kernel/jump_label.c
@@ -88,6 +88,22 @@ static inline void __jump_label_disabling_check(struct 
jump_entry *entry,
        }
 }
 
+static void __jump_label_set_jump_code(struct jump_entry *entry,
+                                    enum jump_label_type type,
+                                    int init,
+                                    union jump_code_union *code)
+{
+       if (type == JUMP_LABEL_JMP) {
+               __jump_label_enabling_check(entry, type, init);
+
+               code->jump = 0xe9;
+               code->offset = entry->target - (entry->code + 
JUMP_LABEL_NOP_SIZE);
+       } else {
+               __jump_label_disabling_check(entry, type, init);
+               memcpy(code, ideal_nops[NOP_ATOMIC5], JUMP_LABEL_NOP_SIZE);
+       }
+}
+
 static void __ref __jump_label_transform(struct jump_entry *entry,
                                         enum jump_label_type type,
                                         void *(*poker)(void *, const void *, 
size_t),
@@ -98,16 +114,7 @@ static void __ref __jump_label_transform(struct jump_entry 
*entry,
        if (early_boot_irqs_disabled)
                poker = text_poke_early;
 
-       if (type == JUMP_LABEL_JMP) {
-               __jump_label_enabling_check(entry, type, init);
-
-               code.jump = 0xe9;
-               code.offset = entry->target -
-                               (entry->code + JUMP_LABEL_NOP_SIZE);
-       } else {
-               __jump_label_disabling_check(entry, type, init);
-               memcpy(&code, ideal_nops[NOP_ATOMIC5], JUMP_LABEL_NOP_SIZE);
-       }
+       __jump_label_set_jump_code(entry, type, init, &code);
 
        /*
         * Make text_poke_bp() a default fallback poker.
-- 
2.17.1

Reply via email to