Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp2927983imw; Sun, 17 Jul 2022 21:08:09 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tsqIZgby/8/gIPIDLGpjwFCk5LOFsxr423q6BMUD8RuPevKGOq8WUqpKiG49OmiC7tcq+M X-Received: by 2002:a17:90a:1c01:b0:1f1:bf54:67ff with SMTP id s1-20020a17090a1c0100b001f1bf5467ffmr5491210pjs.172.1658117289281; Sun, 17 Jul 2022 21:08:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658117289; cv=none; d=google.com; s=arc-20160816; b=UtexZ4S2ppO/ebFEDDXlV5u4eeT5Rn91ABv8Ya4om7XsI78FMZfH5W2joiPNRzyhjT EcSTuItkRqtIi8HrlB5QyPp5iUfwb0qixTRkyk3BRso8DdsEtD1uciUb+iUhaT1+22+U g7AjWDBWkYGamF2H2DKbI9wLXi+ZOQ4JT/n7901YaHiiXMk+H/SZCXmEC1EB62swDTyi SVtQkyX5mhljYqyOMo9VdTquuShc8Sfgy4GS+eiqRHYX6BSviWQaGnrBAGyAsYPKA/11 VwT2F01xlL8tWAN29SA++ZuZ5HVAgxZzzjG3jlixekL+rQoStEX69GcmBkbG8PnwlD+U SAkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=PAhbVquV8KMmPT0KbTUCb3rhFdvrE7pS8SUJl2k86NQ=; b=ZeimoMADSdnSIrsoesH3ai4kZ3QMEWkTVP2FDDy/maM5gpixQ5pxXa5sbAM8FmPDrK ofdWSBEXkC7lstTwkRBjUlWsZ6e+7+DCGsij4/IQ7UrzlhxssjxRwOHxPswX9ldeaECH CJI5+erKkHQWx6jhpBr0AhMmYtgzBg/yUbwCdwk/86WFJ9Kopbp70qOematge2HLk1nf V/Yxg5/ZkEDKjZYW6AHqzu9Cbov+SKvf1+No8MZoH5nOL2LdB/jGj7uLFm6kosa6XUAh Ckgs86CVjSGd3TMwpAlKfmCiM5kHqqatUFQ4xQZEKTDnHCulAIuxV8wf9701OCPooo4R 4Odw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ellerman.id.au header.s=201909 header.b=abNf9MX4; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mh1-20020a17090b4ac100b001efacc53b2esi15815556pjb.25.2022.07.17.21.07.55; Sun, 17 Jul 2022 21:08:09 -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=@ellerman.id.au header.s=201909 header.b=abNf9MX4; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231821AbiGRDwr (ORCPT + 99 others); Sun, 17 Jul 2022 23:52:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229482AbiGRDwp (ORCPT ); Sun, 17 Jul 2022 23:52:45 -0400 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 049D613CE1; Sun, 17 Jul 2022 20:52:44 -0700 (PDT) Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4LmSj62Gn2z4xdJ; Mon, 18 Jul 2022 13:52:42 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ellerman.id.au; s=201909; t=1658116362; bh=PAhbVquV8KMmPT0KbTUCb3rhFdvrE7pS8SUJl2k86NQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=abNf9MX4GToZ6jiZBngBosnaGO7J6cYxeNUtHJjScudZr25fDWl24rBpyIX65VBb8 UsLGOhmSjfXpcn6B8TuwACWUDoTD+0uOnbXkAK7zW5vL8jMsCQQIrHpH/DKoofWkAJ Wa5uTJqVo6voEQzV+NIjrLGnWPWntFlxcdKDzmte+G7ez220tFzclj2p7XzHQU518/ L9h0KiQLxI94FEBrFBpFVy84BHz1Vj69336+PshS8riZ1OA5d4TwpO+ntrmWF8ftlH cUYoLH9Y0AL0ldtOSxCReqfi8u0gC0ITOvkL31Y17LJ/2IBL5EJsQGVCSw2mrBdMC0 naA3RyWOj+3dQ== From: Michael Ellerman To: Segher Boessenkool , Linus Torvalds Cc: Sudip Mukherjee , Kees Cook , linux-kernel , Paul Mackerras , linux-hardening@vger.kernel.org, linuxppc-dev Subject: Re: mainline build failure of powerpc allmodconfig for prom_init_check In-Reply-To: <20220717195448.GB25951@gate.crashing.org> References: <20220717195448.GB25951@gate.crashing.org> Date: Mon, 18 Jul 2022 13:52:38 +1000 Message-ID: <87k08bdqm1.fsf@mpe.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS 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 Segher Boessenkool writes: > On Sun, Jul 17, 2022 at 07:44:22AM -0700, Linus Torvalds wrote: >> On Sun, Jul 17, 2022 at 2:13 AM Sudip Mukherjee >> wrote: >> > I was trying to check it. With gcc-11 the assembly code generated is >> > not using memset, but using __memset. >> > But with gcc-12, I can see the assembly code is using memset. One >> > example from the assembly: >> >> You could try making the 'args' array in 'struct prom_args' be marked >> 'volatile'. >> >> Ie something like this: >> >> --- a/arch/powerpc/kernel/prom_init.c >> +++ b/arch/powerpc/kernel/prom_init.c >> @@ -115,6 +115,6 @@ struct prom_args { >> __be32 service; >> __be32 nargs; >> __be32 nret; >> - __be32 args[10]; >> + volatile __be32 args[10]; >> }; >> >> because I think it's just the compilers turning the small loop over >> those fields into a "memset()". > > Yes. See > near the end: > Most of the compiler support routines used by GCC are present in > libgcc, but there are a few exceptions. GCC requires the freestanding > environment provide memcpy, memmove, memset and memcmp. Finally, if > __builtin_trap is used, and the target does not implement the trap > pattern, then GCC emits a call to abort. > > Can't we simply have a small simple implementation of these functions in > arch/powerpc/boot/? This stuff is not performance-critical, and this is > not the first time we hit these problems. prom_init.c isn't in arch/powerpc/boot :) It's linked into the kernel proper, but we want it to behave like a pre-boot environment (because not all boot paths run it) which is why we restrict what symbols it can call. We could have a prom_memset() etc. but we'd need to do some tricks to rewrite references to memset() to prom_memset() before linking. cheers