From patchwork Fri May 5 11:57:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 98629 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp81170qge; Fri, 5 May 2017 04:58:14 -0700 (PDT) X-Received: by 10.84.230.131 with SMTP id e3mr65704152plk.100.1493985494779; Fri, 05 May 2017 04:58:14 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m25si5435892pli.193.2017.05.05.04.58.14; Fri, 05 May 2017 04:58:14 -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 S1752519AbdEEL6N (ORCPT + 6 others); Fri, 5 May 2017 07:58:13 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:54538 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753385AbdEEL6L (ORCPT ); Fri, 5 May 2017 07:58:11 -0400 Received: from wuerfel.lan ([78.42.17.5]) by mrelayeu.kundenserver.de (mreue102 [212.227.15.145]) with ESMTPA (Nemesis) id 0LzJrN-1eAvtM2lkX-014UJ2; Fri, 05 May 2017 13:57:33 +0200 From: Arnd Bergmann To: gregkh@linuxfoundation.org Cc: stable@vger.kernel.org, Paul Gortmaker , Rusty Russell , Arnd Bergmann Subject: [PATCH 3/9] [3.18-stable] modpost: don't emit section mismatch warnings for compiler optimizations Date: Fri, 5 May 2017 13:57:19 +0200 Message-Id: <20170505115725.1424772-4-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170505115725.1424772-1-arnd@arndb.de> References: <20170505115725.1424772-1-arnd@arndb.de> X-Provags-ID: V03:K0:8u2r1o5b+LJAyCrmCmMLBMU3SnJ0DAx/lk6GA9TNd4WrqKuQZ+4 8OlQ+EWvtRJnXiJln1geVQjgUzqlJy9c0WtMM/Wd4VzafXc7uiwrHQ1SDbSO5JaxXHQi5Xa sW5jsjvtVe3VHG66dCTGiX04JMkIcpeebLu/UOKB/HfUu5ZqDR3m7iszQCatRc2DvM7K/FZ piPILzfq9YtLr0ec43O5Q== X-UI-Out-Filterresults: notjunk:1; V01:K0:ExjBIkRORvA=:DLgOffAHP1hc+04LDn2uPd GdqVo9Cn9hceyEvdhxke0gebDPmtM2o+jSV1FFgVVaGCZULTf1nVFH7JhsNbVZXNlvsNHFsUW XYBi74v/46bBwZTrVCBlg0JgLHfF4egAitL1w5Fd95lPFmN7BLYtllN31shc9pb27J6LDxNyD RpeZ8MWA3FBwX/300sX9UYWu+Z6C/lUJfqyvNKVRGBukwygZPOYFG60sam75xK80wePXVwtYq pYDQYsFMhcyapZwJOcZUFIm+dU5nlWC2iynmeeCItF0/6oY9ubi/ktgoGjMSzFNIWoh7kLlQ7 LsihBVRWWNSzFLt3tMzwFkHsd+2n4OiJSKxDfzKlAGCbdE+mvwHv5Ub31nrK1yhsxHYVUEKea e/dkSlFsuGZ59pUIQJdowHvkXze6KEdrryNWrQtBvFFTcYicBqVcA9pe6oQdn5HHYBCYmafnp RnacsIbAQMFU17Eu+YlwOMe9HoeWNV8G5A7ePV21DNQ8l9mGLcwOMk3PhR0TGjbmrchDFaKOm Io8xiraGQluRmNJJ+SU3BNAPmvaL0s895g5AVkJ34L9qDyeJhomBO2xRRrAXR83K7THzTwaFe TG3uwJft+gn2DcM6QNJTifaT7C6sozVjYuRVsaqwm2c3kFXKEhcN3V8SQu0eo48cnQLeVFVgf o9DsMpFVRiElF04ohtku/lscfT5QPOaA6CCz7msIDq8Rm28gldrNAiOzu1V2FKk9PkxM= 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 688b93cc06fe..a8a54640ba5f 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -902,6 +902,10 @@ static const char *const init_sections[] = { ALL_INIT_SECTIONS, NULL }; static const char *const 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 *const data_sections[] = { DATA_SECTIONS, NULL }; @@ -920,6 +924,7 @@ static const char *const data_sections[] = { DATA_SECTIONS, NULL }; static const char *const head_sections[] = { ".head.text*", NULL }; static const char *const linker_symbols[] = { "__init_begin", "_sinittext", "_einittext", NULL }; +static const char *const optim_symbols[] = { "*.constprop.*", NULL }; enum mismatch { TEXT_TO_ANY_INIT, @@ -1077,6 +1082,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, @@ -1109,6 +1125,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; }