From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6AE6C43387 for ; Fri, 21 Dec 2018 10:28:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 798072176F for ; Fri, 21 Dec 2018 10:28:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389581AbeLUK2A (ORCPT ); Fri, 21 Dec 2018 05:28:00 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45786 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389541AbeLUK17 (ORCPT ); Fri, 21 Dec 2018 05:27:59 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 382F97970D; Fri, 21 Dec 2018 10:27:59 +0000 (UTC) Received: from f28server.default (ovpn-116-118.phx2.redhat.com [10.3.116.118]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0E2BB5D739; Fri, 21 Dec 2018 10:27:55 +0000 (UTC) From: Daniel Bristot de Oliveira To: linux-kernel@vger.kernel.org Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Greg Kroah-Hartman , Masami Hiramatsu , "Steven Rostedt (VMware)" , Jiri Kosina , Josh Poimboeuf , "Peter Zijlstra (Intel)" , Chris von Recklinghausen , Jason Baron , Scott Wood , Marcelo Tosatti , Clark Williams , x86@kernel.org Subject: [PATCH V3 4/9] x86/jump_label: Add __jump_label_set_jump_code() helper Date: Fri, 21 Dec 2018 11:27:29 +0100 Message-Id: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 21 Dec 2018 10:27:59 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move the definition of the code to be written from __jump_label_transform() to a specialized function. No change in the method, code relocation only. Signed-off-by: Daniel Bristot de Oliveira Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: "H. Peter Anvin" Cc: Greg Kroah-Hartman Cc: Masami Hiramatsu Cc: "Steven Rostedt (VMware)" Cc: Jiri Kosina Cc: Josh Poimboeuf Cc: "Peter Zijlstra (Intel)" Cc: Chris von Recklinghausen Cc: Jason Baron Cc: Scott Wood Cc: Marcelo Tosatti Cc: Clark Williams Cc: x86@kernel.org Cc: linux-kernel@vger.kernel.org --- arch/x86/kernel/jump_label.c | 38 +++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c index 7894080bd02f..a039ac4ca5bf 100644 --- a/arch/x86/kernel/jump_label.c +++ b/arch/x86/kernel/jump_label.c @@ -75,30 +75,36 @@ static inline void __jump_label_trans_check_disable(struct jump_entry *entry, bug_at((void *)jump_entry_code(entry), line); } +static void __jump_label_set_jump_code(struct jump_entry *entry, + enum jump_label_type type, + union jump_code_union *code, + int init) +{ + const unsigned char *ideal_nop = ideal_nops[NOP_ATOMIC5]; + + code->jump = 0xe9; + code->offset = jump_entry_target(entry) - + (jump_entry_code(entry) + JUMP_LABEL_NOP_SIZE); + + if (type == JUMP_LABEL_JMP) { + __jump_label_trans_check_enable(entry, type, ideal_nop, init); + } else { + __jump_label_trans_check_disable(entry, type, code, init); + memcpy(code, ideal_nop, 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), int init) { - union jump_code_union jmp; - const unsigned char *ideal_nop = ideal_nops[NOP_ATOMIC5]; - const void *code; - - jmp.jump = 0xe9; - jmp.offset = jump_entry_target(entry) - - (jump_entry_code(entry) + JUMP_LABEL_NOP_SIZE); + union jump_code_union code; if (early_boot_irqs_disabled) poker = text_poke_early; - if (type == JUMP_LABEL_JMP) { - __jump_label_trans_check_enable(entry, type, ideal_nop, init); - code = &jmp.code; - } else { - __jump_label_trans_check_disable(entry, type, &jmp, init); - code = ideal_nop; - } + __jump_label_set_jump_code(entry, type, &code, init); /* * Make text_poke_bp() a default fallback poker. @@ -109,12 +115,12 @@ static void __ref __jump_label_transform(struct jump_entry *entry, * */ if (poker) { - (*poker)((void *)jump_entry_code(entry), code, + (*poker)((void *)jump_entry_code(entry), &code, JUMP_LABEL_NOP_SIZE); return; } - text_poke_bp((void *)jump_entry_code(entry), code, JUMP_LABEL_NOP_SIZE, + text_poke_bp((void *)jump_entry_code(entry), &code, JUMP_LABEL_NOP_SIZE, (void *)jump_entry_code(entry) + JUMP_LABEL_NOP_SIZE); } -- 2.17.1