Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3544508imm; Mon, 8 Oct 2018 05:54:28 -0700 (PDT) X-Google-Smtp-Source: ACcGV61O98pZnvqFNdLYiiD3BIqvbgNZvsh3WyMjw0JO+ZV33r0nGcu+VsHTh89nY3RlNyt+q09d X-Received: by 2002:a17:902:7c96:: with SMTP id y22-v6mr23869800pll.321.1539003268686; Mon, 08 Oct 2018 05:54:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539003268; cv=none; d=google.com; s=arc-20160816; b=Yp/UCJMMKvg97xOilx9plrTbp8qTNFQQivvIl7DTB/1WyVNgKCDgK4yvcLzSDUhekC ZrL2yOVAK5kLeH9YZx+vYIIpdB6iaqCIcGesUlHwt4xpBl4POPerwvvkDXpagolZtXqj WuutTApdo0MHaFS/2Sc2c+VC/VmPvPid8NaUHNUXMMLA5UqpqvJ+W//UehECJ6YxTfqN sNLQYK+0I9BLdCWs/Uv6dnAfxxjZ2//qnuDKydoYDau0V/mZjyzKsfY3ZW6ZewbLubxp rp//uA135vxcdwEN1JVHADfnl4rCkcNgGbZMypHAqcFTspNlByAXPo+yoo85WH0T81na CflQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=pL0w+GAz4hZw5Aa/I+E1NEFcOkmOGtzFHUAkPpHMtAM=; b=D4pc44I54jnE2ZQPVPqLdIhgJWlFfF6hVdcYD5lvAQt8s2U0W870iL5Lor/1PDmeIj GQo5Pk3qHrI7rJB++xIaM8TMxTPv4bIuS5GEc8jM5+40DEfUYzWVYIE69t7oA9OMdqXE h25HoU8CU4FBbYs8OFL+fTh4EuA4gf27rNEJ6hM2iWzEhwJaJ1rjogq7CXhnBzILCF8J pwe1PnxWM4EYlP6iO6Y9TgoMiPtz7qIKUO0TLxocnX8wfSIAyiEYIHmZYAQz7Z9i5vdj jefgEi8HLk8IXDbyL3PFIXUPPbv/diTbzj8JBHDMcQsrmffBaQKrB+gMj9AiGyMnVPDS BBiQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 28-v6si15295777pgy.68.2018.10.08.05.54.13; Mon, 08 Oct 2018 05:54:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726707AbeJHUFX (ORCPT + 99 others); Mon, 8 Oct 2018 16:05:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53002 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725893AbeJHUFW (ORCPT ); Mon, 8 Oct 2018 16:05:22 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 089838831E; Mon, 8 Oct 2018 12:53:48 +0000 (UTC) Received: from f28server.default (ovpn-116-135.phx2.redhat.com [10.3.116.135]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6F8C863129; Mon, 8 Oct 2018 12:53:43 +0000 (UTC) From: Daniel Bristot de Oliveira To: linux-kernel@vger.kernel.org, x86@kernel.org Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Greg Kroah-Hartman , Pavel Tatashin , Masami Hiramatsu , "Steven Rostedt (VMware)" , Zhou Chengming , Jiri Kosina , Josh Poimboeuf , "Peter Zijlstra (Intel)" , Chris von Recklinghausen , Jason Baron , Scott Wood , Marcelo Tosatti , Clark Williams Subject: [RFC PATCH 4/6] x86/jump_label: Add __jump_label_set_jump_code() helper Date: Mon, 8 Oct 2018 14:53:03 +0200 Message-Id: <48663bd96154409d558981221b4f4b6ce4fce72a.1539001620.git.bristot@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 08 Oct 2018 12:53:48 +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. 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: Pavel Tatashin Cc: Masami Hiramatsu Cc: "Steven Rostedt (VMware)" Cc: Zhou Chengming 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 | 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