Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp638850pxa; Fri, 21 Aug 2020 17:14:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXmHY30dxItpat4Yk5JSZ4vHxIso35YCDASajkawXUW0VNoJAQX3GQWKKd33plhvN5tTP/ X-Received: by 2002:a17:906:f2cd:: with SMTP id gz13mr71612ejb.49.1598055280588; Fri, 21 Aug 2020 17:14:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598055280; cv=none; d=google.com; s=arc-20160816; b=0TQFVh88ll7JKca/ulYDTIhIEmAGjgrgqj4aeCva74//3Rfe+eFo5bIWi6Qpis2Tbn PZUdl8plIGTf0d29IZKM4Q+EK1g3YksXOFM7q1I2UjEI0hR0xMOmEaVUMPkjGrUE4mU4 bBU4MCZbWd58JZicj6yUo+UP3hAD0oyoTkUYAhWdfRvb1KJZjiQ6jFYKHkhgHWI+vMwB q96C/x4F/kZdFw6gNAu4AKgvmMQEU2HzwBcNfdfM/H92Mgs+DySpv9h9hYknKSxDJ3sc c1i/Q6n2Yu4bJJp5SF+d0TdixbHxlZDeecuWQ0JdGzoFVkb4EQUAFtJIH3yyalh/bUxl qyfw== 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=8s688KoZxryWBri/Ybpi1A7SGlEThSLqWoaty4kYg0c=; b=qwc0oBho5hTfw/5g4l3kkfHd9OrmK2yV6qFIRRCReJOd7kGCiFJu1yrRSKSdNse9dr BRpJSKRzRGtYH02N3oaCy7ofGQXRfBsVsgnIj1qSryjwqGmdEqo0rhRUNkWx6RmTjlSn w9+s6f9XKG0y4h4fu07bv0B9pUD8MLWj1M7IwJ09r6OC6JT467gHG38UFaJONTKJEVc9 M0jogCpcOHMF1noYKVwpQHROngwIT+iLfCJ5YxXy3H4p85/7gE++3ePbVUfyEUSyBsbs 2x56NOzT0HAdrs9fmxAAaROuiNRPK1858MZ1xKwJfHMxLIeXY73k8jHEAH01c39CpYwh aKnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=pliY5fue; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qw15si2248956ejb.481.2020.08.21.17.14.17; Fri, 21 Aug 2020 17:14:40 -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=@google.com header.s=20161025 header.b=pliY5fue; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726799AbgHVAMj (ORCPT + 99 others); Fri, 21 Aug 2020 20:12:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726747AbgHVAMi (ORCPT ); Fri, 21 Aug 2020 20:12:38 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E3F2C061573 for ; Fri, 21 Aug 2020 17:12:36 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id o13so1753767pgf.0 for ; Fri, 21 Aug 2020 17:12:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=8s688KoZxryWBri/Ybpi1A7SGlEThSLqWoaty4kYg0c=; b=pliY5fueHpr0mfqh5IExqAIqLw47d7YXsrz+dL7f3lv7TxV6ISyFx1VfOvN5YwPQzS koZVpF0XpR03lKkCVynFGRhEl9PwxlWSBHs5ZkQNG/oiyqcYHCTH21iD5IajYe1I5AB2 HmFHks1vubeDTItYred4nHLKUodffZZiVrsPAMns+Fwv94PmhOOcmPVVWZuvrR5OUOgH 4KGAylLrzDGXzNsn3+A1IO/tL3ANsqkko9jpDOZtsgjMo6xQrO02Cmig9TLzPhqOUJE5 Dr9aRItUMgFqomMEc3viE/hVmcN5OsmVtJhThfyk3tt8giaXObtKBvxCm7tt+Cl2ig7G gXXg== 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=8s688KoZxryWBri/Ybpi1A7SGlEThSLqWoaty4kYg0c=; b=IDNso/e0K/hxi54oGjcP8blyR+Ou6jeY3tAGhyw+ZOJvZw+xp2ZcReFMVnfzWFx4A/ K3HHqVsofsUxWhYhmK+NoKMfzSfuaGFcQIZ5wHkddw86COpgW63RwhbhMq3JXM5eA6y8 MDG9z62LZj/VgxodDGeG1/vN++rjfmRqbPUh+6QuFtevSBgRvNjFoOYxwJp70oPqmDrX 4yQovctosh+09uA8vtv5Q4ofeV4fSLligLdTJRqxNbkDS0+442WCd+uPEn8qbRbvtOFM QkxUiWa2J4lOiWVyN9lT8dFiWcSC3FMYOBPKcBuQKI4ivcmVY7gCC5PPbVK7n6tCBBOV eXTg== X-Gm-Message-State: AOAM5324n6ZvF6KLkB08ub1ipKLWZBrRKeevbsaM+7CZpoB4sPmHwdDa xwCTtGZ4CqRKD2zIDns2+fRD1TfESPmURpJtV+A2VA== X-Received: by 2002:a63:7d8:: with SMTP id 207mr4088742pgh.263.1598055155611; Fri, 21 Aug 2020 17:12:35 -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: From: Nick Desaulniers Date: Fri, 21 Aug 2020 17:12:23 -0700 Message-ID: Subject: Re: [PATCH 0/4] -ffreestanding/-fno-builtin-* patches To: Linus Torvalds , Arvind Sankar , Masahiro Yamada Cc: Rasmus Villemoes , =?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 Fri, Aug 21, 2020 at 2:39 PM Linus Torvalds wrote: > > 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. For more context for folks at home eating popcorn and enjoying the show: https://github.com/ClangBuiltLinux/linux/issues/876#issuecomment-613049480. And that was specifically with KASAN enabled and doesn't appear to be common behavior in clang otherwise (higher threshold). Why the heuristics change for when it seems to be more profitable to roll assignment of contiguous members of the same struct to the same value into a memset, and 2 longs seems to be the threshold for KASAN, I don't know. But I agree that should be fixed on the compiler side, which is why I haven't been pushing the kernel workaround. Everyone's just too busy right now; folks working on kernel sanitizers have their hands full with KCSAN or MTE (on armv8.5) or default initialization, and I'm trying to keep the build green (ie. this series, well the v2 below, and https://lore.kernel.org/lkml/20200812004308.1448603-1-nivedita@alum.mit.edu/ would be much appreciated), and get ready for plumbers, and wrap up my intern's project, and do yearly performance reviews at my day job, and million other things. I've filed https://bugs.llvm.org/show_bug.cgi?id=47280 to discuss more the ability to opt into builtins from a freestanding environment. Now that Arvind has provided an excellent analysis of how the builtin functionality works (bookmarked: https://lore.kernel.org/lkml/20200821172935.GA1411923@rani.riverdale.lan/), were there still objections to add the -fno-builtin-stpcpy flags for clang to the Makefile? I would like to get https://lore.kernel.org/lkml/20200819191654.1130563-1-ndesaulniers@google.com/T/#m76c445f9645f62bc6ffc48ca26949725235688a0 landed so the build is not red for another week. -- Thanks, ~Nick Desaulniers