From patchwork Fri May 5 19:46:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 98657 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp292652qge; Fri, 5 May 2017 12:48:13 -0700 (PDT) X-Received: by 10.99.97.6 with SMTP id v6mr5391704pgb.186.1494013693828; Fri, 05 May 2017 12:48:13 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 144si6012850pfa.118.2017.05.05.12.48.13; Fri, 05 May 2017 12:48:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752658AbdEETsM (ORCPT + 6 others); Fri, 5 May 2017 15:48:12 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:54100 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751653AbdEETsK (ORCPT ); Fri, 5 May 2017 15:48:10 -0400 Received: from wuerfel.lan ([78.42.17.5]) by mrelayeu.kundenserver.de (mreue002 [212.227.15.129]) with ESMTPA (Nemesis) id 0MdTH9-1dP58Y2x5n-00IRos; Fri, 05 May 2017 21:47:57 +0200 From: Arnd Bergmann To: Ben Hutchings Cc: stable@vger.kernel.org, Paul Gortmaker , Rusty Russell , Arnd Bergmann Subject: [PATCH 3.16-stable 04/87] modpost: don't emit section mismatch warnings for compiler optimizations Date: Fri, 5 May 2017 21:46:22 +0200 Message-Id: <20170505194745.3627137-5-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170505194745.3627137-1-arnd@ar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k= Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Paul Gortmaker Commit 4a3893d069b788f3570c19c12d9e986e8e15870f upstream. Currently an allyesconfig build [gcc-4.9.1] can generate the following: WARNING: vmlinux.o(.text.unlikely+0x3864): Section mismatch in reference from the function cpumask_empty.constprop.3() to the variable .init.data:nmi_ipi_mask which comes from the cpumask_empty usage in arch/x86/kernel/nmi_selftest.c. Normally we would not see a symbol entry for cpumask_empty since it is: static inline bool cpumask_empty(const struct cpumask *srcp) however in this case, the variant of the symbol gets emitted when GCC does constant propagation optimization. Fix things up so that any locally optimized constprop variants don't warn when accessing variables that live in the __init sections. [arnd: adapted text_sections definition to 3.18] Signed-off-by: Paul Gortmaker Signed-off-by: Rusty Russell Signed-off-by: Arnd Bergmann --- scripts/mod/modpost.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) -- 2.9.0 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 14e3f53ebf17..2241d036b63a 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -930,6 +930,10 @@ static const char *init_sections[] = { ALL_INIT_SECTIONS, NULL }; static const char *init_exit_sections[] = {ALL_INIT_SECTIONS, ALL_EXIT_SECTIONS, NULL }; +/* all text sections */ +static const char *const text_sections[] = { ALL_INIT_TEXT_SECTIONS, + ALL_EXIT_TEXT_SECTIONS, TEXT_SECTIONS, NULL }; + /* data section */ static const char *data_sections[] = { DATA_SECTIONS, NULL }; @@ -948,6 +952,7 @@ static const char *data_sections[] = { DATA_SECTIONS, NULL }; static const char *head_sections[] = { ".head.text*", NULL }; static const char *linker_symbols[] = { "__init_begin", "_sinittext", "_einittext", NULL }; +static const char *const optim_symbols[] = { "*.constprop.*", NULL }; enum mismatch { TEXT_TO_ANY_INIT, @@ -1105,6 +1110,17 @@ static const struct sectioncheck *section_mismatch( * This pattern is identified by * refsymname = __init_begin, _sinittext, _einittext * + * Pattern 5: + * GCC may optimize static inlines when fed constant arg(s) resulting + * in functions like cpumask_empty() -- generating an associated symbol + * cpumask_empty.constprop.3 that appears in the audit. If the const that + * is passed in comes from __init, like say nmi_ipi_mask, we get a + * meaningless section warning. May need to add isra symbols too... + * This pattern is identified by + * tosec = init section + * fromsec = text section + * refsymname = *.constprop.* + * **/ static int secref_whitelist(const struct sectioncheck *mismatch, const char *fromsec, const char *fromsym, @@ -1137,6 +1153,12 @@ static int secref_whitelist(const struct sectioncheck *mismatch, if (match(tosym, linker_symbols)) return 0; + /* Check for pattern 5 */ + if (match(fromsec, text_sections) && + match(tosec, init_sections) && + match(fromsym, optim_symbols)) + return 0; + return 1; }