Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp566942pxa; Fri, 21 Aug 2020 14:48:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwT+YZqaJEc8/JSccCwmegYvsJVu65Kooz8UaOoCeJZBW4fR0vAJR9wkHxVWDTXffO/Ll8m X-Received: by 2002:a17:906:6cd:: with SMTP id v13mr4752611ejb.307.1598046530285; Fri, 21 Aug 2020 14:48:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598046530; cv=none; d=google.com; s=arc-20160816; b=Mb3aNz4F9tgRp6BUaf8TpW+6MVqD5NwRkNSZqha9hj/jZ67Pqt4aG3syiRF9kB19/k ptjmjQJe0hMU9oSuSDTa+AnlSOka3aB/Yjl2Hb7Eq2qgN05oC+DhFOcov9rcurFxyNT6 a2jDoNWN0YNbH9H4oSYcXl2aUwX95pE0nzQQNYlOE0RJogKfWSaUxMQyBwgsyn8BNahV adW+1h0fU4oHIReyBWrgA82wqcLhgQa86+TBDkifFvY4kO5fiwMVRrgLDJ8YNqDVQRAL lFE3UBkqXsBIgr0VYoKzvA7RSP2s9FaLcj0Ju34uAIeaH4I1Umm/iPNBlV5kT78PtxRW VhPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=fmQQDVMXbn1xkliDoKeEU74auHxtHQpL4ZkAUewHmqw=; b=k9134dR8H1a4mhLBoNEYRAmmQ1R4f4xM5Bc9V/VULitQuKXdK0miAkXsQJHbDrpTWr Ym5HDpSNYq7pfKzu8ejDC8zwHSGULTOa3mpfKQQKEfuRlf08EOSuD2AP/AVC8dvYxiL5 bkyua6VuVIrs2ir0l9oqXN+MUBQ+d3a16WjntGqZDjhvdF/G4/si6G2WOfKfNp7Dbeom ffdkAw7OvO5GWUzBfpQ0RIye2IZYhfrx6ddzc6yKE+Q6UEExDrfkt5TlRsdbKmDlZeq/ tO5myrHtXG9zW9iTsOiixP5yTow6jmWhACefWRhQEj3TJlCtcssPPI7dGAXaBNqyJlCI whkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=gfwHC9xe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h18si2089937edw.184.2020.08.21.14.48.27; Fri, 21 Aug 2020 14:48:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=gfwHC9xe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726730AbgHUVoh (ORCPT + 99 others); Fri, 21 Aug 2020 17:44:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726433AbgHUVoh (ORCPT ); Fri, 21 Aug 2020 17:44:37 -0400 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 911F0C061573 for ; Fri, 21 Aug 2020 14:44:36 -0700 (PDT) Received: by mail-ed1-x543.google.com with SMTP id w14so2264969eds.0 for ; Fri, 21 Aug 2020 14:44:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=fmQQDVMXbn1xkliDoKeEU74auHxtHQpL4ZkAUewHmqw=; b=gfwHC9xeYNz7EUpsz/d5a69ffJsRioVxivkh2vW/TF4IoWRw3IP7tqtfK1M2BdovRD BqR5TXoGfgnoGPiVUutu4293iBXetWkpFRZW47K9qMBDXtc3lD7qcD5MTZFqIHAqEy7Z fvQROxcppyhgOJ17j77yZkQ1SOQxSLwO/qOY0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fmQQDVMXbn1xkliDoKeEU74auHxtHQpL4ZkAUewHmqw=; b=LTGKdXbGXPrxXIXaWQ5r0roi+T02jDalazsPsUJ7hZJX+LcBHMJjHv0u/TuqhxArQD vLhw7B8JSwpIsLjldwwovvLOt5If9FS07aoJo3kgAvylthBz4wiqWzSBe3y5pyyh+odj gO8jolRWXFodHe4baEb2sdj17GljUFNhdVj92tm2P/Wf9MLgvCGR3FFKUsZyCZrGcND+ RuxgqzT4cEIhqILdauBjKS9Gh1nWc595XlUZDAHbg5pj/Xz8HVbyLptLiYSmv8mJRM7R h7Q82VuKLDnDG/yQgABiJMtUgBllSS0eIvxle9mM9LJUWLHOCjCCIpdJafUzV3U1kq2a VuCQ== X-Gm-Message-State: AOAM532SKravcUu+zNjUG3c19UOrAvlDc6HvH4LgYui2HaNMQTXEYUV0 S28PnWhV5u0RbnJP0JaFeat5VHqJQLT7nw== X-Received: by 2002:a05:6402:501:: with SMTP id m1mr4554819edv.99.1598046274595; Fri, 21 Aug 2020 14:44:34 -0700 (PDT) Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com. [209.85.218.45]) by smtp.gmail.com with ESMTPSA id j21sm107141eja.109.2020.08.21.14.44.34 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 21 Aug 2020 14:44:34 -0700 (PDT) Received: by mail-ej1-f45.google.com with SMTP id o23so4194360ejr.1 for ; Fri, 21 Aug 2020 14:44:34 -0700 (PDT) X-Received: by 2002:a2e:7615:: with SMTP id r21mr2253045ljc.371.1598045972531; Fri, 21 Aug 2020 14:39:32 -0700 (PDT) MIME-Version: 1.0 References: <20200818202407.GA3143683@rani.riverdale.lan> <20200818214146.GA3196105@rani.riverdale.lan> <20200820175617.GA604994@rani.riverdale.lan> <20200821172935.GA1411923@rani.riverdale.lan> <20200821195712.GB1475504@rani.riverdale.lan> In-Reply-To: <20200821195712.GB1475504@rani.riverdale.lan> From: Linus Torvalds Date: Fri, 21 Aug 2020 14:39:16 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 0/4] -ffreestanding/-fno-builtin-* patches To: Arvind Sankar Cc: Rasmus Villemoes , Nick Desaulniers , =?UTF-8?B?RMOhdmlkIEJvbHZhbnNrw70=?= , Eli Friedman , "H. Peter Anvin" , Masahiro Yamada , 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 Fri, Aug 21, 2020 at 12:57 PM Arvind Sankar wrote: > > Look, four stores into memset(), yeah that's a bit weird. I didn't think > you meant "four" literally. But in any case, that has nothing to do with > the topic at hand. It would be just as bad if it was a 16-byte structure > being initialized with an out-of-line memset() call. Actually, I mis-remembered. It wasn't four stores. It was two. We have this lovely "sas_ss_reset()" function that initializes three fields in a structure (two to zero, one to '2'). And we used it in a critical place that didn't allow function calls (because we have magic rules with the SMAP instructions). And clang turned the initalization into a memset(). Which then triggered our "you can't do that here" check on the generated code. This is the kind of special rules we sometimes can have for code generation, where the compiler really doesn't understand that no, you can't just replace this code sequence with a function call, because there are things going on around it that really mean that the code should be generated the way we wrote it. > But coming back to the actual topic: it is fine if the compiler turns > four stores into __builtin_memset(). A size-16 or -32 __builtin_memset() > will get inlined anyway. There's a lot of garbage here if you look > closely: check out what gcc does to initialize a 7-character array with > zeros at -Os. Yeah. The reason we had to make -Os be a non-preferred thing is because gcc has some really sad things it does when optimizing for size. I happen to believe that I$ matters, but -Os made _such_ a mess of things that it was untenable to use ;( Linus