Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp2466867imd; Fri, 2 Nov 2018 11:55:02 -0700 (PDT) X-Google-Smtp-Source: AJdET5dWzc3+NAcKhk0n4889qY3cr2OYu4qshY4S4afYnSYz7JtfdPTsWyEbznVC97LPpWEZ3aoc X-Received: by 2002:a62:ab05:: with SMTP id p5-v6mr12836209pff.211.1541184902763; Fri, 02 Nov 2018 11:55:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541184902; cv=none; d=google.com; s=arc-20160816; b=wxYT1KGEhrsKkKfSaApxLJix8JVrAekFlyHVvbC1nO3LFwYMAbuZvQeGvhMvfvEDeW mxColhH6z8rjvx2GBoSQFV0HAjYdASpay4I9FTMolBEINNK1G3UjsYq/BMdKcPtXWfpj 03hwRt5Dvm9oAARFjGrBtIULGNFrVwVl51/4yZYD22JRaIZQZD62Gdaxj86/Dum4Fyql WWHxcbUb6Oq6Bf6xiQy11j8GnlzYwwZU4xA9MaY7LXTSpyKQv5sH7rVKIny6LApkfG4n 8gvOPe7wniDgWngKLdCnaL39AY8mrMFhTyf8+Uf9FDnBsWuYHEvoSmowmzTNujLsWBwl ri2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jeG8j551OYJTbh5BYSHE3cH4V158VKxva7mCjrgh1Xc=; b=aTfOJetmSJOdmwKexQV6MXn5T2sa3T5+1MhAvKYJkJPo5IYdGBiK1vcRYnMlcg/X6h I2uuQD0RJ0FFOhVZ3mm0nzwhz1GvlLdyb89/KWVWRvBv4dbQ7FvjSGmUxOeD6oYMfBHF qL7FmwzJ9t0Rm3IyF/hbxUaPt5nqeVyyp5972Sfc53Mr9UUFeG12JsKzvOGi36KkjyAX ckLrQStET4mEzaxkqqefoFQ612aa54n9AOp1uw6rTYOJfjyV96L5G62p7c0l3stMUMuJ 8NPfI3Oflry8hs8Tjuu6iW5nK3sXl4oLkmNkr088KeivoodYGCnl/IPUm2PnkIU/FL9E DWAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vF2RtogE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b13-v6si4219565plm.316.2018.11.02.11.54.48; Fri, 02 Nov 2018 11:55:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vF2RtogE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730545AbeKCEBY (ORCPT + 99 others); Sat, 3 Nov 2018 00:01:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:57290 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726081AbeKCEBY (ORCPT ); Sat, 3 Nov 2018 00:01:24 -0400 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8EB9520848; Fri, 2 Nov 2018 18:53:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541184788; bh=UnStb8iSjgMhmvGho6Kd013wBhCng5A2W8hpvXIHyIg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vF2RtogERt7pST935hlR9O9Zmjlhb688Ak5QVmkN137DOKPUDWbAMrQ482btYnqNR RDEKIja+OcZSMCtlZ21ZKKx399l1gEKbQyx2LGy6zpQV56CbxB51kpRyfQ2t1wx+xO o4FYlmJD58xs+H4GadXTSnGmV6QnIlcWCzIVWkPo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paul Burton , Masahiro Yamada , Arnd Bergmann , James Hogan , Ralf Baechle , linux-arch@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-mips@linux-mips.org, Sasha Levin Subject: [PATCH 4.14 096/143] compiler.h: Allow arch-specific asm/compiler.h Date: Fri, 2 Nov 2018 19:34:41 +0100 Message-Id: <20181102182905.564377295@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181102182857.064326086@linuxfoundation.org> References: <20181102182857.064326086@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 04f264d3a8b0eb25d378127bd78c3c9a0261c828 ] 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 28128c61e08e ("kconfig.h: Include compiler types to avoid missed struct attributes") which caused linux/compiler_types.h to be included in the compilation of every C file via the -include linux/kconfig.h flag in c_flags. 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 Reviewed-by: Masahiro Yamada Patchwork: https://patchwork.linux-mips.org/patch/20269/ 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 Signed-off-by: Sasha Levin --- arch/Kconfig | 8 ++++++++ include/linux/compiler_types.h | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/arch/Kconfig b/arch/Kconfig index 40dc31fea90c..77b3e21c4844 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -965,4 +965,12 @@ 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" diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h index 6b79a9bba9a7..4be464a07612 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.17.1