Move the definition of the code to be written from __jump_label_transform() to a specialized function.
Signed-off-by: Daniel Bristot de Oliveira <bris...@redhat.com> Cc: Thomas Gleixner <t...@linutronix.de> Cc: Ingo Molnar <mi...@redhat.com> Cc: Borislav Petkov <b...@alien8.de> Cc: "H. Peter Anvin" <h...@zytor.com> Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org> Cc: Pavel Tatashin <pasha.tatas...@oracle.com> Cc: Masami Hiramatsu <mhira...@kernel.org> Cc: "Steven Rostedt (VMware)" <rost...@goodmis.org> Cc: Zhou Chengming <zhouchengmi...@huawei.com> Cc: Jiri Kosina <jkos...@suse.cz> Cc: Josh Poimboeuf <jpoim...@redhat.com> Cc: "Peter Zijlstra (Intel)" <pet...@infradead.org> Cc: Chris von Recklinghausen <creck...@redhat.com> Cc: Jason Baron <jba...@akamai.com> Cc: Scott Wood <sw...@redhat.com> Cc: Marcelo Tosatti <mtosa...@redhat.com> Cc: Clark Williams <willi...@redhat.com> Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org --- 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