diff options
Diffstat (limited to 'recipes-kernel/linux/linux-imx-4.14.98/0002-include-linux-module.h-copy-init-exit-attrs-to-.patch')
| -rw-r--r-- | recipes-kernel/linux/linux-imx-4.14.98/0002-include-linux-module.h-copy-init-exit-attrs-to-.patch | 139 |
1 files changed, 139 insertions, 0 deletions
diff --git a/recipes-kernel/linux/linux-imx-4.14.98/0002-include-linux-module.h-copy-init-exit-attrs-to-.patch b/recipes-kernel/linux/linux-imx-4.14.98/0002-include-linux-module.h-copy-init-exit-attrs-to-.patch new file mode 100644 index 000000000..e30d94255 --- /dev/null +++ b/recipes-kernel/linux/linux-imx-4.14.98/0002-include-linux-module.h-copy-init-exit-attrs-to-.patch | |||
| @@ -0,0 +1,139 @@ | |||
| 1 | From mboxrd@z Thu Jan 1 00:00:00 1970 | ||
| 2 | Return-Path: <SRS0=AQQw=UD=vger.kernel.org=stable-owner@kernel.org> | ||
| 3 | X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on | ||
| 4 | aws-us-west-2-korg-lkml-1.web.codeaurora.org | ||
| 5 | X-Spam-Level: | ||
| 6 | X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, | ||
| 7 | DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, | ||
| 8 | SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT | ||
| 9 | autolearn=ham autolearn_force=no version=3.4.0 | ||
| 10 | Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) | ||
| 11 | by smtp.lore.kernel.org (Postfix) with ESMTP id 63BF0C46470 | ||
| 12 | for <stable@archiver.kernel.org>; Tue, 4 Jun 2019 13:25:01 +0000 (UTC) | ||
| 13 | Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) | ||
| 14 | by mail.kernel.org (Postfix) with ESMTP id 3D9B223D29 | ||
| 15 | for <stable@archiver.kernel.org>; Tue, 4 Jun 2019 13:25:01 +0000 (UTC) | ||
| 16 | Authentication-Results: mail.kernel.org; | ||
| 17 | dkim=pass (1024-bit key) header.d=agner.ch header.i=@agner.ch header.b="QWkQ/3jN" | ||
| 18 | Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand | ||
| 19 | id S1727340AbfFDNZA (ORCPT <rfc822;stable@archiver.kernel.org>); | ||
| 20 | Tue, 4 Jun 2019 09:25:00 -0400 | ||
| 21 | Received: from mail.kmu-office.ch ([178.209.48.109]:48348 "EHLO | ||
| 22 | mail.kmu-office.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org | ||
| 23 | with ESMTP id S1727343AbfFDNZA (ORCPT | ||
| 24 | <rfc822;stable@vger.kernel.org>); Tue, 4 Jun 2019 09:25:00 -0400 | ||
| 25 | Received: from trochilidae.toradex.int (unknown [46.140.72.82]) | ||
| 26 | by mail.kmu-office.ch (Postfix) with ESMTPSA id A3CC45C1F29; | ||
| 27 | Tue, 4 Jun 2019 15:24:57 +0200 (CEST) | ||
| 28 | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agner.ch; s=dkim; | ||
| 29 | t=1559654697; | ||
| 30 | h=from:from:reply-to:subject:subject:date:date:message-id:message-id: | ||
| 31 | to:to:cc:cc:mime-version:mime-version:content-type: | ||
| 32 | content-transfer-encoding:content-transfer-encoding: | ||
| 33 | in-reply-to:in-reply-to:references:references; | ||
| 34 | bh=tc6JvYRo2QJoJQVnFd/oGDG0/z6TF30OxAP+nBfruDc=; | ||
| 35 | b=QWkQ/3jNBkysiiD5SMb2UF+0YtSMCbOyP2/dUXeDQChYIal8jUex+QvYHjBh6l4Gff6WwG | ||
| 36 | 3Zd44X6jE/KqxygBkoglOSb/dHwZ5AS8B8vpUM8vh2CzhrW4fD9eguoEIImOJJZ9RHgx0b | ||
| 37 | Gwno+ZPPhuPOcFbSrBwNsKK6mZLGttY= | ||
| 38 | From: Stefan Agner <stefan@agner.ch> | ||
| 39 | To: gregkh@linuxfoundation.org | ||
| 40 | Cc: stable@vger.kernel.org, | ||
| 41 | Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>, | ||
| 42 | Martin Sebor <msebor@gcc.gnu.org>, | ||
| 43 | Jessica Yu <jeyu@kernel.org>, Stefan Agner <stefan@agner.ch> | ||
| 44 | Subject: [PATCH BACKPORT 4.19 2/2] include/linux/module.h: copy __init/__exit attrs to init/cleanup_module | ||
| 45 | Date: Tue, 4 Jun 2019 15:24:41 +0200 | ||
| 46 | Message-Id: <20190604132441.15383-2-stefan@agner.ch> | ||
| 47 | X-Mailer: git-send-email 2.21.0 | ||
| 48 | In-Reply-To: <20190604132441.15383-1-stefan@agner.ch> | ||
| 49 | References: <20190604132441.15383-1-stefan@agner.ch> | ||
| 50 | MIME-Version: 1.0 | ||
| 51 | Content-Transfer-Encoding: 8bit | ||
| 52 | Sender: stable-owner@vger.kernel.org | ||
| 53 | Precedence: bulk | ||
| 54 | List-ID: <stable.vger.kernel.org> | ||
| 55 | X-Mailing-List: stable@vger.kernel.org | ||
| 56 | Archived-At: <https://lore.kernel.org/stable/20190604132441.15383-2-stefan@agner.ch/> | ||
| 57 | List-Archive: <https://lore.kernel.org/stable/> | ||
| 58 | List-Post: <mailto:stable@vger.kernel.org> | ||
| 59 | |||
| 60 | From: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com> | ||
| 61 | |||
| 62 | [ Upstream commit a6e60d84989fa0e91db7f236eda40453b0e44afa ] | ||
| 63 | |||
| 64 | The upcoming GCC 9 release extends the -Wmissing-attributes warnings | ||
| 65 | (enabled by -Wall) to C and aliases: it warns when particular function | ||
| 66 | attributes are missing in the aliases but not in their target. | ||
| 67 | |||
| 68 | In particular, it triggers for all the init/cleanup_module | ||
| 69 | aliases in the kernel (defined by the module_init/exit macros), | ||
| 70 | ending up being very noisy. | ||
| 71 | |||
| 72 | These aliases point to the __init/__exit functions of a module, | ||
| 73 | which are defined as __cold (among other attributes). However, | ||
| 74 | the aliases themselves do not have the __cold attribute. | ||
| 75 | |||
| 76 | Since the compiler behaves differently when compiling a __cold | ||
| 77 | function as well as when compiling paths leading to calls | ||
| 78 | to __cold functions, the warning is trying to point out | ||
| 79 | the possibly-forgotten attribute in the alias. | ||
| 80 | |||
| 81 | In order to keep the warning enabled, we decided to silence | ||
| 82 | this case. Ideally, we would mark the aliases directly | ||
| 83 | as __init/__exit. However, there are currently around 132 modules | ||
| 84 | in the kernel which are missing __init/__exit in their init/cleanup | ||
| 85 | functions (either because they are missing, or for other reasons, | ||
| 86 | e.g. the functions being called from somewhere else); and | ||
| 87 | a section mismatch is a hard error. | ||
| 88 | |||
| 89 | A conservative alternative was to mark the aliases as __cold only. | ||
| 90 | However, since we would like to eventually enforce __init/__exit | ||
| 91 | to be always marked, we chose to use the new __copy function | ||
| 92 | attribute (introduced by GCC 9 as well to deal with this). | ||
| 93 | With it, we copy the attributes used by the target functions | ||
| 94 | into the aliases. This way, functions that were not marked | ||
| 95 | as __init/__exit won't have their aliases marked either, | ||
| 96 | and therefore there won't be a section mismatch. | ||
| 97 | |||
| 98 | Note that the warning would go away marking either the extern | ||
| 99 | declaration, the definition, or both. However, we only mark | ||
| 100 | the definition of the alias, since we do not want callers | ||
| 101 | (which only see the declaration) to be compiled as if the function | ||
| 102 | was __cold (and therefore the paths leading to those calls | ||
| 103 | would be assumed to be unlikely). | ||
| 104 | |||
| 105 | Cc: <stable@vger.kernel.org> # 4.14+ | ||
| 106 | Link: https://lore.kernel.org/lkml/20190123173707.GA16603@gmail.com/ | ||
| 107 | Link: https://lore.kernel.org/lkml/20190206175627.GA20399@gmail.com/ | ||
| 108 | Suggested-by: Martin Sebor <msebor@gcc.gnu.org> | ||
| 109 | Acked-by: Jessica Yu <jeyu@kernel.org> | ||
| 110 | Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com> | ||
| 111 | Signed-off-by: Stefan Agner <stefan@agner.ch> | ||
| 112 | --- | ||
| 113 | include/linux/module.h | 4 ++-- | ||
| 114 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
| 115 | |||
| 116 | diff --git a/include/linux/module.h b/include/linux/module.h | ||
| 117 | index c71044644979..9915397715fc 100644 | ||
| 118 | --- a/include/linux/module.h | ||
| 119 | +++ b/include/linux/module.h | ||
| 120 | @@ -130,13 +130,13 @@ extern void cleanup_module(void); | ||
| 121 | #define module_init(initfn) \ | ||
| 122 | static inline initcall_t __maybe_unused __inittest(void) \ | ||
| 123 | { return initfn; } \ | ||
| 124 | - int init_module(void) __attribute__((alias(#initfn))); | ||
| 125 | + int init_module(void) __copy(initfn) __attribute__((alias(#initfn))); | ||
| 126 | |||
| 127 | /* This is only required if you want to be unloadable. */ | ||
| 128 | #define module_exit(exitfn) \ | ||
| 129 | static inline exitcall_t __maybe_unused __exittest(void) \ | ||
| 130 | { return exitfn; } \ | ||
| 131 | - void cleanup_module(void) __attribute__((alias(#exitfn))); | ||
| 132 | + void cleanup_module(void) __copy(exitfn) __attribute__((alias(#exitfn))); | ||
| 133 | |||
| 134 | #endif | ||
| 135 | |||
| 136 | -- | ||
| 137 | 2.21.0 | ||
| 138 | |||
| 139 | |||
