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=-3.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS,T_DKIMWL_WL_MED, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 A6558C4321D for ; Mon, 20 Aug 2018 22:37:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 46F0C2173D for ; Mon, 20 Aug 2018 22:37:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=wavesemi.onmicrosoft.com header.i=@wavesemi.onmicrosoft.com header.b="GZ+l+TTM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 46F0C2173D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=mips.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726665AbeHUByg (ORCPT ); Mon, 20 Aug 2018 21:54:36 -0400 Received: from mail-by2nam03on0135.outbound.protection.outlook.com ([104.47.42.135]:42758 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726620AbeHUByf (ORCPT ); Mon, 20 Aug 2018 21:54:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wavesemi.onmicrosoft.com; s=selector1-wavecomp-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1uYPkPIfFjwhleqctInd/ocfB8x3ppeJFOh7x9h9lr4=; b=GZ+l+TTMrs1Xbu1wyaxAxvdisdk8jMO8d90iksypHKLjX12vcIFzAR4lzs7pTvwTV6y8+xjkcjQhX8fV0H1Go2/R2VN2XMEzaDWBqx3rFeu/IVJnZ9QmCZNgFf6AGPwxM3QZlNXEtu3+iOkR7Ru1lGCCa/ElyRkKnsNMhvJx4R8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=pburton@wavecomp.com; Received: from pburton-laptop.mipstec.com (4.16.204.77) by DM6PR08MB4939.namprd08.prod.outlook.com (2603:10b6:5:4b::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1059.23; Mon, 20 Aug 2018 22:37:05 +0000 From: Paul Burton To: linux-mips@linux-mips.org Cc: linux-arch@vger.kernel.org, Arnd Bergmann , James Hogan , Masahiro Yamada , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Paul Burton , Ralf Baechle Subject: [PATCH v9 1/2] kbuild: Allow arch-specific asm/compiler.h Date: Mon, 20 Aug 2018 15:36:17 -0700 Message-Id: <20180820223618.22319-2-paul.burton@mips.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180820223618.22319-1-paul.burton@mips.com> References: <20180820183417.dejfsluih7elbclu@pburton-laptop> <20180820223618.22319-1-paul.burton@mips.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [4.16.204.77] X-ClientProxiedBy: SN6PR0102CA0031.prod.exchangelabs.com (2603:10b6:805:1::44) To DM6PR08MB4939.namprd08.prod.outlook.com (2603:10b6:5:4b::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d41d25d3-2be7-485d-9693-08d606ed74ff X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020);SRVR:DM6PR08MB4939; X-Micro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uuHEE8piYB6TnhghqOGl2y8etBbN8yhP6yiwVWnEwUnnLTOSumHQgOGbdrXCfAtui4Jjw7ssJ91UtGKpMaqF+zVyZabHdhtj7YDGq9Yzzetb1errnTxj2VwamxoQ5MGg;4:FFgMmMQdg3qquymLpcJz0KkhfXgaf4icgsPxDaxTtVnirCUmdULGevGourBD2aacxqHkN8fcM6sbmDQYk1fbyTAYWgvPcmOGXvtGQPGuqDEdhyijng9EzXtSkqFUUvN7/A0rkjvpB+93vbitnaAkVSYyBbCQl2Ii+VzOib8ypEaMyiy/30vb0JFWrvjpRzpB2ZwmUAHrv7gUlMVW+PgX/5waBiYW98zfsO+APSSh4sM919LB5vzWAi92CSVA/752FXK88KWD8NPPkUCdUHdrpGgdyWTVTM3Y6jfWeFXw4jjrmZixd6MRhothN3pg1Yhg4fKMIVhr2Jp4j8YDQ5pSSWzZJ0vxYiwS4MPdTSp5HbPcbJ8zOucNTgTBg6C8GGqs X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(192374486261705)(9452136761055)(162533806227266); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(5005006)(8121501046)(3231311)(944501410)(52105095)(10201501046)(93006095)(3002001)(149027)(150027)(6041310)(20161123564045)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699016);SRVR:DM6PR08MB4939;BCL:0;PCL:0;RULEID:;SRVR:DM6PR08MB4939; X-Forefront-PRVS: 0770F75EA9 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(366004)(39840400004)(376002)(346002)(396003)(136003)(199004)(189003)(6512007)(2351001)(2616005)(6306002)(53936002)(36756003)(25786009)(476003)(956004)(4326008)(6486002)(50226002)(44832011)(66066001)(105586002)(48376002)(11346002)(478600001)(966005)(68736007)(6916009)(6666003)(53416004)(47776003)(50466002)(486006)(69596002)(106356001)(446003)(1076002)(5660300001)(16586007)(16526019)(316002)(26005)(2906002)(575784001)(8676002)(2361001)(7736002)(14444005)(8936002)(97736004)(386003)(305945005)(6506007)(6116002)(81156014)(186003)(51416003)(81166006)(76176011)(52116002)(3846002)(54906003)(42882007);DIR:OUT;SFP:1102;SCL:1;SRVR:DM6PR08MB4939;H:pburton-laptop.mipstec.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: wavecomp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DM6PR08MB4939;23:6cJd7oJ1VWUFOGFIOrbG1jjcYD0RLS36H65VljH1O?= =?us-ascii?Q?g0PkpJmdBRK5MSYJ+9dPEVgnayoh2Y8f9lrUTjTYHWQpG03HRCc4RcteDRHV?= =?us-ascii?Q?m9o1+qz0U6jEitYubUByCpMYTQIs6hrXdtL+N9v/x4mN8MVgoFfaR8qAYajH?= =?us-ascii?Q?X/NbYy7tM6vwZF0dsqbLnieYoOCe7+HY6OPaqbspY7IA+RxwfGE5hHzlbGqU?= =?us-ascii?Q?dj7sV84I6uc+u3LPJZZWFmKBDuFPgE/zxcg5CY9Z3+Y8fkWaWQ5yh8jT8EXo?= =?us-ascii?Q?ggQer5CUNjuWhzmhHs7AL5E3MbM4vrpPh1T1AymL7c+v6H3rPwDftfVxNx1t?= =?us-ascii?Q?KA/VbqQMCTmc2LwHhByQImXhgS7H0t0sNjneQOdJUN1sSC4CFRAP++AEVjMu?= =?us-ascii?Q?KppmNwkBtuUsrN3V7sVwrlPAYT+my00XKX4kGcZanmHEowHAtA5EVWmiYupL?= =?us-ascii?Q?NNX3aqiKZlXmdYiFBgJbDuEe3nsmaXo8cjPMn4I4lgKNMgk9kKWcXdtVyO8f?= =?us-ascii?Q?aFhbm0fCK4q2DdWQDY4Lw4BdZpo4xPSboaJtYJafHCUB9jEzbp52Fplg7nIp?= =?us-ascii?Q?9iOj2gRyZS/s2qn/nOe6W4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1j6kBfv0/R6ImB52VcebyxI4GtKM5xQxdy1+ioP7lf/hSoPosT4rhYeupVq+QeVR1SAA66os3zdrPxkDHdAFphX6nfVF9+TezlsTgaScd6mWecn/nnE9CD2mjAouG5CkTX118s1iEsO SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: mips.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2018 22:37:05.2021 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d41d25d3-2be7-485d-9693-08d606ed74ff X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 463607d3-1db3-40a0-8a29-970c56230104 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR08MB4939 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We have a need to override the definition of barrier_before_unreachable() for MIPS, which means we either need to add architecture-specific code into linux/compiler-gcc.h or we need to allow the architecture to provide a header that can define the macro before the generic definition. The latter seems like the better approach. A straightforward approach to the per-arch header is to make use of asm-generic to provide a default empty header & adjust architectures which don't need anything specific to make use of that by adding the header to generic-y. Unfortunately this doesn't work so well due to commit a95b37e20db9 ("kbuild: get out of ") which moved the inclusion of linux/compiler.h to cflags using the -include compiler flag. Because the -include flag is present for all C files we compile, we need the architecture-provided header to be present before any C files are compiled. If any C files can be compiled prior to the asm-generic header wrappers being generated then we hit a build failure due to missing header. Such cases do exist - one pointed out by the kbuild test robot is the compilation of arch/ia64/kernel/nr-irqs.c, which occurs as part of the archprepare target [1]. This leaves us with a few options: 1) Use generic-y & fix any build failures we find by enforcing ordering such that the asm-generic target occurs before any C compilation, such that linux/compiler_types.h can always include the generated asm-generic wrapper which in turn includes the empty asm-generic header. This would rely on us finding all the problematic cases - I don't know for sure that the ia64 issue is the only one. 2) Add an actual empty header to each architecture, so that we don't need the generated asm-generic wrapper. This seems messy. 3) Give up & add #ifdef CONFIG_MIPS or similar to linux/compiler_types.h. This seems messy too. 4) Include the arch header only when it's actually needed, removing the need for the asm-generic wrapper for all other architectures. This patch allows us to use approach 4, by including an asm/compiler.h header from linux/compiler_types.h after the inclusion of the compiler-specific linux/compiler-*.h header(s). We do this conditionally, only when CONFIG_HAVE_ARCH_COMPILER_H is selected, in order to avoid the need for asm-generic wrappers & the associated build ordering issue described above. The asm/compiler.h header is included after the generic linux/compiler-*.h header(s) for consistency with the way linux/compiler-intel.h & linux/compiler-clang.h are included after the linux/compiler-gcc.h header that they override. [1] https://lists.01.org/pipermail/kbuild-all/2018-August/051175.html Signed-off-by: Paul Burton Cc: Arnd Bergmann Cc: James Hogan Cc: Masahiro Yamada Cc: Ralf Baechle Cc: linux-arch@vger.kernel.org Cc: linux-kbuild@vger.kernel.org Cc: linux-mips@linux-mips.org --- Changes in v9: - Use Kconfig & a #include directive as Masahiro suggested. - Go with asm/compiler.h rather than asm/compiler_types.h as it's really definitions from linux/compiler-*.h that we want to override & the conditional include means we don't need to worry about existing asm/compiler.h headers. - Tweak subject & commit message to reflect the changes above. Changes in v8: - New patch. arch/Kconfig | 8 ++++++++ include/linux/compiler_types.h | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/arch/Kconfig b/arch/Kconfig index c6148166a7b4..c0b56b0d86b0 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -841,6 +841,14 @@ config REFCOUNT_FULL against various use-after-free conditions that can be used in security flaw exploits. +config HAVE_ARCH_COMPILER_H + bool + help + An architecture can select this if it provides an + asm/compiler.h header that should be included after + linux/compiler-*.h in order to override macro definitions that those + headers generally provide. + source "kernel/gcov/Kconfig" source "scripts/gcc-plugins/Kconfig" diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h index fbf337933fd8..66239549d240 100644 --- a/include/linux/compiler_types.h +++ b/include/linux/compiler_types.h @@ -78,6 +78,18 @@ extern void __chk_io_ptr(const volatile void __iomem *); #include #endif +/* + * Some architectures need to provide custom definitions of macros provided + * by linux/compiler-*.h, and can do so using asm/compiler.h. We include that + * conditionally rather than using an asm-generic wrapper in order to avoid + * build failures if any C compilation, which will include this file via an + * -include argument in c_flags, occurs prior to the asm-generic wrappers being + * generated. + */ +#ifdef CONFIG_HAVE_ARCH_COMPILER_H +#include +#endif + /* * Generic compiler-dependent macros required for kernel * build go below this comment. Actual compiler/compiler version -- 2.18.0