Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4621938iob; Sun, 8 May 2022 19:33:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwUjPzfC7lzl+ECYWBysDOIbU874vgm+98ZMgMtQ7dfjvB0F/JrQSfRVGLShkY+GHrzPZbC X-Received: by 2002:a17:903:2002:b0:15c:686f:da1a with SMTP id s2-20020a170903200200b0015c686fda1amr14042128pla.30.1652063594467; Sun, 08 May 2022 19:33:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652063594; cv=none; d=google.com; s=arc-20160816; b=MMvDtL0+dGE+52FaSZuUEELNXLaKlUBytaxnMut7OREfTadWLPaC6kBPvvidG6qZud yVpt08x7K2NvgBHtNXnb6nqojhEWuNlY6FaMTTtGreaMQn1OAYmKqXIDlkh/gBPRN9EH yWNftXd0G6f4+Ux78Sn6xG146qFOBNjQUf+SS9lx1WHYShL5ZVBjrjMFiHjM5up65N0R 5YN/Kmd1LZs0biD4qtX9+4wg0CBRHZHyreLwx+fyBxYYrF7r+ncVFnUguxqYS4G6wJzu tVyBW1ptheO+jaHV8Ub8FHbj8gRis39/HNJnBiCS+JieCt29hPI2wAAp1e1Ut6sbpEqc Kpvw== 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; bh=VuJms/7a1Fox6UxpgPi9Undwrl7KJZiaeog6B+JELcQ=; b=fSwbL7uyaD32LDkZ7B1ISZvU+8xKMfDjAN4Dg/Ck6Yqh30AAH7sGsNZodixVzCx+3C bXcilwQ1n3spXbIhQZy/a8S3zQ8f575YDcfOBTeuX7BpfncyKpXoDP7/wVU2tGV3bVvx WLxps3FakIl93Cffh1EJKeYKmujVmQ8lvVqMkbACNyMuVliJoSFXr2c81OmOzai6Mh7U Z/oJA/OK4UpbFwxVsN3+PxoHKBq+heplZWCOz/523rPcpAPWA47IR16x0xUmVd/f7bSR CSPGipu/UjTbMZloXTTkoTbMvH3QWcRQXYgna7SQrYZySG37WnhmxqlAJYldnXVPsMz4 nJdQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id o22-20020a63fb16000000b0039dc635f2d9si11538884pgh.281.2022.05.08.19.33.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 19:33:14 -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; 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 325F371D9B; Sun, 8 May 2022 19:32:46 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232988AbiEHMlT (ORCPT + 99 others); Sun, 8 May 2022 08:41:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232146AbiEHMlQ (ORCPT ); Sun, 8 May 2022 08:41:16 -0400 Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E2B1261F for ; Sun, 8 May 2022 05:37:26 -0700 (PDT) Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-2ef5380669cso119721757b3.9 for ; Sun, 08 May 2022 05:37:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=VuJms/7a1Fox6UxpgPi9Undwrl7KJZiaeog6B+JELcQ=; b=ybmIW7T5t43ZPNwEQL+rAnQdovWfEUDtovGqS16yWN4UtHFcnKa02ohqPtBFVPjnAd WtjEAbp6oUGVWDjKuIKp30+cLQKUhs1P3jYsnkjYL7LFuID+E9oI6Lv9WkvoIRR4ytYq wqxbDSIzoDeucb9XM+UjJvtZyU8vY6TZq2sSK/NlrrpDg0PwVgQ0GrAN2lvu/1ZfBDkE lOc+YQ3lPGCUY2XRGtl+fntttry2yWMgZrHp/RDfFOt9VFoE90Qrd3hPlluWefbRGRFP BSG19GDwJVbOAZ5rxUESwV5lBRLIZqZjqidgMaSjuo+/uGR5sxvSBPbBf0q7OKPEhNPj vmVQ== X-Gm-Message-State: AOAM5325K+6N8KEzUp50cKzqk6p1rCCIEfSyTheB3M/PvysV9/VT0gRu GQJdVuy39B3Jn4Ca1ht/eVC7LImQ7sIjOqzRUig= X-Received: by 2002:a81:8cf:0:b0:2f4:da59:9eef with SMTP id 198-20020a8108cf000000b002f4da599eefmr10253166ywi.78.1652013445268; Sun, 08 May 2022 05:37:25 -0700 (PDT) MIME-Version: 1.0 References: <20220306171009.1973074-1-mailhol.vincent@wanadoo.fr> <20220508100907.61231-1-mailhol.vincent@wanadoo.fr> In-Reply-To: From: Vincent MAILHOL Date: Sun, 8 May 2022 21:37:14 +0900 Message-ID: Subject: Re: [RESEND PATCH v1] x86/build: add -fno-builtin flag to prevent shadowing To: Arnd Bergmann Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "the arch/x86 maintainers" , "H . Peter Anvin" , Linux Kernel Mailing List , clang-built-linux , Nathan Chancellor , Nick Desaulniers , Tom Rix , Kees Cook Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 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 :) Yours sincerely, Vincent Mailhol