From patchwork Mon Sep 9 10:53:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 173369 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp4186994ilq; Mon, 9 Sep 2019 03:53:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqzjD/ZxxzcRUp6Ztea9qkkU7o5ndiYrtl2lv28un42IxBOdWJI3eY1ZqQkDQ3RY5xb4EwEF X-Received: by 2002:a50:b30f:: with SMTP id q15mr22201176edd.145.1568026426815; Mon, 09 Sep 2019 03:53:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568026426; cv=none; d=google.com; s=arc-20160816; b=VYZUrnVXB/zVHjOUMDtWqmiKeta2IiZGIGgNfXWjO2gv5mhwZbX+r8jLMsfkHLyeAQ gYpSElceOQB2GR6gqhdFQETpDF4UP7/lJdbfoOeyJn5lIAYxZ+CHXJkzwz21onlKawQG QkL2KrPliqCmb6RSORrZTg2MuVrLURUkeNf2fyXui/Dw4fLZdVpfMyMFGAVClDNSMbq7 IbZdKX8ivaVRt6BVF3t1WdQIqEFPnKUEXY826uXPwMTBU+H5gRnjwVPFbqbXrX8xjjrk YDGKNkTwi6NwBUT8dOgBQZ5uEGrPhBLHIJ4cDHm1sDosoNoT6XTKOP/C7G0t+z1stdAs 1pLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=JUGLW57UsVm5dqkHawVFsjR557zZIe+tiYuceaDlomE=; b=delg+IAuCrDlvbX9dko+eIEoqs7We+hiPidfJ4LfXDVdbkdTkRkVT9z8qLc+MiN1nt ZeXI2Q4h3jpVLwJOTENCsflV4andTWtYPJrDCegjtSMoCJ10QvBGZLKLwAQ7nTrljOJL wrLN/xi0pn7kbZ2Kcq/n3ff3jeHqrAH1lc2etp8Dn7UI6mZB8FMqioQ3WwPCcpDwngHF EHgM+73Zydz8en0+qkuPNzz82be7mBgpK8mhvp9vjej3r2qGORIijm9g0UcEN7S+do+w 3DAw321h8B7MkEgfxxTEuOVFx4jyQ1YL70yYGAYzq0vTivav+iBF6SiM5ee0aRTpUGef 8rYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=L+wtOVxb; 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 y13si6006391ede.219.2019.09.09.03.53.46; Mon, 09 Sep 2019 03:53:46 -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=@nifty.com header.s=dec2015msa header.b=L+wtOVxb; 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 S1729646AbfIIKxm (ORCPT + 28 others); Mon, 9 Sep 2019 06:53:42 -0400 Received: from conuserg-10.nifty.com ([210.131.2.77]:54370 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729369AbfIIKxl (ORCPT ); Mon, 9 Sep 2019 06:53:41 -0400 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-10.nifty.com with ESMTP id x89ArI1L010864; Mon, 9 Sep 2019 19:53:18 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com x89ArI1L010864 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1568026398; bh=JUGLW57UsVm5dqkHawVFsjR557zZIe+tiYuceaDlomE=; h=From:To:Cc:Subject:Date:From; b=L+wtOVxbYdZtfMGs0sRygO3/+lILWFRY73LurajYu/oIclqGD5LOQ25fvH291Dicm amEPS9Bu7gu2bIKTHUQHhxiRH4m9yDcmI/qU8n0sJ9Cv/MbCz+IzYbUNFjicpKlsox Dz3616Du+bZSnYOLfc1EvjvLwGk4zbIqy4hPALas5QxXQigQQNamPGQMb25bj7AqPg /E4zaVk0oZZCm/EZBLYxrGPrYPskkkTQbW0NrqiWNeDfCjYk3SZN9me8c2nTbrFwU0 krmIEiz0mRgFPu1yu4yMaEg+64wZkvKoc/9F63DlrflSpw0oLT1zSsmVjldq2DL3Sn CEU/nw/QQVMSw== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Arnd Bergmann , Denis Efremov , Nicolas Pitre , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 1/2] export.h: remove defined(__KERNEL__) Date: Mon, 9 Sep 2019 19:53:16 +0900 Message-Id: <20190909105317.20473-1-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This line was touched by commit f235541699bc ("export.h: allow for per-symbol configurable EXPORT_SYMBOL()"), but the commit log did not explain why. CONFIG_TRIM_UNUSED_KSYMS works for me without defined(__KERNEL__). Signed-off-by: Masahiro Yamada --- include/linux/export.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.1 Acked-by: Nicolas Pitre diff --git a/include/linux/export.h b/include/linux/export.h index fd8711ed9ac4..cdd98a0d918c 100644 --- a/include/linux/export.h +++ b/include/linux/export.h @@ -20,7 +20,7 @@ extern struct module __this_module; #ifdef CONFIG_MODULES -#if defined(__KERNEL__) && !defined(__GENKSYMS__) +#if !defined(__GENKSYMS__) #ifdef CONFIG_MODVERSIONS /* Mark the CRC weak since genksyms apparently decides not to * generate a checksums for some symbols */ From patchwork Mon Sep 9 10:53:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 173370 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp4187001ilq; Mon, 9 Sep 2019 03:53:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqyAUdR5t+JguUqHWJnoOrQEf2WgyISEn0olRB//OGL0dKbdBrJam/1/dbWT3XnRfNaKhvgC X-Received: by 2002:a17:906:35c2:: with SMTP id p2mr8563624ejb.241.1568026427269; Mon, 09 Sep 2019 03:53:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568026427; cv=none; d=google.com; s=arc-20160816; b=SaxC1MSWjGEsYKrJ6ULyAyF9UpcSVbhExVghs4VRz8pLXj0ZtaiIZyTRgkZpHbQHpx UQWO1ror7PsjybK0mkcrNwTzn9zfGLWrsKq0L+OEjHuFhmWaVte5RQT0D68dwsKDzX+r rPYcx5KyaGx2MYt6B0341e3t/ivMT0SmIfyDzAvZwI+bhXdf7F6H/oJs0A3qQe7pDLJI uZ7VH8m5jslrPvlfkLV9e3jlmW/PDipINuYMoRjQT6gKulX/2EF4XWdy7+KBq55j8m9T VRk50IgBAUO2jXcau0h03QUF6wPbMhJeLGL4kWYCa1Fz16hfG3fORA3HhPV1wwusrAw/ sh5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=TPeYKnTEdhTSobLdVu97GXYNke2Sz7pzo6o03rxMrF8=; b=obX35jblbknqQJnhJHKBdrWNMQQW27i3/de/xmsDmnIbtj73A+h7Nwrp/gBhH0nmC4 HwYiRwa3swIEQzy092sSfF2EOGLdHQt00F1c5MhRxi6Fi2zhywuzg2s46dF5ozJgIrLR d5Bk+3rd3Sj8AmeF0c0pFPWbcB5vZ27m7VaHvAhcbzvJIKVXd/ja+wObCcefpdDXWApm g8IKzaohZzCnZKGLrBidNPYwmRIxA05rYS+2wqjp6Rp4SgCuLaV+G7Cik2hI1fJiohQ8 5qR1ADC67Y8N+9fzrd1DR1P2lKlfnwXSzsKAUWBDuTI3qbsxlSUtyME+gT08SVj+z2/j kMfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=EyHKJvqA; 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 y13si6006391ede.219.2019.09.09.03.53.47; Mon, 09 Sep 2019 03:53:47 -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=@nifty.com header.s=dec2015msa header.b=EyHKJvqA; 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 S1731953AbfIIKxo (ORCPT + 28 others); Mon, 9 Sep 2019 06:53:44 -0400 Received: from conuserg-10.nifty.com ([210.131.2.77]:54371 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729342AbfIIKxm (ORCPT ); Mon, 9 Sep 2019 06:53:42 -0400 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-10.nifty.com with ESMTP id x89ArI1M010864; Mon, 9 Sep 2019 19:53:19 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com x89ArI1M010864 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1568026399; bh=TPeYKnTEdhTSobLdVu97GXYNke2Sz7pzo6o03rxMrF8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EyHKJvqAnMJPsStPeeSPGtTcYtAW8I8GPAqQrIO3Mue5DpnJA5t9UTUaMgF6VLA5N 80apDHEZgfWGdQI+8qKe/6/m8EvFKM7nNPE+qRyUdVFZZ9sZxIB9lBm4yDS5bgnkPY Pmu9LReTTNraDcA4z7F5IpA44ZK3xEKdQib7bgBtiWV5QLpNC1DkEuTqmN+QPkvlkG 700n/RyJ5GBNAUL8HTRPJYyuiEAvYUFZG4AqNNy9fsVxCkzLeue49Vfap5QWSqNfU2 OXmxEu5XU7B59rwPY5UuX+IGQ1OiSQA9IQNhKe1f/0xfTZKIJt+2CcUz2CPQivQkli P53suwAxUT7fA== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Arnd Bergmann , Denis Efremov , Nicolas Pitre , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 2/2] export.h, genksyms: do not make genksyms calculate CRC of trimmed symbols Date: Mon, 9 Sep 2019 19:53:17 +0900 Message-Id: <20190909105317.20473-2-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190909105317.20473-1-yamada.masahiro@socionext.com> References: <20190909105317.20473-1-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Arnd Bergmann reported false-positive modpost warnings detected by his randconfig testing of linux-next: https://lkml.org/lkml/2019/9/6/619 Actually, this happens under the combination of CONFIG_MODVERSIONS=y and CONFIG_TRIM_UNUSED_KSYMS=y since commit 15bfc2348d54 ("modpost: check for static EXPORT_SYMBOL* functions"). For example, arch/arm/config/multi_v7_defconfig + CONFIG_MODVERSIONS=y + CONFIG_TRIM_UNUSED_KSYMS=y produces the following false-positives: WARNING: "__lshrdi3" [vmlinux] is a static (unknown) WARNING: "__ashrdi3" [vmlinux] is a static (unknown) WARNING: "__aeabi_lasr" [vmlinux] is a static (unknown) WARNING: "__aeabi_llsr" [vmlinux] is a static (unknown) WARNING: "ftrace_set_clr_event" [vmlinux] is a static (unknown) WARNING: "__muldi3" [vmlinux] is a static (unknown) WARNING: "__aeabi_ulcmp" [vmlinux] is a static (unknown) WARNING: "__ucmpdi2" [vmlinux] is a static (unknown) WARNING: "__aeabi_lmul" [vmlinux] is a static (unknown) WARNING: "__bswapsi2" [vmlinux] is a static (unknown) WARNING: "__bswapdi2" [vmlinux] is a static (unknown) WARNING: "__ashldi3" [vmlinux] is a static (unknown) WARNING: "__aeabi_llsl" [vmlinux] is a static (unknown) The root cause of the problem is not in the modpost, but in the implementation of CONFIG_TRIM_UNUSED_KSYMS. If there is at least one untrimmed symbol in the file, genksyms is invoked to calculate CRC of *all* the symbols in that file even if some of them have been trimmed due to no caller existing. As a result, .tmp_*.ver files contain CRC of trimmed symbols, thus unneeded __crc* symbols are added to objects. It has been harmless until recently. Since commit 15bfc2348d54 ("modpost: check for static EXPORT_SYMBOL* functions"), it is harmful because the bogus __crc* symbols make modpost call sym_update_crc(), and then new_symbol(), but there is no one that clears the ->is_static member. I gave Fixes to the first commit that uncovered the issue, but the potential problem has long existed since commit f235541699bc ("export.h: allow for per-symbol configurable EXPORT_SYMBOL()"). Fixes: 15bfc2348d54 ("modpost: check for static EXPORT_SYMBOL* functions") Reported-by: Arnd Bergmann Signed-off-by: Masahiro Yamada --- include/linux/export.h | 42 ++++++++++++++----------------------- scripts/genksyms/keywords.c | 6 +----- 2 files changed, 17 insertions(+), 31 deletions(-) -- 2.17.1 Tested-by: Arnd Bergmann diff --git a/include/linux/export.h b/include/linux/export.h index cdd98a0d918c..7d8c112a8b61 100644 --- a/include/linux/export.h +++ b/include/linux/export.h @@ -18,9 +18,6 @@ extern struct module __this_module; #define THIS_MODULE ((struct module *)0) #endif -#ifdef CONFIG_MODULES - -#if !defined(__GENKSYMS__) #ifdef CONFIG_MODVERSIONS /* Mark the CRC weak since genksyms apparently decides not to * generate a checksums for some symbols */ @@ -74,6 +71,12 @@ struct kernel_symbol { }; #endif +#ifdef __GENKSYMS__ + +#define ___EXPORT_SYMBOL(sym, sec) __GENKSYMS_EXPORT_SYMBOL(sym) + +#else + /* For every exported symbol, place a struct in the __ksymtab section */ #define ___EXPORT_SYMBOL(sym, sec) \ extern typeof(sym) sym; \ @@ -83,7 +86,9 @@ struct kernel_symbol { = #sym; \ __KSYMTAB_ENTRY(sym, sec) -#if defined(__DISABLE_EXPORTS) +#endif + +#if !defined(CONFIG_MODULES) || defined(__DISABLE_EXPORTS) /* * Allow symbol exports to be disabled completely so that C code may @@ -117,37 +122,22 @@ struct kernel_symbol { #define __cond_export_sym_0(sym, sec) /* nothing */ #else -#define __EXPORT_SYMBOL ___EXPORT_SYMBOL -#endif -#define EXPORT_SYMBOL(sym) \ - __EXPORT_SYMBOL(sym, "") +#define __EXPORT_SYMBOL(sym, sec) ___EXPORT_SYMBOL(sym, sec) -#define EXPORT_SYMBOL_GPL(sym) \ - __EXPORT_SYMBOL(sym, "_gpl") - -#define EXPORT_SYMBOL_GPL_FUTURE(sym) \ - __EXPORT_SYMBOL(sym, "_gpl_future") +#endif /* CONFIG_MODULES */ +#define EXPORT_SYMBOL(sym) __EXPORT_SYMBOL(sym, "") +#define EXPORT_SYMBOL_GPL(sym) __EXPORT_SYMBOL(sym, "_gpl") +#define EXPORT_SYMBOL_GPL_FUTURE(sym) __EXPORT_SYMBOL(sym, "_gpl_future") #ifdef CONFIG_UNUSED_SYMBOLS -#define EXPORT_UNUSED_SYMBOL(sym) __EXPORT_SYMBOL(sym, "_unused") -#define EXPORT_UNUSED_SYMBOL_GPL(sym) __EXPORT_SYMBOL(sym, "_unused_gpl") +#define EXPORT_UNUSED_SYMBOL(sym) __EXPORT_SYMBOL(sym, "_unused") +#define EXPORT_UNUSED_SYMBOL_GPL(sym) __EXPORT_SYMBOL(sym, "_unused_gpl") #else #define EXPORT_UNUSED_SYMBOL(sym) #define EXPORT_UNUSED_SYMBOL_GPL(sym) #endif -#endif /* __GENKSYMS__ */ - -#else /* !CONFIG_MODULES... */ - -#define EXPORT_SYMBOL(sym) -#define EXPORT_SYMBOL_GPL(sym) -#define EXPORT_SYMBOL_GPL_FUTURE(sym) -#define EXPORT_UNUSED_SYMBOL(sym) -#define EXPORT_UNUSED_SYMBOL_GPL(sym) - -#endif /* CONFIG_MODULES */ #endif /* !__ASSEMBLY__ */ #endif /* _LINUX_EXPORT_H */ diff --git a/scripts/genksyms/keywords.c b/scripts/genksyms/keywords.c index c586d32dd2c3..7a85c4e21175 100644 --- a/scripts/genksyms/keywords.c +++ b/scripts/genksyms/keywords.c @@ -3,11 +3,7 @@ static struct resword { const char *name; int token; } keywords[] = { - { "EXPORT_SYMBOL", EXPORT_SYMBOL_KEYW }, - { "EXPORT_SYMBOL_GPL", EXPORT_SYMBOL_KEYW }, - { "EXPORT_SYMBOL_GPL_FUTURE", EXPORT_SYMBOL_KEYW }, - { "EXPORT_UNUSED_SYMBOL", EXPORT_SYMBOL_KEYW }, - { "EXPORT_UNUSED_SYMBOL_GPL", EXPORT_SYMBOL_KEYW }, + { "__GENKSYMS_EXPORT_SYMBOL", EXPORT_SYMBOL_KEYW }, { "__asm", ASM_KEYW }, { "__asm__", ASM_KEYW }, { "__attribute", ATTRIBUTE_KEYW },