Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp327442iog; Wed, 15 Jun 2022 03:06:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxop/xIbljhPmH+uTH8KizHjfJ4s7kTwOwyvD+RwXgELEKJBn0WXEUOH12lT+lG3qMk83Nn X-Received: by 2002:a05:6a00:2341:b0:51b:dd96:c7c1 with SMTP id j1-20020a056a00234100b0051bdd96c7c1mr9369912pfj.14.1655287618359; Wed, 15 Jun 2022 03:06:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655287618; cv=none; d=google.com; s=arc-20160816; b=YyH4fwMAEthMmtj9Z2oDYqlMK8Scx5IyWyh8BY1kh1vfNsh6CDuy74BBBBieVN94E6 FR06YnFv/3BxdlAmqpCa0sUZm1qYfeSVX2PxKYP+XJCTcmEnbY2PkVFSL3nUN5WmWC8I EEDsLXGD+UPm2VRtZosT5hsMJi2Xmrg875hyfiCPPin/yksSTE3Bpqzz571qz/b/yynL AuFi2KdmkYgADpHNt8NNXsLxNaj+z908cDuzUGNQ1tJBkIZNDIkRXrxfcaIAs2pWr6ON pts/bejx2TrQNKAxf03Ys6LAab6kZwXy+mnd5qijR/jPZzzga3YtSNc8RexmhxfBgkOq IDgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=bXEtlviVgVsiCha9XlFKMqYB5Tx57oChpVxd4y8upwA=; b=dgEQd4LyY5GdyQmGUKQkRP5ETpNzSFcP19EBYx3GaUfsY2JhV1NuotmtdHhdboCjoh H6rc3Fdi0iw87jI8vSGUnhKkOBFYhWjv8LF1NZYGSwlSzagWx9PVHnt5yuNUFhedLI/L IRIBMt1nYgXT32sisI96JqcxRaVGgF/UiXh7/BB32Db448stUdo2gJSIPZVseVKGvao6 g6ruu6zUBRI9upLiQNKup0EWwTLf9TndT3zSf3hQ4efGnEQAI31sjeBImn2I0qtJ3WRr MaPBtPEofKkB9pvCEaUftE9qqO58w1YCbd7DApGhisp/o+oCM/o6gx4fVbgqPTaQ277B QwfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jZJIPayW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d24-20020a631d18000000b003fc8c5109adsi16719988pgd.315.2022.06.15.03.06.46; Wed, 15 Jun 2022 03:06:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jZJIPayW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346802AbiFOJ7R (ORCPT + 99 others); Wed, 15 Jun 2022 05:59:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346430AbiFOJ61 (ORCPT ); Wed, 15 Jun 2022 05:58:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95D9A2F000; Wed, 15 Jun 2022 02:58:26 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3124F61AEF; Wed, 15 Jun 2022 09:58:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94E2CC341C4; Wed, 15 Jun 2022 09:58:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1655287105; bh=olVZaX+Ei3ossRIrggwze0jxjL/US0T//Qz67+mOFlQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=jZJIPayWVQ5/uvWzTsXk2GXO2sVyZp2zdsdRMUBOukqLc1IJvMVxC0GaQ2CfhpOKX WjeadKesJaONRVFX79itG71aU0200AjMOnpXI7N8c68bZEbPsLzoxwX4iOM9M3J84n CfQ184wQ1twtbwyD1VuQgJULVP0q57ZSusCdvKHZu3VwQFB2jH9JzLVdk+ZlrCO0Bj 7XazbzKbPITavSC3EUcGTRFEAzcAzF+c5m7wWhl2k6Io1g5rC+XDUhciy5htDzhO14 rvpgWxFqRWz8p+mrURM0JD9B99S1qYSGcm15e+ThED14KICLunCWnZEZhBbjPpjz5b eHjauPt3FPg0A== Received: by mail-oo1-f52.google.com with SMTP id g9-20020a4adc89000000b0041bef879199so1988856oou.10; Wed, 15 Jun 2022 02:58:25 -0700 (PDT) X-Gm-Message-State: AOAM532hEaS0giRS28MX2VnZ/qa9ZKC6UWP0ghiQZrK5U/pca7uwgU/7 ZVAFRvStQw0jPUn7g3vzO0aeELYGQbNfhoOQgAQ= X-Received: by 2002:a4a:c983:0:b0:41b:9e6f:44ab with SMTP id u3-20020a4ac983000000b0041b9e6f44abmr3689475ooq.98.1655287104725; Wed, 15 Jun 2022 02:58:24 -0700 (PDT) MIME-Version: 1.0 References: <20220608104512.1176209-1-ardb@kernel.org> <20220608104512.1176209-4-ardb@kernel.org> In-Reply-To: From: Ard Biesheuvel Date: Wed, 15 Jun 2022 11:58:13 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 3/3] jump_label: make initial NOP patching the special case To: Mark Rutland Cc: Linux Kernel Mailing List , Peter Zijlstra , Thomas Bogendoerfer , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , "open list:MIPS" , "open list:S390" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 15 Jun 2022 at 11:52, Mark Rutland wrote: > > On Wed, Jun 08, 2022 at 12:45:12PM +0200, Ard Biesheuvel wrote: > > Instead of defaulting to patching NOP opcodes at init time, and leaving > > it to the architectures to override this if this is not needed, switch > > to a model where doing nothing is the default. This is the common case > > by far, as only MIPS requires NOP patching at init time. On all other > > architectures, the correct encodings are emitted by the compiler and so > > no initial patching is needed. > > > > Signed-off-by: Ard Biesheuvel > > --- > > Documentation/staging/static-keys.rst | 3 --- > > arch/arc/kernel/jump_label.c | 13 ------------- > > arch/arm/kernel/jump_label.c | 6 ------ > > arch/arm64/kernel/jump_label.c | 11 ----------- > > arch/mips/include/asm/jump_label.h | 2 ++ > > arch/parisc/kernel/jump_label.c | 11 ----------- > > arch/riscv/kernel/jump_label.c | 12 ------------ > > arch/s390/kernel/jump_label.c | 5 ----- > > arch/x86/kernel/jump_label.c | 13 ------------- > > kernel/jump_label.c | 14 +++----------- > > 10 files changed, 5 insertions(+), 85 deletions(-) > > I have one minor comment below, but either way this is a nice cleanup (and I'm > always happy to see __weak functions disappear), so FWIW: > > Acked-by: Mark Rutland > > [...] > > > diff --git a/kernel/jump_label.c b/kernel/jump_label.c > > index b1ac2948be79..ff8576c00893 100644 > > --- a/kernel/jump_label.c > > +++ b/kernel/jump_label.c > > @@ -332,17 +332,9 @@ static int __jump_label_text_reserved(struct jump_entry *iter_start, > > return 0; > > } > > > > -/* > > - * Update code which is definitely not currently executing. > > - * Architectures which need heavyweight synchronization to modify > > - * running code can override this to make the non-live update case > > - * cheaper. > > - */ > > -void __weak __init_or_module arch_jump_label_transform_static(struct jump_entry *entry, > > - enum jump_label_type type) > > -{ > > - arch_jump_label_transform(entry, type); > > -} > > +#ifndef arch_jump_label_transform_static > > +#define arch_jump_label_transform_static(entry, type) > > +#endif > > It might be slightly better to make this a static inline stub so that we always > get the compiler to type-check it, e.g. > > | #ifndef arch_jump_label_transform_static > | static inline void arch_jump_label_transform_static(struct jump_entry *entry, > | enum jump_label_type type) > | { > | /* nothing to do on most architectures */ > | } > | #define arch_jump_label_transform_static arch_jump_label_transform_static > | #endif > Yeah, good point. Note that the current patch is broken because of this, as the empty string is not a statement, and so the if binds to the following line (I got a couple of bot warnings about this)