From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D44A5C433DF for ; Wed, 26 Aug 2020 13:31:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A6E29208E4 for ; Wed, 26 Aug 2020 13:31:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598448700; bh=Avp0kg1mVvqmDWEUA6Vp6vLz7Al8IbcvxsV5ClDevxY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=jZRFYJq322qDHni9mbVREtLl+uGEiBUB7h7bgCKFF2C2eXxmHEgYfNYxEujhjIsex i6QebgobXcnLcfjSfSXglcIhFOffZNlfeA0fAehaRdBfCIddWXQK85ghM7BpmRBHYb /LwtLtDQxTyAStHUEMMF57LOw64+TNghhwdfRVzE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730174AbgHZNbi (ORCPT ); Wed, 26 Aug 2020 09:31:38 -0400 Received: from conssluserg-06.nifty.com ([210.131.2.91]:53856 "EHLO conssluserg-06.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729540AbgHZN3r (ORCPT ); Wed, 26 Aug 2020 09:29:47 -0400 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (authenticated) by conssluserg-06.nifty.com with ESMTP id 07QDTLdk005122; Wed, 26 Aug 2020 22:29:22 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-06.nifty.com 07QDTLdk005122 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1598448562; bh=tNXIFtx4OCOjEbxfaMetiZvvEWEud6dFm6DVPlRG6/U=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=oZS0uyjQxKwmiORelo6ou/ZXRCWhxWwnRb7KpxTe0i7TxSoqM7aDjV7OztApNLg/i /yBwGooq2tgmM7bi7swgUohQ4DxU41AFBoZcWKMTmAIJl1rdj0ClN4S9r/Lue+hbY0 gjuuwr0UEAKcS2e0jfkH/zDXpnO4OmIRMN5PlPhCrutYwgSQJmsKgPcLlW/vAXGcBN Bw7qHjRwEGVfn2JssQ7BsZtFoF0fJ43xiQpUqf2WLefAbzG+RfEuDrTYQVqfMO09Jz kklYUQOz8N7GV/NqXboH11vehTJoQAGBfhzFeCpWufXJjBJa769CV1l8WriyYAlgmt uGd/CIB9LEOjQ== X-Nifty-SrcIP: [209.85.214.178] Received: by mail-pl1-f178.google.com with SMTP id h2so890891plr.0; Wed, 26 Aug 2020 06:29:21 -0700 (PDT) X-Gm-Message-State: AOAM530WoDfiPKpaelZEARqeCGvc39jJXSEq7S/+UOXGPotqvE2Rrf+I qxJkaFmgrBFSvpXmRH56WcazDKJImQ8ZIGTLi10= X-Google-Smtp-Source: ABdhPJyptsNXsluSTO9BSD2NQ/mPRLaxE4KppC7eM2LmlxEpDMBfy8uGyHMsjIWEYawhJuX6U9wNVDjFGHMWbEkzA8w= X-Received: by 2002:a17:90b:11c4:: with SMTP id gv4mr5899331pjb.198.1598448561144; Wed, 26 Aug 2020 06:29:21 -0700 (PDT) MIME-Version: 1.0 References: <20200817220212.338670-1-ndesaulniers@google.com> <76071c24-ec6f-7f7a-4172-082bd574d581@zytor.com> <20200818202407.GA3143683@rani.riverdale.lan> <20200818214146.GA3196105@rani.riverdale.lan> <20200824173450.GA4157679@rani.riverdale.lan> In-Reply-To: From: Masahiro Yamada Date: Wed, 26 Aug 2020 22:28:41 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 0/4] -ffreestanding/-fno-builtin-* patches To: Nick Desaulniers Cc: Linus Torvalds , Arvind Sankar , =?UTF-8?B?RMOhdmlkIEJvbHZhbnNrw70=?= , Eli Friedman , "H. Peter Anvin" , Andrew Morton , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Michal Marek , Linux Kbuild mailing list , LKML , Kees Cook , Tony Luck , Dmitry Vyukov , Michael Ellerman , Joe Perches , Joel Fernandes , Daniel Axtens , Andy Shevchenko , Alexandru Ardelean , Yury Norov , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , Ard Biesheuvel , "Paul E . McKenney" , Daniel Kiper , Bruce Ashfield , Marco Elver , Vamshi K Sthambamkadi Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 25, 2020 at 11:02 PM Nick Desaulniers wrote: > > On Tue, Aug 25, 2020 at 5:30 AM Masahiro Yamada wrote: > > > > On Tue, Aug 25, 2020 at 4:10 PM Nick Desaulniers > > wrote: > > > > > > Masahiro, are you implying that we shouldn't take the > > > -fno-builtin-stpcpy patch, because Clang is inconsistent? (That can be > > > fixed.) Even though -fno-builtin-stpcpy works here as intended? > > > https://lore.kernel.org/lkml/20200817220212.338670-2-ndesaulniers@google.com/ > > > > > > Otherwise we need to provide an implementation of this symbol in the kernel. > > > https://lore.kernel.org/lkml/20200815020946.1538085-1-ndesaulniers@google.com/ > > > > > > Please, pick your poison. > > > > > > > > I am not a compiler expert. > > > > Nor am I sure if I am the right person who makes this decision. > > But, if so, I would choose the latter. > > (implement stpcpy() in the kernel) > > > > I was addressed last night, so > > I should write up my thoughts. > > > > I do not think -fno-builtin-stpcpy is a > > general solution. > > > > -fno-builtin-stpcpy will work for now > > because only Clang implements the transformation > > from 'sprintf(dest, "%s", str)' into > > 'stpcpy(dest, str) - dest'. > > > > If GCC implements it some day, > > we would run into a problem because > > in GCC, it is not -fno-builtin-stpcpy, but > > -fno-builtin-sprintf that disables that optimization. > > > > In this regard, 'KBUILD_CFLAGS += -fno-builtin-sprintf' > > would be more future-proof, but it is potentially > > an overkill. > > We want to disable optimization from sprintf() to stpcpy(), > > but we may still benefit from the optimization from > > sprintf() into something else. > > > > > > Linus is uncomfortable with this kind of compiler magic. > > If we take compiler's freedom away, > > -ffreestanding is a big hammer to solve this problem. > > > > If we welcome the compiler's optimization, > > we should implement stpcpy(), bcmp(), and whatever > > until we solve all link errors. > > Speculating that -ffreestanding is untenable, submitted v3: > https://lore.kernel.org/lkml/20200825135838.2938771-1-ndesaulniers@google.com/T/#u > -- > Thanks, > ~Nick Desaulniers FYI: Andrew Morton picked up this patch. -- Best Regards Masahiro Yamada