From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750727AbdAWFyG (ORCPT ); Mon, 23 Jan 2017 00:54:06 -0500 Received: from ozlabs.org ([103.22.144.67]:35011 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750703AbdAWFyF (ORCPT ); Mon, 23 Jan 2017 00:54:05 -0500 From: Michael Ellerman To: Peter Zijlstra , Vlastimil Babka Cc: Stafford Horne , linux-kernel@vger.kernel.org, Andrew Morton , Thomas Gleixner , Kees Cook , Jessica Yu , Petr Mladek , Rasmus Villemoes , Yang Shi , Tejun Heo , Prarit Bhargava , Yaowei Bai , Andrey Ryabinin Subject: Re: [PATCH -next] init/main: Init jump_labels before they are used to build zonelists In-Reply-To: <20170117134454.GB6515@twins.programming.kicks-ass.net> References: <20170117125624.8535-1-shorne@gmail.com> <20170117134454.GB6515@twins.programming.kicks-ass.net> User-Agent: Notmuch/0.21 (https://notmuchmail.org) Date: Mon, 23 Jan 2017 16:54:00 +1100 Message-ID: <87mveimidj.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Peter Zijlstra writes: > On Tue, Jan 17, 2017 at 02:07:36PM +0100, Vlastimil Babka wrote: > >> Anyway I'm not sure if this patch is safe. Hopefully Peter can judge >> this better... >> >> > Cc: Vlastimil Babka >> > Signed-off-by: Stafford Horne >> > --- >> > init/main.c | 3 +-- >> > 1 file changed, 1 insertion(+), 2 deletions(-) >> > >> > diff --git a/init/main.c b/init/main.c >> > index 8b1adb6e..d1ca7cb 100644 >> > --- a/init/main.c >> > +++ b/init/main.c >> > @@ -513,6 +513,7 @@ asmlinkage __visible void __init start_kernel(void) >> > boot_cpu_state_init(); >> > smp_prepare_boot_cpu(); /* arch-specific boot-cpu hooks */ >> > >> > + jump_label_init(); >> > build_all_zonelists(NULL, NULL); >> > page_alloc_init(); >> > >> > @@ -526,8 +527,6 @@ asmlinkage __visible void __init start_kernel(void) >> > parse_args("Setting init args", after_dashes, NULL, 0, -1, -1, >> > NULL, set_init_arg); >> > >> > - jump_label_init(); >> > - > > Urgh, that means auditing all archs that implement this. The thing > you're looking for is if the self-modifying code cruft can be done that > early. You could do what we do on powerpc, which is to call jump_label_init() early in arch code. The second call from generic code will just return without doing anything, see the start of jump_label_init(): void __init jump_label_init(void) { struct jump_entry *iter_start = __start___jump_table; struct jump_entry *iter_stop = __stop___jump_table; struct static_key *key = NULL; struct jump_entry *iter; /* * Since we are initializing the static_key.enabled field with * with the 'raw' int values (to avoid pulling in atomic.h) in * jump_label.h, let's make sure that is safe. There are only two * cases to check since we initialize to 0 or 1. */ BUILD_BUG_ON((int)ATOMIC_INIT(0) != 0); BUILD_BUG_ON((int)ATOMIC_INIT(1) != 1); if (static_key_initialized) return; cheers