Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3545383imm; Mon, 8 Oct 2018 05:55:25 -0700 (PDT) X-Google-Smtp-Source: ACcGV61ayWEzhLp20MXqcT7QGVDZNLcxnCumXUoBOkzNB56yKPwcJ9Mbwj95Pkqb6D3811Lgbk/q X-Received: by 2002:a63:c0f:: with SMTP id b15-v6mr21286818pgl.400.1539003325499; Mon, 08 Oct 2018 05:55:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539003325; cv=none; d=google.com; s=arc-20160816; b=S4/dwIA6REGf006ybVdTdNyj0ISdU4t4OUS59szGcDlwDC2/BaLzgaPcav51KwrMIt argf5T6sUj+GiCmj5+u2SW+xeyi2DqAmqrmI3GE3RW3C06bjRtzJnEv+aP3V0CQxsNeB 1uz3LwFkwCk0G4eWkNiW/y6JcOwIrZGGo2vZLhTyYRUpPdlgjCn+LwPlQ0FyWisjLfH2 /UusDcSuQwGqXoBAUyF+Fu/6mbUtf0Zr+BFaeKp/iTfqce53z7X+74ufVlRmF7V7XIMb /vIo534NArnRzNjCYqvmBz/YFzL0V4rnbqGpVlZ/8omLVDuOmTjWQi8y9+wGY+IROMMI clcA== 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=y1oSCJanxy6t0MmCDm5kTu/SEMDlue0lcZsgY7R7YI0=; b=MmUbsnKfXMEpVqtOR5FD1coDI39zOs9hSdD1d0cb6ZnhyK9r8DEJSmL4lJ8nnSo3tE B1IwVA7DbKfEcoQ4nC1MpnVhZ8HYvKPLuzrFheZ1u2z/28JKLXC1ASacGfKRlt/+zrb5 IedPeAoetd+tt+i9lafOlet9oa/WqI5gNhQ5Rl8FEu7I2X7s9wFYCl68rss9JMMbH/4+ o8kWU8rhAEMnSFIrIvlzzSLqip1lJ2BECFJlphi0JEY2e8o3XIoA5gPR5dKyEgEhz//d 7HUvd94YwNq5vk2VMDRrw7KYwYtTgl3UenO1476PtjFArwoijGW7SPMx0Aso4xSYEiCM OTTg== 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 u8-v6si9230304plh.376.2018.10.08.05.55.09; Mon, 08 Oct 2018 05:55:25 -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 S1726646AbeJHUFI (ORCPT + 99 others); Mon, 8 Oct 2018 16:05:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52752 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725893AbeJHUFH (ORCPT ); Mon, 8 Oct 2018 16:05:07 -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 73FB088312; Mon, 8 Oct 2018 12:53:33 +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 E51B663756; Mon, 8 Oct 2018 12:53:29 +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 2/6] jump_label: Add the jump_label_can_update_check() helper Date: Mon, 8 Oct 2018 14:53:01 +0200 Message-Id: <6323276163587de071cd830f9f4def97cf222550.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:33 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move the check of if a jump_entry is valid to a 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 --- kernel/jump_label.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/kernel/jump_label.c b/kernel/jump_label.c index e853916a3b46..940ba7819c87 100644 --- a/kernel/jump_label.c +++ b/kernel/jump_label.c @@ -361,22 +361,29 @@ static enum jump_label_type jump_label_type(struct jump_entry *entry) return enabled ^ branch; } +bool jump_label_can_update_check(struct jump_entry *entry) +{ + /* + * An entry->code of 0 indicates an entry which has been + * disabled because it was in an init text area. + */ + if (entry->code) { + if (kernel_text_address(entry->code)) + return 1; + else + WARN_ONCE(1, "can't patch jump_label at %pS", + (void *)(unsigned long)entry->code); + } + return 0; +} + static void __jump_label_update(struct static_key *key, struct jump_entry *entry, struct jump_entry *stop) { for_each_label_entry(key, entry, stop) { - /* - * An entry->code of 0 indicates an entry which has been - * disabled because it was in an init text area. - */ - if (entry->code) { - if (kernel_text_address(entry->code)) - arch_jump_label_transform(entry, jump_label_type(entry)); - else - WARN_ONCE(1, "can't patch jump_label at %pS", - (void *)(unsigned long)entry->code); - } + if (jump_label_can_update_check(entry)) + arch_jump_label_transform(entry, jump_label_type(entry)); } } -- 2.17.1