Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2674000pxa; Mon, 17 Aug 2020 16:14:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwu4JTM2fFXFeDr6fJo2K2S5N5fxKXDHNrHIO5cGtdOFbmq2ItFFPfb/M37uRwvbkE9SXgp X-Received: by 2002:a50:ef0a:: with SMTP id m10mr17517181eds.226.1597706079215; Mon, 17 Aug 2020 16:14:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597706079; cv=none; d=google.com; s=arc-20160816; b=f/YAGX+jVCaQMCZTTSoLEp1RlWaKiJ+CPkQj6Un7OVjZQLS94rfYHIStdgpbaszJL0 JoeNuSjrNAuskzldCSsVMFH7ym5QhSRs1CSzN+iIQLSbQtJ2qYGdFhDOkh7JihwmvsuZ WwwrR3P4N4LWSDi0EpUWyX3WmQvjafWTAQ1vRYQ7KPrsF1vpsJGBOUjL/6rwBqaUpgPv TnFi1SxpR2ry0FigsQJsr0sLzY/0Hl9L4XXfXHGu9LpMmC5YCPSJi8JHZ2I8xXf79QVt Ez7XTyG5LmCLBIAYaKcrmKou/h1f2QcdPyBYvcYtwxEFqb7vo1jW6p+MMy5JJp/n6M2I Ou4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:mime-version :message-id:date:dkim-signature; bh=SCGP1B0GabBPIIHG5VJ2o7cUGzZ8S7iKHRNNa+xeYyE=; b=MpiBYflyUaSCv4B5Z9ZsIHzSQFVOBEfFRISTs3ivwvU14qMayqaxR+FRnjiqLN8rFW hNrIQSCldc/R37CUssdMWpvoVkOtZR7f9UBUVNz1e7K6m129cQHPavhbmG76tWFXsjbT qsbeLU5MUAf7h//olQ2ZWG3NiGWUunB5Se/7XC5BdG82Kt/qtbS0FOiI/j+W3N+JXGsE Bnlnyf56pWsHlMUnvcSt/SfA++WTc8sey/gFs4M/fuxw6VaIdlZbaMkNDrSp2PJfeATn grhTjhorq/dP797JsDL4K0E8bRdd2GiuetT+/nwHFTE4+yuefrpc4xQD8gzK1hebDILa v5EA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ImA5y6OS; 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 bx26si12048244edb.588.2020.08.17.16.14.16; Mon, 17 Aug 2020 16:14:39 -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=ImA5y6OS; 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 S1729270AbgHQWCX (ORCPT + 99 others); Mon, 17 Aug 2020 18:02:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729255AbgHQWCS (ORCPT ); Mon, 17 Aug 2020 18:02:18 -0400 Received: from mail-pj1-x1049.google.com (mail-pj1-x1049.google.com [IPv6:2607:f8b0:4864:20::1049]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA25FC061342 for ; Mon, 17 Aug 2020 15:02:18 -0700 (PDT) Received: by mail-pj1-x1049.google.com with SMTP id gf16so11141498pjb.7 for ; Mon, 17 Aug 2020 15:02:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=SCGP1B0GabBPIIHG5VJ2o7cUGzZ8S7iKHRNNa+xeYyE=; b=ImA5y6OSZJsSxIPHsXDdYNsmOWF03t/GCF1wydDTkMNPnwFYHmAoquiUE1s1V7h8jH UXrSnaNxxzBdcEXBZ2qo9Qw+m9RgBQRony04zbdg/4XMUNjpbSmAUDgMqTmRtowMDeGJ kewoEMjj+PZYqbE9CSY+3R4Cg7XUc+y5DEPvMt22tvVMtoJS1y9zcahOkuDtmU+eVBQd cUjgV6APd8twafZwkYF+WYlhVyFPKtSEVN6aqA2n6/C5tzcICXlukjmNMzL9NRiRIMmt fcouD5X6n88sMsMTcROVsdKKWRTxpSeWeFuALYEGTrJYLJFF1ez8g5m6ZZJUFKsWVr1Y Q9lA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=SCGP1B0GabBPIIHG5VJ2o7cUGzZ8S7iKHRNNa+xeYyE=; b=Pf4acSP9QFPZgXdNCiGpGgrUZ201xytmP1PBGOjDpYkb3oPhHAplhZoA4ST+Fqti6X wng8yxD/rYV2dqgJExE9XENR9r5xWBCusnw6B/Ruo2A/bnyoWPHpCUAWM4Z0ThhL5fSi hkJZYFNKr40BbcXu8sGMUtKv9/xZJpZ4I97+6yMT5dHiNuDDBiohb1aK0rFYNuGXZRxY NgJwur2nf2qVEzMxAoiVO/6XeOGotuV+0x7ZF3aD6XZDpqtZ3SYkiU/x0VRYBt4wnQsi CuuVM2zub1W+vkXTSPD4cTPODuAW5wjfiPIoGCTqk+PIMO64JMXRsF2yhkNsDSkX9xAZ rpgw== X-Gm-Message-State: AOAM5329wKILlm424Ci5G08xQGaImwjqEVwbo1TMsx31S7X32N0bjft8 M2+DX0jQDNUcFAYK6Go+xLtDuSH+IPOGfZ1e7Z0= X-Received: by 2002:a62:6142:: with SMTP id v63mr13080841pfb.179.1597701737995; Mon, 17 Aug 2020 15:02:17 -0700 (PDT) Date: Mon, 17 Aug 2020 15:02:08 -0700 Message-Id: <20200817220212.338670-1-ndesaulniers@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.220.ged08abb693-goog Subject: [PATCH 0/4] -ffreestanding/-fno-builtin-* patches From: Nick Desaulniers To: Masahiro Yamada , Andrew Morton , Thomas Gleixner , Ingo Molnar , Borislav Petkov Cc: Michal Marek , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Kees Cook , Tony Luck , Dmitry Vyukov , Michael Ellerman , Joe Perches , Joel Fernandes , Daniel Axtens , Arvind Sankar , Andy Shevchenko , Alexandru Ardelean , Yury Norov , x86@kernel.org, "H . Peter Anvin" , Ard Biesheuvel , "Paul E . McKenney" , Daniel Kiper , Bruce Ashfield , Marco Elver , Vamshi K Sthambamkadi , Andi Kleen , Linus Torvalds , "=?UTF-8?q?D=C3=A1vid=20Bolvansk=C3=BD?=" , Eli Friedman , Nick Desaulniers 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 -ffreestanding typically inhibits "libcall optimizations" where calls to certain library functions can be replaced by the compiler in certain cases to calls to other library functions that may be more efficient. This can be problematic for embedded targets that don't provide full libc implementations. -ffreestanding inhibits all such optimizations, which is the safe choice, but generally we want the optimizations that are performed. The Linux kernel does implement a fair amount of libc routines. Instead of -ffreestanding (which makes more sense in smaller images like kexec's purgatory image), prefer -fno-builtin-* flags to disable the compiler from emitting calls to functions which may not be defined. If you see a linkage failure due to a missing symbol that's typically defined in a libc, and not explicitly called from the source code, then the compiler may have done such a transform. You can either implement such a function (ie. in lib/string.c) or disable the transform outright via -fno-builtin-* flag (where * is the name of the library routine, ie. -fno-builtin-bcmp). Patch 1 unbreaks the build with ToT clang, which has been red all weekend, by adding -fno-builtin-stpcpy. Patch 2 is a revert but adds -fno-builtin-bcmp. Patch 3 does the same for x86 purgatory. Patch 4 removes -ffreestanding from i386. The first patch makes sense for Kbuild, the second maybe akpm@, the third and forth for x86. Not sure who should pick up the series (they can be merged out of order, technically) but I really need the first patch soon. The 3 latter patches are cleanups. Nick Desaulniers (4): Makefile: add -fno-builtin-stpcpy Revert "lib/string.c: implement a basic bcmp" x86/boot: use -fno-builtin-bcmp x86: don't build CONFIG_X86_32 as -ffreestanding Makefile | 7 +++++++ arch/x86/Makefile | 3 --- arch/x86/boot/Makefile | 1 + arch/x86/boot/string.c | 8 -------- include/linux/string.h | 3 --- lib/string.c | 20 -------------------- 6 files changed, 8 insertions(+), 34 deletions(-) -- 2.28.0.220.ged08abb693-goog