Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4843443iob; Mon, 9 May 2022 03:00:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcidLhfhaOuEN3pAASr3omxvvuCr9aztUDGvanEklUnoOWtlLQCY+tlJKmrnGAFEe83m/g X-Received: by 2002:a17:902:ce8b:b0:15e:c249:1bf8 with SMTP id f11-20020a170902ce8b00b0015ec2491bf8mr15211046plg.52.1652090424932; Mon, 09 May 2022 03:00:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652090424; cv=none; d=google.com; s=arc-20160816; b=Id+nJp5jBJVE2OmpjwpdyOdZRfIurIaQV4NfzkP3pRkAWYP3wfNrHaw+L++mv3Y/t+ QRep+tAUxvclA0bXA+YMweSk+ey2PR8G52vHBIVhNDAs+IwiVHkbcOEwcE5kfLbuq/qp Ft6HryrR9BxG5zFwuTaHwRJ6NN8tKP9uALBanNhP9hyYLGjqlWCpQOpKND0uTtirxamq TzEv4mbCrv12m6cVEErXz4hC9LimLszHcNMML1ljVbMzV1WFDOneJ7h9o/KDZnZ6yB02 lYGikoAAjRVF/nraou9KTkSOWmtw1/MxfQpgpYxRcqw3n8GSjj+J6wVaJ/jGbRm+2nYw xJgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=WKScAw+TRgATw8FrdPEYib92QSxweGtPCPX/6x9uzb4=; b=FAKkNSeWJMkW4l9sFWt2t+narANvazsN+on1BuwgUK77mL1386pltNTMvFctFaJC5E XqIF3PQrjm7ffIjaJUyDaApkd/M97+fdnIr4EgCeZFLApswBMnq5P61+tlT7te3utCx3 KfLN6+j5fEYvH5QSNrOcbL7laul5d0rW2D5Lu0/wmlbMf1GencbYToQ/P8CTD/iF4XNX +/jd1HExcSaPQgerAcdD1e1Beg8iSiEwoBO6h2JzTfF0BeYfzzgQw41iBdlKuAP4pzxx yzbn5ShOzibQnLG2VDxKfYYVmcYU8D1tVggJNsphUNBF74Zr45F+96RYN5OP+m+mKgpl 8EZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CDLgSUrL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id i14-20020aa78d8e000000b0050dd63b1f05si11886177pfr.219.2022.05.09.03.00.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 03:00:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CDLgSUrL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 291EC14916D; Mon, 9 May 2022 02:42:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235748AbiEIBcB (ORCPT + 99 others); Sun, 8 May 2022 21:32:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233967AbiEHXz1 (ORCPT ); Sun, 8 May 2022 19:55:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE7BAE4C for ; Sun, 8 May 2022 16:51:35 -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 4107660F10 for ; Sun, 8 May 2022 23:51:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C35C9C385A4; Sun, 8 May 2022 23:51:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1652053894; bh=JxIt81fSqlUqVYbyW1jrVBaOtkLCBHv625E414LbXt0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=CDLgSUrLYZD1UGkGluaOyvl+lDnASzFx1zpwANIkYSR3VbgaAR9+4+V1lLklDxpWY seL1wBh4N/t8BGTLexCx8ykiDZsxKrmwlhiE0EupkEgy2yObbM+V08FoFxxWhMj3fm mTciTAWrn32A8vLbSrsPD9cuA8yb8wuMH4MQ1qTR/RMlTjpGxBgkbgP4vWxTPSmrgK 4N+kqvYVgEIztYD/umyondYo1oB66CTKZajvOM6EHN9FAzME1nYjoBev6LpHgYH2pa +dV8BECUVFuH5ilGApbVdaxImoFGDskSxsJCt2O67tJgmiPFjK25/oNAuyIgz9fEWO lZj3FNAfB2CKg== Date: Sun, 8 May 2022 16:51:31 -0700 From: Nathan Chancellor To: Vincent MAILHOL Cc: Arnd Bergmann , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , the arch/x86 maintainers , "H . Peter Anvin" , Linux Kernel Mailing List , clang-built-linux , Nick Desaulniers , Tom Rix , Kees Cook Subject: Re: [RESEND PATCH v1] x86/build: add -fno-builtin flag to prevent shadowing Message-ID: References: <20220306171009.1973074-1-mailhol.vincent@wanadoo.fr> <20220508100907.61231-1-mailhol.vincent@wanadoo.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Sun, May 08, 2022 at 09:37:14PM +0900, Vincent MAILHOL wrote: > Hi Arnd, > > +CC: Kees Cook > > On Sun. 8 May 2022 at 19:27, Arnd Bergmann wrote: > > On Sun, May 8, 2022 at 12:09 PM Vincent Mailhol > > wrote: > > > > > > Aside of the __builtin_foo() ones, x86 does not directly rely on any > > > builtin functions. > > > > > > However, such builtin functions are not explicitly deactivated, > > > creating some collisions, concrete example being ffs() from bitops.h, > > > c.f.: > > > > > > | ./arch/x86/include/asm/bitops.h:283:28: warning: declaration of 'ffs' shadows a built-in function [-Wshadow] > > > | 283 | static __always_inline int ffs(int x) > > > > > > This patch adds -fno-builtin to KBUILD_CFLAGS for the x86 > > > architectures in order to prevent shadowing of builtin functions. > > > > > > Signed-off-by: Vincent Mailhol > > > --- > > > FYI, I tested this patch on a "make allyesconfig" for both x86_32 and > > > x86_64. > > > > > > This is a resend. Only difference is that I dropped the RFC flag and > > > added Arnd in CC because he did a similar patch to fix ffs shadow > > > warnings in the past: > > > > > > https://lore.kernel.org/all/20201026160006.3704027-1-arnd@kernel.org/ > > > > I think this is a correct change, but unfortunately it exposes a clang bug > > with -mregparm=3. Nick should be able to provide more details, I think > > he has a plan. > > Interesting. I admittedly did not do extensive tests on clang > but I would have expected the Linux kernel bot to have warned me > on my previous patch. > > I did research on mregparm and clang. I found this thread: > https://lore.kernel.org/r/20220208225350.1331628-9-keescook@chromium.org > > and the associated LLVM issue: > https://github.com/llvm/llvm-project/issues/53645 > > Those threads mention that some clang builtins become unusable > when combining -mregparm=3 and -m32. But I could not find a > bug reference about -mregparm=3 and -fno-builtin combination. > > Could you just double confirm that you indeed saw the issue with > -fno-builtin? If that the case, I am really curious to get the > details :) -ffreestanding implies -fno-builtin; removing -ffreestanding from arch/x86/Makefile for 32-bit x86 caused the problem so I don't think that your patch would cause any issue but I could be missing something. However, doesn't -fno-builtin remove the ability for GCC and clang to perform certain libcall optimizations? I seem to recall this coming up in previous threads but I am having a hard time finding the exact language that I was looking for. This thread seems to be the most recent one that I can remember: https://lore.kernel.org/CAHk-=whn91ar+EbcBXQb9UXad00Q5WjU-TCB6UBzVba682a4ew@mail.gmail.com/ Cheers, Nathan