From patchwork Tue Sep 3 15:06:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Matthias_M=C3=A4nnich?= X-Patchwork-Id: 11128239 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B0C1614F7 for ; Tue, 3 Sep 2019 15:08:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8F23F2339D for ; Tue, 3 Sep 2019 15:08:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="BYUxI3Mr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729693AbfICPH2 (ORCPT ); Tue, 3 Sep 2019 11:07:28 -0400 Received: from mail-ua1-f74.google.com ([209.85.222.74]:33810 "EHLO mail-ua1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729538AbfICPH1 (ORCPT ); Tue, 3 Sep 2019 11:07:27 -0400 Received: by mail-ua1-f74.google.com with SMTP id r3so656487uae.1 for ; Tue, 03 Sep 2019 08:07:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=XfkuPAzUg0cWTsSII8UxfvUGODgh66Dt0PdffmfP8ds=; b=BYUxI3MrD4U+BDkDqOah6HY4Bw3pPfx8gK6OvtG3TXQTUxrmLgeaUM0pE8m3+shX6r a/m7v+yD6KHnNo+2ozvu18HPRGjOHvfslAqkS5IswlmTxW49zalq4r2NEg5CdB8oQkZJ pAapdfiGvhDtqiSUAMffWLVrPJkbibNXNTmF7aR7IOEMKWP7svSLCs82N06Qiv1VX1m/ 5vbEakyc4zD9nCo5vutlPMx63M7oy2fEEfWiVlMm+JhP/hBcAkGEKvPBGRSCkvuGoziM 55t1VRH8ly44VKnD8mGx4rlnGVDfwwQI67M2aRWLr9QioEbqXOZ2lppuU09AhqkaX4S+ GWeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=XfkuPAzUg0cWTsSII8UxfvUGODgh66Dt0PdffmfP8ds=; b=Ic0cYTYJ8lCTbcX+VyXT92tj4cDFKlEXLMZAvDO/XYXmux+m4POldKm++vh/mLiBJz Zzv/65YmJVUWeAL8IV2sK9h4R/fIB08RnUxepLSjo25ykvknAXeDPOuKajsPqwk3LMv0 bRDPO2GJoX9gi7PE7j/0Dh8cbfI64TcFUeDb2Li8WhpIHIdfPVC5OpuNQZGIC8VVuHjD i1ge6wnHTiId+v2xl1IuymQlmEJvSETFBixxX4QRfaJ1MEWU7OcQ5eFonHBDc/YSmsh1 ze0rxKguI2WvlMBQYhGP2ZaNLhSc62ZLs/NqufOVu9MliLOqvRXg5NR3Z+ceh9CJ39kU 7EUQ== X-Gm-Message-State: APjAAAWiKfalKnV1SEEneEsO+n53ki3EGcNkQP3rJTOUKVO4lsfOG4HG Y8/i0gLOznKjf0M6IVAV84krUzr+2JrjvQ== X-Google-Smtp-Source: APXvYqwpDXpoU/tekMTm7cq8cLvZxAh2XQiVvLYuHJwsk/oxVDEJdK9XflLHkcImHQpKAl2LR/xVFUqqHgFc+A== X-Received: by 2002:a67:fb90:: with SMTP id n16mr19342370vsr.7.1567523246431; Tue, 03 Sep 2019 08:07:26 -0700 (PDT) Date: Tue, 3 Sep 2019 16:06:27 +0100 In-Reply-To: <20190903150638.242049-1-maennich@google.com> Message-Id: <20190903150638.242049-2-maennich@google.com> Mime-Version: 1.0 References: <20180716122125.175792-1-maco@android.com> <20190903150638.242049-1-maennich@google.com> X-Mailer: git-send-email 2.23.0.187.g17f5b7556c-goog Subject: [PATCH v4 01/12] module: support reading multiple values per modinfo tag From: Matthias Maennich To: linux-kernel@vger.kernel.org Cc: kernel-team@android.com, maennich@google.com, arnd@arndb.de, gregkh@linuxfoundation.org, jeyu@kernel.org, joel@joelfernandes.org, lucas.de.marchi@gmail.com, maco@android.com, sspatil@google.com, will@kernel.org, yamada.masahiro@socionext.com, linux-kbuild@vger.kernel.org, linux-modules@vger.kernel.org, linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, linux-watchdog@vger.kernel.org Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org Similar to modpost's get_next_modinfo(), introduce get_next_modinfo() in kernel/module.c to acquire any further values associated with the same modinfo tag name. That is useful for any tags that have multiple occurrences (such as 'alias'), but is in particular introduced here as part of the symbol namespaces patch series to read the (potentially) multiple namespaces a module is importing. Reviewed-by: Joel Fernandes (Google) Reviewed-by: Martijn Coenen Reviewed-by: Greg Kroah-Hartman Signed-off-by: Matthias Maennich --- kernel/module.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/kernel/module.c b/kernel/module.c index 9ee93421269c..3ee507c0a92f 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -2481,7 +2481,8 @@ static char *next_string(char *string, unsigned long *secsize) return string; } -static char *get_modinfo(struct load_info *info, const char *tag) +static char *get_next_modinfo(const struct load_info *info, const char *tag, + char *prev) { char *p; unsigned int taglen = strlen(tag); @@ -2492,13 +2493,25 @@ static char *get_modinfo(struct load_info *info, const char *tag) * get_modinfo() calls made before rewrite_section_headers() * must use sh_offset, as sh_addr isn't set! */ - for (p = (char *)info->hdr + infosec->sh_offset; p; p = next_string(p, &size)) { + char *modinfo = (char *)info->hdr + infosec->sh_offset; + + if (prev) { + size -= prev - modinfo; + modinfo = next_string(prev, &size); + } + + for (p = modinfo; p; p = next_string(p, &size)) { if (strncmp(p, tag, taglen) == 0 && p[taglen] == '=') return p + taglen + 1; } return NULL; } +static char *get_modinfo(const struct load_info *info, const char *tag) +{ + return get_next_modinfo(info, tag, NULL); +} + static void setup_modinfo(struct module *mod, struct load_info *info) { struct module_attribute *attr; From patchwork Tue Sep 3 15:06:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Matthias_M=C3=A4nnich?= X-Patchwork-Id: 11128147 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 984B014F7 for ; Tue, 3 Sep 2019 15:07:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6EE4A23774 for ; Tue, 3 Sep 2019 15:07:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="BfHZbHR9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729727AbfICPHb (ORCPT ); Tue, 3 Sep 2019 11:07:31 -0400 Received: from mail-vs1-f74.google.com ([209.85.217.74]:40171 "EHLO mail-vs1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729722AbfICPHa (ORCPT ); Tue, 3 Sep 2019 11:07:30 -0400 Received: by mail-vs1-f74.google.com with SMTP id m24so771270vsp.7 for ; Tue, 03 Sep 2019 08:07:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=WpyyM8zjm4wtK5J690VZrM2s4HSiRGUxtkfpxo7zqKI=; b=BfHZbHR97xdAxRIdMmVlOwnyxzrq6JmTVQXv4Fg5l+zyV5iGtr+ffZtaPXCj9UClr2 HBUSLv4AD6uEOTct4s9MJL4qHRMnroaVu+TZIx303DWUAe4bpNCNRpUHhZ9N4Tsfw/Y/ Z6Vl7K0uLitFGrCDhFrtgVbzEuLb86F4SbiR/ZyZL1VWiGNb2INzfCvhjRkamz5g8g9V ZxSOL4PIYiq9rEmw7LakJ4nI5VTYE9x0PyJ1U1mF3bZvU06pcbLkUqx4S7Ipp2030F5D fDto7fdbBtKazVvfo9UtqoXJuWsdHzGzIKJXbV3i6+U+1a/n53z3B7gUU4jhyJb8Msqc F3VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=WpyyM8zjm4wtK5J690VZrM2s4HSiRGUxtkfpxo7zqKI=; b=K70aDhYKTSmwJQ7/S70TLOwzPAo5/6sD2cvK6g0ohmGo8qROITv66h28MR3evKqU+Z HXhh8As/hQU14Ip4YvA+3J0iQxn+4W67jRLhtKeiR8rO4KHqIJNry1qx9RErwWvSa4Gb J0FmMwHmvAJU35VnG8qEDdMl8ik2dMzHkO/GtcJffupLP8jhHQV91bYv2eOmr7/k5yK6 ENLNfLoOtH4daKaB/ewF+sptQQzyNfpCtY6x7pKU5kjbMRaok3GG1AusbyPBR06KrY3z jJUaEOykw1il4gzod7f9bKLUkokJ7x0h6fUbeoJ2z5y6TE/9g12ZNOqeWohrhs1JSKny VzqA== X-Gm-Message-State: APjAAAUfFutgBRzDMCw0f9HdC7bqn3F7eGFABMVHYXJKL7DsEBpCLYU7 za9ByTE/IOxF2xBLflAhjH95vuTWamYq2Q== X-Google-Smtp-Source: APXvYqyRkq3kWS+md+h91R4aNGpmWOv69BYMd6kwCtRNSe5sfbB/Zp3Ra0kJkrdzunasXK4SgK6CH0kEQqjxxg== X-Received: by 2002:a1f:5c0d:: with SMTP id q13mr3631221vkb.38.1567523249382; Tue, 03 Sep 2019 08:07:29 -0700 (PDT) Date: Tue, 3 Sep 2019 16:06:28 +0100 In-Reply-To: <20190903150638.242049-1-maennich@google.com> Message-Id: <20190903150638.242049-3-maennich@google.com> Mime-Version: 1.0 References: <20180716122125.175792-1-maco@android.com> <20190903150638.242049-1-maennich@google.com> X-Mailer: git-send-email 2.23.0.187.g17f5b7556c-goog Subject: [PATCH v4 02/12] export: explicitly align struct kernel_symbol From: Matthias Maennich To: linux-kernel@vger.kernel.org Cc: kernel-team@android.com, maennich@google.com, arnd@arndb.de, gregkh@linuxfoundation.org, jeyu@kernel.org, joel@joelfernandes.org, lucas.de.marchi@gmail.com, maco@android.com, sspatil@google.com, will@kernel.org, yamada.masahiro@socionext.com, linux-kbuild@vger.kernel.org, linux-modules@vger.kernel.org, linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, linux-watchdog@vger.kernel.org Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org This change allows growing struct kernel_symbol without wasting bytes to alignment. It also concretized the alignment of ksymtab entries if relative references are used for ksymtab entries. struct kernel_symbol was already implicitly being aligned to the word size, except on x86_64 and m68k, where it is aligned to 16 and 2 bytes, respectively. As far as I can tell there is no requirement for aligning struct kernel_symbol to 16 bytes on x86_64, but gcc aligns structs to their size, and the linker aligns the custom __ksymtab sections to the largest data type contained within, so setting KSYM_ALIGN to 16 was necessary to stay consistent with the code generated for non-ASM EXPORT_SYMBOL(). Now that non-ASM EXPORT_SYMBOL() explicitly aligns to word size (8), KSYM_ALIGN is no longer necessary. In case of relative references, the alignment has been changed accordingly to not waste space when adding new struct members. As for m68k, struct kernel_symbol is aligned to 2 bytes even though the structure itself is 8 bytes; using a 4-byte alignment shouldn't hurt. I manually verified the output of the __ksymtab sections didn't change on x86, x86_64, arm, arm64 and m68k. As expected, the section contents didn't change, and the ELF section alignment only changed on x86_64 and m68k. Feedback from other archs more than welcome. Co-developed-by: Martijn Coenen Signed-off-by: Martijn Coenen Reviewed-by: Greg Kroah-Hartman Signed-off-by: Matthias Maennich --- arch/m68k/include/asm/export.h | 1 - include/asm-generic/export.h | 8 +++----- include/linux/export.h | 3 ++- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/arch/m68k/include/asm/export.h b/arch/m68k/include/asm/export.h index 0af20f48bd07..b53008b67ce1 100644 --- a/arch/m68k/include/asm/export.h +++ b/arch/m68k/include/asm/export.h @@ -1,3 +1,2 @@ -#define KSYM_ALIGN 2 #define KCRC_ALIGN 2 #include diff --git a/include/asm-generic/export.h b/include/asm-generic/export.h index 294d6ae785d4..63f54907317b 100644 --- a/include/asm-generic/export.h +++ b/include/asm-generic/export.h @@ -4,15 +4,13 @@ #ifndef KSYM_FUNC #define KSYM_FUNC(x) x #endif -#ifdef CONFIG_64BIT -#ifndef KSYM_ALIGN +#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS +#define KSYM_ALIGN 4 +#elif defined(CONFIG_64BIT) #define KSYM_ALIGN 8 -#endif #else -#ifndef KSYM_ALIGN #define KSYM_ALIGN 4 #endif -#endif #ifndef KCRC_ALIGN #define KCRC_ALIGN 4 #endif diff --git a/include/linux/export.h b/include/linux/export.h index fd8711ed9ac4..28a4d2150689 100644 --- a/include/linux/export.h +++ b/include/linux/export.h @@ -52,7 +52,7 @@ extern struct module __this_module; #define __KSYMTAB_ENTRY(sym, sec) \ __ADDRESSABLE(sym) \ asm(" .section \"___ksymtab" sec "+" #sym "\", \"a\" \n" \ - " .balign 8 \n" \ + " .balign 4 \n" \ "__ksymtab_" #sym ": \n" \ " .long " #sym "- . \n" \ " .long __kstrtab_" #sym "- . \n" \ @@ -66,6 +66,7 @@ struct kernel_symbol { #define __KSYMTAB_ENTRY(sym, sec) \ static const struct kernel_symbol __ksymtab_##sym \ __attribute__((section("___ksymtab" sec "+" #sym), used)) \ + __aligned(sizeof(void *)) \ = { (unsigned long)&sym, __kstrtab_##sym } struct kernel_symbol { From patchwork Tue Sep 3 15:06:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Matthias_M=C3=A4nnich?= X-Patchwork-Id: 11128231 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4182514F7 for ; Tue, 3 Sep 2019 15:08:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 221B3215EA for ; Tue, 3 Sep 2019 15:08:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Sq3vmIE3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729113AbfICPHe (ORCPT ); Tue, 3 Sep 2019 11:07:34 -0400 Received: from mail-qk1-f201.google.com ([209.85.222.201]:46855 "EHLO mail-qk1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729715AbfICPHd (ORCPT ); Tue, 3 Sep 2019 11:07:33 -0400 Received: by mail-qk1-f201.google.com with SMTP id n135so18814669qka.13 for ; Tue, 03 Sep 2019 08:07:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=6KFIwWWApjCQfX4bs8S0gCxREVnzqCf121iaZRShrCw=; b=Sq3vmIE3RRW8/0tzAryDYvO6evIP8eSEgKaTM+D/EjC8D0qfLDriKuTZA/b5mqtwJk aRdkKtHKuczfbACLOAhxwIgZDJ53o9A/E9TUG1Bdzg2HvN0R8BBESPo4N0f34P0+l5EK TPxw9a1/q8BY9TSSBPwb0hwdW3mRNp6EVLDyQPjU+ouRKTPeXVZ9jThW+buuKSLlKHcr fLPo01ryJYo6mpHGQwgLdWJaSgr0PrCEcJrMH+veMvbsHH+7LbxNNPYVKezLtFRE10fC hylPZTXDMuJm6WdUOphQ1A1BCgs+u5dp1SUgRp92vfjRUWx92yIdcTMBHFcC6esRqLRm /WdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=6KFIwWWApjCQfX4bs8S0gCxREVnzqCf121iaZRShrCw=; b=Zx5X18lp+RejJxeu+BjRju/l08WMkTx0Ulpt8nNBtaZ43C9gtLwOjmgrknK6u1fNyc aaLnL6SO/0v8/fNlgxFxARb3HtZujbiDuyaoZ7PiFRzjGgbq0Ag7de93eOxF5cycPVh3 IzRWu3RwQol2VvGc+YgYU/awlqa5Xyh473iXMXLQWTj66Wme+Jfbj//OlXmWtcJgUkm1 nbUUylulg1olItuDtWT6ZWHnb02eLpjSCinyoH2YbAJztXLqFWo1loB5eI3t3d8LUKvi PHivL9WiNJUB1sr0blfZHBac0HZP/oEuJV2Yt0lXMfuaPebA8WN6KsOtw2TQT2qAGhkV jKcg== X-Gm-Message-State: APjAAAWltiIHvH0sqQMXlzP1XAOJE9ARHsROKnNgJlx8qPFqb4lOiGQH khTFt8f5VTemqMjWkT7QOILTHoS/WtMNZg== X-Google-Smtp-Source: APXvYqwkGjOjq8i5CnHuf2sFWNeuuy/PHCxP/r2j+xPkkCcu6R9v+4Q7lNDZkL2j2OiB3bjx7xLwNhsBvEQdiQ== X-Received: by 2002:a05:6214:12ca:: with SMTP id s10mr15075192qvv.91.1567523252369; Tue, 03 Sep 2019 08:07:32 -0700 (PDT) Date: Tue, 3 Sep 2019 16:06:29 +0100 In-Reply-To: <20190903150638.242049-1-maennich@google.com> Message-Id: <20190903150638.242049-4-maennich@google.com> Mime-Version: 1.0 References: <20180716122125.175792-1-maco@android.com> <20190903150638.242049-1-maennich@google.com> X-Mailer: git-send-email 2.23.0.187.g17f5b7556c-goog Subject: [PATCH v4 03/12] module: add support for symbol namespaces. From: Matthias Maennich To: linux-kernel@vger.kernel.org Cc: kernel-team@android.com, maennich@google.com, arnd@arndb.de, gregkh@linuxfoundation.org, jeyu@kernel.org, joel@joelfernandes.org, lucas.de.marchi@gmail.com, maco@android.com, sspatil@google.com, will@kernel.org, yamada.masahiro@socionext.com, linux-kbuild@vger.kernel.org, linux-modules@vger.kernel.org, linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, linux-watchdog@vger.kernel.org Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org The EXPORT_SYMBOL_NS() and EXPORT_SYMBOL_NS_GPL() macros can be used to export a symbol to a specific namespace. There are no _GPL_FUTURE and _UNUSED variants because these are currently unused, and I'm not sure they are necessary. I didn't add EXPORT_SYMBOL_NS() for ASM exports; this patch sets the namespace of ASM exports to NULL by default. In case of relative references, it will be relocatable to NULL. If there's a need, this should be pretty easy to add. A module that wants to use a symbol exported to a namespace must add a MODULE_IMPORT_NS() statement to their module code; otherwise, modpost will complain when building the module, and the kernel module loader will emit an error and fail when loading the module. MODULE_IMPORT_NS() adds a modinfo tag 'import_ns' to the module. That tag can be observed by the modinfo command, modpost and kernel/module.c at the time of loading the module. The ELF symbols are renamed to include the namespace with an asm label; for example, symbol 'usb_stor_suspend' in namespace USB_STORAGE becomes 'usb_stor_suspend.USB_STORAGE'. This allows modpost to do namespace checking, without having to go through all the effort of parsing ELF and relocation records just to get to the struct kernel_symbols. On x86_64 I saw no difference in binary size (compression), but at runtime this will require a word of memory per export to hold the namespace. An alternative could be to store namespaced symbols in their own section and use a separate 'struct namespaced_kernel_symbol' for that section, at the cost of making the module loader more complex. Co-developed-by: Martijn Coenen Signed-off-by: Martijn Coenen Reviewed-by: Greg Kroah-Hartman Signed-off-by: Matthias Maennich --- include/asm-generic/export.h | 6 +-- include/linux/export.h | 91 +++++++++++++++++++++++++++++------- include/linux/module.h | 2 + kernel/module.c | 43 +++++++++++++++++ 4 files changed, 123 insertions(+), 19 deletions(-) diff --git a/include/asm-generic/export.h b/include/asm-generic/export.h index 63f54907317b..e2b5d0f569d3 100644 --- a/include/asm-generic/export.h +++ b/include/asm-generic/export.h @@ -17,11 +17,11 @@ .macro __put, val, name #ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS - .long \val - ., \name - . + .long \val - ., \name - ., 0 - . #elif defined(CONFIG_64BIT) - .quad \val, \name + .quad \val, \name, 0 #else - .long \val, \name + .long \val, \name, 0 #endif .endm diff --git a/include/linux/export.h b/include/linux/export.h index 28a4d2150689..d59461e71478 100644 --- a/include/linux/export.h +++ b/include/linux/export.h @@ -20,6 +20,8 @@ extern struct module __this_module; #ifdef CONFIG_MODULES +#define NS_SEPARATOR "." + #if defined(__KERNEL__) && !defined(__GENKSYMS__) #ifdef CONFIG_MODVERSIONS /* Mark the CRC weak since genksyms apparently decides not to @@ -29,13 +31,13 @@ extern struct module __this_module; asm(" .section \"___kcrctab" sec "+" #sym "\", \"a\" \n" \ " .weak __crc_" #sym " \n" \ " .long __crc_" #sym " - . \n" \ - " .previous \n"); + " .previous \n") #else #define __CRC_SYMBOL(sym, sec) \ asm(" .section \"___kcrctab" sec "+" #sym "\", \"a\" \n" \ " .weak __crc_" #sym " \n" \ " .long __crc_" #sym " \n" \ - " .previous \n"); + " .previous \n") #endif #else #define __CRC_SYMBOL(sym, sec) @@ -49,6 +51,16 @@ extern struct module __this_module; * absolute relocations that require runtime processing on relocatable * kernels. */ +#define __KSYMTAB_ENTRY_NS(sym, sec, ns) \ + __ADDRESSABLE(sym) \ + asm(" .section \"___ksymtab" sec "+" #sym "\", \"a\" \n" \ + " .balign 4 \n" \ + "__ksymtab_" #sym NS_SEPARATOR #ns ": \n" \ + " .long " #sym "- . \n" \ + " .long __kstrtab_" #sym "- . \n" \ + " .long __kstrtab_ns_" #sym "- . \n" \ + " .previous \n") + #define __KSYMTAB_ENTRY(sym, sec) \ __ADDRESSABLE(sym) \ asm(" .section \"___ksymtab" sec "+" #sym "\", \"a\" \n" \ @@ -56,32 +68,53 @@ extern struct module __this_module; "__ksymtab_" #sym ": \n" \ " .long " #sym "- . \n" \ " .long __kstrtab_" #sym "- . \n" \ + " .long 0 - . \n" \ " .previous \n") struct kernel_symbol { int value_offset; int name_offset; + int namespace_offset; }; #else +#define __KSYMTAB_ENTRY_NS(sym, sec, ns) \ + static const struct kernel_symbol __ksymtab_##sym##__##ns \ + asm("__ksymtab_" #sym NS_SEPARATOR #ns) \ + __attribute__((section("___ksymtab" sec "+" #sym), used)) \ + __aligned(sizeof(void *)) \ + = { (unsigned long)&sym, __kstrtab_##sym, __kstrtab_ns_##sym } + #define __KSYMTAB_ENTRY(sym, sec) \ static const struct kernel_symbol __ksymtab_##sym \ + asm("__ksymtab_" #sym) \ __attribute__((section("___ksymtab" sec "+" #sym), used)) \ __aligned(sizeof(void *)) \ - = { (unsigned long)&sym, __kstrtab_##sym } + = { (unsigned long)&sym, __kstrtab_##sym, NULL } struct kernel_symbol { unsigned long value; const char *name; + const char *namespace; }; #endif -/* For every exported symbol, place a struct in the __ksymtab section */ -#define ___EXPORT_SYMBOL(sym, sec) \ +#define ___export_symbol_common(sym, sec) \ extern typeof(sym) sym; \ - __CRC_SYMBOL(sym, sec) \ + __CRC_SYMBOL(sym, sec); \ static const char __kstrtab_##sym[] \ __attribute__((section("__ksymtab_strings"), used, aligned(1))) \ - = #sym; \ + = #sym \ + +/* For every exported symbol, place a struct in the __ksymtab section */ +#define ___EXPORT_SYMBOL_NS(sym, sec, ns) \ + ___export_symbol_common(sym, sec); \ + static const char __kstrtab_ns_##sym[] \ + __attribute__((section("__ksymtab_strings"), used, aligned(1))) \ + = #ns; \ + __KSYMTAB_ENTRY_NS(sym, sec, ns) + +#define ___EXPORT_SYMBOL(sym, sec) \ + ___export_symbol_common(sym, sec); \ __KSYMTAB_ENTRY(sym, sec) #if defined(__DISABLE_EXPORTS) @@ -91,6 +124,7 @@ struct kernel_symbol { * be reused in other execution contexts such as the UEFI stub or the * decompressor. */ +#define __EXPORT_SYMBOL_NS(sym, sec, ns) #define __EXPORT_SYMBOL(sym, sec) #elif defined(CONFIG_TRIM_UNUSED_KSYMS) @@ -117,18 +151,26 @@ struct kernel_symbol { #define __cond_export_sym_1(sym, sec) ___EXPORT_SYMBOL(sym, sec) #define __cond_export_sym_0(sym, sec) /* nothing */ +#define __EXPORT_SYMBOL_NS(sym, sec, ns) \ + __ksym_marker(sym); \ + __cond_export_ns_sym(sym, sec, ns, __is_defined(__KSYM_##sym)) +#define __cond_export_ns_sym(sym, sec, ns, conf) \ + ___cond_export_ns_sym(sym, sec, ns, conf) +#define ___cond_export_ns_sym(sym, sec, ns, enabled) \ + __cond_export_ns_sym_##enabled(sym, sec, ns) +#define __cond_export_ns_sym_1(sym, sec, ns) ___EXPORT_SYMBOL_NS(sym, sec, ns) +#define __cond_export_ns_sym_0(sym, sec, ns) /* nothing */ + #else +#define __EXPORT_SYMBOL_NS ___EXPORT_SYMBOL_NS #define __EXPORT_SYMBOL ___EXPORT_SYMBOL #endif -#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") +#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") +#define EXPORT_SYMBOL_NS(sym, ns) __EXPORT_SYMBOL_NS(sym, "", ns) +#define EXPORT_SYMBOL_NS_GPL(sym, ns) __EXPORT_SYMBOL_NS(sym, "_gpl", ns) #ifdef CONFIG_UNUSED_SYMBOLS #define EXPORT_UNUSED_SYMBOL(sym) __EXPORT_SYMBOL(sym, "_unused") @@ -138,11 +180,28 @@ struct kernel_symbol { #define EXPORT_UNUSED_SYMBOL_GPL(sym) #endif -#endif /* __GENKSYMS__ */ +#endif /* __KERNEL__ && !__GENKSYMS__ */ + +#if defined(__GENKSYMS__) +/* + * When we're running genksyms, ignore the namespace and make the _NS + * variants look like the normal ones. There are two reasons for this: + * 1) In the normal definition of EXPORT_SYMBOL_NS, the 'ns' macro + * argument is itself not expanded because it's always tokenized or + * concatenated; but when running genksyms, a blank definition of the + * macro does allow the argument to be expanded; if a namespace + * happens to collide with a #define, this can cause issues. + * 2) There's no need to modify genksyms to deal with the _NS variants + */ +#define EXPORT_SYMBOL_NS(sym, ns) EXPORT_SYMBOL(sym) +#define EXPORT_SYMBOL_NS_GPL(sym, ns) EXPORT_SYMBOL_GPL(sym) +#endif #else /* !CONFIG_MODULES... */ #define EXPORT_SYMBOL(sym) +#define EXPORT_SYMBOL_NS(sym, ns) +#define EXPORT_SYMBOL_NS_GPL(sym, ns) #define EXPORT_SYMBOL_GPL(sym) #define EXPORT_SYMBOL_GPL_FUTURE(sym) #define EXPORT_UNUSED_SYMBOL(sym) diff --git a/include/linux/module.h b/include/linux/module.h index 1455812dd325..b3611e749f72 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -280,6 +280,8 @@ struct notifier_block; #ifdef CONFIG_MODULES +#define MODULE_IMPORT_NS(ns) MODULE_INFO(import_ns, #ns) + extern int modules_disabled; /* for sysctl */ /* Get/put a kernel symbol (calls must be symmetric) */ void *__symbol_get(const char *symbol); diff --git a/kernel/module.c b/kernel/module.c index 3ee507c0a92f..6bb9b938f9c7 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -544,6 +544,15 @@ static const char *kernel_symbol_name(const struct kernel_symbol *sym) #endif } +static const char *kernel_symbol_namespace(const struct kernel_symbol *sym) +{ +#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS + return offset_to_ptr(&sym->namespace_offset); +#else + return sym->namespace; +#endif +} + static int cmp_name(const void *va, const void *vb) { const char *a; @@ -1379,6 +1388,34 @@ static inline int same_magic(const char *amagic, const char *bmagic, } #endif /* CONFIG_MODVERSIONS */ +static char *get_modinfo(const struct load_info *info, const char *tag); +static char *get_next_modinfo(const struct load_info *info, const char *tag, + char *prev); + +static int verify_namespace_is_imported(const struct load_info *info, + const struct kernel_symbol *sym, + struct module *mod) +{ + const char *namespace; + char *imported_namespace; + + namespace = kernel_symbol_namespace(sym); + if (namespace) { + imported_namespace = get_modinfo(info, "import_ns"); + while (imported_namespace) { + if (strcmp(namespace, imported_namespace) == 0) + return 0; + imported_namespace = get_next_modinfo( + info, "import_ns", imported_namespace); + } + pr_err("%s: module uses symbol (%s) from namespace %s, but does not import it.\n", + mod->name, kernel_symbol_name(sym), namespace); + return -EINVAL; + } + return 0; +} + + /* Resolve a symbol for this module. I.e. if we find one, record usage. */ static const struct kernel_symbol *resolve_symbol(struct module *mod, const struct load_info *info, @@ -1407,6 +1444,12 @@ static const struct kernel_symbol *resolve_symbol(struct module *mod, goto getname; } + err = verify_namespace_is_imported(info, sym, mod); + if (err) { + sym = ERR_PTR(err); + goto getname; + } + err = ref_module(mod, owner); if (err) { sym = ERR_PTR(err); From patchwork Tue Sep 3 15:06:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Matthias_M=C3=A4nnich?= X-Patchwork-Id: 11128219 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 570A71813 for ; Tue, 3 Sep 2019 15:08:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2E80F2377D for ; Tue, 3 Sep 2019 15:08:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="DjpPoCow" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729812AbfICPIX (ORCPT ); Tue, 3 Sep 2019 11:08:23 -0400 Received: from mail-yw1-f74.google.com ([209.85.161.74]:47439 "EHLO mail-yw1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729806AbfICPHg (ORCPT ); Tue, 3 Sep 2019 11:07:36 -0400 Received: by mail-yw1-f74.google.com with SMTP id p205so7535136ywc.14 for ; Tue, 03 Sep 2019 08:07:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=TomRv8WBRCsnjt12ZHD1+VdCr+4pjb/fkJlpjNFFLG4=; b=DjpPoCowYoYMtqq6HChqsAFuCxySsXs6nnis1S6OjRSfR5h5o60lx6prLWk2IFp2SB ZL/iH4uSQoA87fOY1SCt0JtauSbUEx9o01Cw6SePQ2YK4+oEDisY472VSZN5nIZvfvbz tVMjf1T/FJN/3X6ktlKarr3AKfRelcnCr8tDvp87Ha9hBen3ifVU1gQR5ccBVcsgUIZK gC4SqEWp++ijD8pUY4RQdXZx+pdOYK4onjRmTH0sTgRBTOvy06mKNBGZBSsvkFC5UZTV I436Nils03M3qCKFxh2B+xkDNq4uJfvNaH29KloUvqo8TVZgUK3gCEWzNe47LlkGywPr /3lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=TomRv8WBRCsnjt12ZHD1+VdCr+4pjb/fkJlpjNFFLG4=; b=gdrqobA94f6j1ALvVzc1htVH/IaCByE8sP1G9IYnp12H024VKHv3bEalCU0WHdjmer YZPLeXWCbXM2czBObqUCHbLig+aWP5uOjS/J2axqr3U686g9WB9MeAiSz0QnDciNqKWf v6CbKZMp2yiyjNTQDcE4W1cjrNpwgKm60ZEWYRxjYafEdmYI2uUe+2QB7D9l5tZVqdMz LieTYJXJSFgC4Tnh0SLs9r8c0GPF/g7KcmZX88/tbaEvmx8rk37EDdDRQ0Vwtk3vbZFi PZng7Aw18hekTTwDi5tl5mOmmKsKFUADCfcIJpVBuxLaEyoSQxja7pGkpagTgGvM5A3K b3ag== X-Gm-Message-State: APjAAAXHz45JbCB7pUaOubPGbq+0dSPEXESikdz6kW1glbv+qcDqniMy i7JObT6wsAjCMGxeL0YoeliIprLzlIOiXQ== X-Google-Smtp-Source: APXvYqxEBrg7gJojzVUw3GwcZ9otAyXaBVd2jFNcrR6p4Ed9JS8wISKsWDTTwpk0FQ8t1mXJbWEJPSJ83QnbiA== X-Received: by 2002:a25:2e4e:: with SMTP id b14mr24713314ybn.242.1567523255286; Tue, 03 Sep 2019 08:07:35 -0700 (PDT) Date: Tue, 3 Sep 2019 16:06:30 +0100 In-Reply-To: <20190903150638.242049-1-maennich@google.com> Message-Id: <20190903150638.242049-5-maennich@google.com> Mime-Version: 1.0 References: <20180716122125.175792-1-maco@android.com> <20190903150638.242049-1-maennich@google.com> X-Mailer: git-send-email 2.23.0.187.g17f5b7556c-goog Subject: [PATCH v4 04/12] modpost: add support for symbol namespaces From: Matthias Maennich To: linux-kernel@vger.kernel.org Cc: kernel-team@android.com, maennich@google.com, arnd@arndb.de, gregkh@linuxfoundation.org, jeyu@kernel.org, joel@joelfernandes.org, lucas.de.marchi@gmail.com, maco@android.com, sspatil@google.com, will@kernel.org, yamada.masahiro@socionext.com, linux-kbuild@vger.kernel.org, linux-modules@vger.kernel.org, linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, linux-watchdog@vger.kernel.org Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org Add support for symbols that are exported into namespaces. For that, extract any namespace suffix from the symbol name. In addition, emit a warning whenever a module refers to an exported symbol without explicitly importing the namespace that it is defined in. This patch consistently adds the namespace suffix to symbol names exported into Module.symvers. Example warning emitted by modpost in case of the above violation: WARNING: module ums-usbat uses symbol usb_stor_resume from namespace USB_STORAGE, but does not import it. Co-developed-by: Martijn Coenen Signed-off-by: Martijn Coenen Reviewed-by: Joel Fernandes (Google) Reviewed-by: Greg Kroah-Hartman Signed-off-by: Matthias Maennich --- Documentation/kbuild/modules.rst | 7 ++- scripts/export_report.pl | 2 +- scripts/mod/modpost.c | 104 ++++++++++++++++++++++++++----- scripts/mod/modpost.h | 7 +++ 4 files changed, 101 insertions(+), 19 deletions(-) diff --git a/Documentation/kbuild/modules.rst b/Documentation/kbuild/modules.rst index 24e763482650..d2ae799237fd 100644 --- a/Documentation/kbuild/modules.rst +++ b/Documentation/kbuild/modules.rst @@ -470,9 +470,12 @@ build. The syntax of the Module.symvers file is:: - + - 0x2d036834 scsi_remove_host drivers/scsi/scsi_mod + 0xe1cc2a05 usb_stor_suspend USB_STORAGE drivers/usb/storage/usb-storage EXPORT_SYMBOL_GPL + + The fields are separated by tabs and values may be empty (e.g. + if no namespace is defined for an exported symbol). For a kernel build without CONFIG_MODVERSIONS enabled, the CRC would read 0x00000000. diff --git a/scripts/export_report.pl b/scripts/export_report.pl index 7d3030d03a25..548330e8c4e7 100755 --- a/scripts/export_report.pl +++ b/scripts/export_report.pl @@ -94,7 +94,7 @@ if (defined $opt{'o'}) { # while ( <$module_symvers> ) { chomp; - my (undef, $symbol, $module, $gpl) = split; + my (undef, $symbol, $namespace, $module, $gpl) = split('\t'); $SYMBOL { $symbol } = [ $module , "0" , $symbol, $gpl]; } close($module_symvers); diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index f277e116e0eb..c2d49afaea1c 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -164,6 +164,7 @@ struct symbol { struct module *module; unsigned int crc; int crc_valid; + const char *namespace; unsigned int weak:1; unsigned int vmlinux:1; /* 1 if symbol is defined in vmlinux */ unsigned int kernel:1; /* 1 if symbol is from kernel @@ -233,6 +234,37 @@ static struct symbol *find_symbol(const char *name) return NULL; } +static bool contains_namespace(struct namespace_list *list, + const char *namespace) +{ + struct namespace_list *ns_entry; + + for (ns_entry = list; ns_entry != NULL; ns_entry = ns_entry->next) + if (strcmp(ns_entry->namespace, namespace) == 0) + return true; + + return false; +} + +static void add_namespace(struct namespace_list **list, const char *namespace) +{ + struct namespace_list *ns_entry; + + if (!contains_namespace(*list, namespace)) { + ns_entry = NOFAIL(malloc(sizeof(struct namespace_list) + + strlen(namespace) + 1)); + strcpy(ns_entry->namespace, namespace); + ns_entry->next = *list; + *list = ns_entry; + } +} + +static bool module_imports_namespace(struct module *module, + const char *namespace) +{ + return contains_namespace(module->imported_namespaces, namespace); +} + static const struct { const char *str; enum export export; @@ -312,23 +344,39 @@ static enum export export_from_sec(struct elf_info *elf, unsigned int sec) return export_unknown; } +static const char *sym_extract_namespace(const char **symname) +{ + size_t n; + char *dupsymname; + + n = strcspn(*symname, "."); + if (n < strlen(*symname) - 1) { + dupsymname = NOFAIL(strdup(*symname)); + dupsymname[n] = '\0'; + *symname = dupsymname; + return dupsymname + n + 1; + } + + return NULL; +} + /** * Add an exported symbol - it may have already been added without a * CRC, in this case just update the CRC **/ -static struct symbol *sym_add_exported(const char *name, struct module *mod, - enum export export) +static struct symbol *sym_add_exported(const char *name, const char *namespace, + struct module *mod, enum export export) { struct symbol *s = find_symbol(name); if (!s) { s = new_symbol(name, mod, export); + s->namespace = namespace; } else { if (!s->preloaded) { - warn("%s: '%s' exported twice. Previous export " - "was in %s%s\n", mod->name, name, - s->module->name, - is_vmlinux(s->module->name) ?"":".ko"); + warn("%s: '%s' exported twice. Previous export was in %s%s\n", + mod->name, name, s->module->name, + is_vmlinux(s->module->name) ? "" : ".ko"); } else { /* In case Module.symvers was out of date */ s->module = mod; @@ -620,6 +668,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info, unsigned int crc; enum export export; bool is_crc = false; + const char *name, *namespace; if ((!is_vmlinux(mod->name) || mod->is_dot_o) && strstarts(symname, "__ksymtab")) @@ -691,8 +740,9 @@ static void handle_modversions(struct module *mod, struct elf_info *info, default: /* All exported symbols */ if (strstarts(symname, "__ksymtab_")) { - sym_add_exported(symname + strlen("__ksymtab_"), mod, - export); + name = symname + strlen("__ksymtab_"); + namespace = sym_extract_namespace(&name); + sym_add_exported(name, namespace, mod, export); } if (strcmp(symname, "init_module") == 0) mod->has_init = 1; @@ -1943,6 +1993,7 @@ static void read_symbols(const char *modname) const char *symname; char *version; char *license; + char *namespace; struct module *mod; struct elf_info info = { }; Elf_Sym *sym; @@ -1974,6 +2025,12 @@ static void read_symbols(const char *modname) license = get_next_modinfo(&info, "license", license); } + namespace = get_modinfo(&info, "import_ns"); + while (namespace) { + add_namespace(&mod->imported_namespaces, namespace); + namespace = get_next_modinfo(&info, "import_ns", namespace); + } + for (sym = info.symtab_start; sym < info.symtab_stop; sym++) { symname = remove_dot(info.strtab + sym->st_name); @@ -2118,6 +2175,13 @@ static int check_exports(struct module *mod) basename++; else basename = mod->name; + + if (exp->namespace && + !module_imports_namespace(mod, exp->namespace)) { + warn("module %s uses symbol %s from namespace %s, but does not import it.\n", + basename, exp->name, exp->namespace); + } + if (!mod->gpl_compatible) check_for_gpl_usage(exp->export, basename, exp->name); check_for_unused(exp->export, basename, exp->name); @@ -2341,7 +2405,7 @@ static void read_dump(const char *fname, unsigned int kernel) return; while ((line = get_next_line(&pos, file, size))) { - char *symname, *modname, *d, *export, *end; + char *symname, *namespace, *modname, *d, *export, *end; unsigned int crc; struct module *mod; struct symbol *s; @@ -2349,7 +2413,10 @@ static void read_dump(const char *fname, unsigned int kernel) if (!(symname = strchr(line, '\t'))) goto fail; *symname++ = '\0'; - if (!(modname = strchr(symname, '\t'))) + if (!(namespace = strchr(symname, '\t'))) + goto fail; + *namespace++ = '\0'; + if (!(modname = strchr(namespace, '\t'))) goto fail; *modname++ = '\0'; if ((export = strchr(modname, '\t')) != NULL) @@ -2366,7 +2433,8 @@ static void read_dump(const char *fname, unsigned int kernel) mod = new_module(modname); mod->skip = 1; } - s = sym_add_exported(symname, mod, export_no(export)); + s = sym_add_exported(symname, namespace, mod, + export_no(export)); s->kernel = kernel; s->preloaded = 1; sym_update_crc(symname, mod, crc, export_no(export)); @@ -2395,16 +2463,20 @@ static void write_dump(const char *fname) { struct buffer buf = { }; struct symbol *symbol; + const char *namespace; int n; for (n = 0; n < SYMBOL_HASH_SIZE ; n++) { symbol = symbolhash[n]; while (symbol) { - if (dump_sym(symbol)) - buf_printf(&buf, "0x%08x\t%s\t%s\t%s\n", - symbol->crc, symbol->name, - symbol->module->name, - export_str(symbol->export)); + if (dump_sym(symbol)) { + namespace = symbol->namespace; + buf_printf(&buf, "0x%08x\t%s\t%s\t%s\t%s\n", + symbol->crc, symbol->name, + namespace ? namespace : "", + symbol->module->name, + export_str(symbol->export)); + } symbol = symbol->next; } } diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index 8453d6ac2f77..9626bf3e7424 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -109,6 +109,11 @@ buf_printf(struct buffer *buf, const char *fmt, ...); void buf_write(struct buffer *buf, const char *s, int len); +struct namespace_list { + struct namespace_list *next; + char namespace[0]; +}; + struct module { struct module *next; const char *name; @@ -121,6 +126,8 @@ struct module { struct buffer dev_table_buf; char srcversion[25]; int is_dot_o; + // Actual imported namespaces + struct namespace_list *imported_namespaces; }; struct elf_info { From patchwork Tue Sep 3 15:06:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Matthias_M=C3=A4nnich?= X-Patchwork-Id: 11128211 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 500371813 for ; Tue, 3 Sep 2019 15:08:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 307132377D for ; Tue, 3 Sep 2019 15:08:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Hc0uhxet" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729842AbfICPHk (ORCPT ); Tue, 3 Sep 2019 11:07:40 -0400 Received: from mail-vs1-f74.google.com ([209.85.217.74]:42394 "EHLO mail-vs1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729833AbfICPHj (ORCPT ); Tue, 3 Sep 2019 11:07:39 -0400 Received: by mail-vs1-f74.google.com with SMTP id m26so934469vsa.9 for ; Tue, 03 Sep 2019 08:07:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=e5Xa0/L265hDWGkY0PbNgVQnJTuuZu+3daZLqyOdxeE=; b=Hc0uhxetFetgu/poYhUNFgg1T/AwAxEU/l5K1FfOUg+f0UDE9/4KemaScAtIodqCcf p+HErAQSwLryXYi6kJhwEDHbcaoIEMJn1t1UXw5opoN+Eo7Q8uX0MgEtrKPvgRCHqr60 bcyHtxD9NVfAPNsjYgne7wNNEXO3ygL8XmhSxOqgamb2vNSBC/PH9s1qLICgCeuhcUzc gor8Bzjd0nOLnqmfz8RlNFqa+Ip17HpWMJ/4Oohd87xpibMA9P2cOON4y/PnV+yD1DEY yim6amoWS0+2n19l9MHM7rxxZ1+ZLaK1MEr2KbIKihHzI+SvCc1RGyKDayWQorTmMk8m 6vpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=e5Xa0/L265hDWGkY0PbNgVQnJTuuZu+3daZLqyOdxeE=; b=frnJm29k23s7O+gZsZFSmM4bE8zfPHRM3NJMBYXxilST1SBb/78NmoiNLH1lK7sVLZ j0XLPO7VUcvwh3YTjh8zgqSk/xlFKGbO0zfj4YGUtN2peUFt7OTec1OMwKJ+ooXJk4db +OIWQ0eCXSZC0aX7IHRHqRcw2QJPXcPZvBp21UPmSWeZSJComVYHyk3fd9LMq5mFZmTj EtVqyEpJmEIPkznF2AqRlJVtH2Nf+YefEOJxqYV49ZXF3orL8axtkh72srG97LXrGDwH W/7Gk6936OW+CwD0TAE5a1CIgC11KXJF4xtjCFRU/rS/KGC6wjkGxm0Fp1uz22/t/9xM +LNg== X-Gm-Message-State: APjAAAWMjOCLLKe2+9IfAqSq+hw9j1CjuJTzPIgcsrwpGrl+Mr2jy/xw aQgAesc/t5cPWs3S6z2H+35+RaHPgn/shg== X-Google-Smtp-Source: APXvYqwQdWroZ46qqIvVShU81d8ojjOGsuCIOY/jhv+xD2nymIDWaNxFqSFL2DC3qyyVqkblB8HT7gT1W1ZVnQ== X-Received: by 2002:a1f:bd94:: with SMTP id n142mr7086317vkf.86.1567523258142; Tue, 03 Sep 2019 08:07:38 -0700 (PDT) Date: Tue, 3 Sep 2019 16:06:31 +0100 In-Reply-To: <20190903150638.242049-1-maennich@google.com> Message-Id: <20190903150638.242049-6-maennich@google.com> Mime-Version: 1.0 References: <20180716122125.175792-1-maco@android.com> <20190903150638.242049-1-maennich@google.com> X-Mailer: git-send-email 2.23.0.187.g17f5b7556c-goog Subject: [PATCH v4 05/12] module: add config option MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS From: Matthias Maennich To: linux-kernel@vger.kernel.org Cc: kernel-team@android.com, maennich@google.com, arnd@arndb.de, gregkh@linuxfoundation.org, jeyu@kernel.org, joel@joelfernandes.org, lucas.de.marchi@gmail.com, maco@android.com, sspatil@google.com, will@kernel.org, yamada.masahiro@socionext.com, linux-kbuild@vger.kernel.org, linux-modules@vger.kernel.org, linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, linux-watchdog@vger.kernel.org Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org If MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS is enabled (default=n), the requirement for modules to import all namespaces that are used by the module is relaxed. Enabling this option effectively allows (invalid) modules to be loaded while only a warning is emitted. Disabling this option keeps the enforcement at module loading time and loading is denied if the module's imports are not satisfactory. Reviewed-by: Martijn Coenen Reviewed-by: Greg Kroah-Hartman Signed-off-by: Matthias Maennich --- init/Kconfig | 13 +++++++++++++ kernel/module.c | 11 +++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/init/Kconfig b/init/Kconfig index bd7d650d4a99..cc28561288a7 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -2119,6 +2119,19 @@ config MODULE_COMPRESS_XZ endchoice +config MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS + bool "Allow loading of modules with missing namespace imports" + help + Symbols exported with EXPORT_SYMBOL_NS*() are considered exported in + a namespace. A module that makes use of a symbol exported with such a + namespace is required to import the namespace via MODULE_IMPORT_NS(). + There is no technical reason to enforce correct namespace imports, + but it creates consistency between symbols defining namespaces and + users importing namespaces they make use of. This option relaxes this + requirement and lifts the enforcement when loading a module. + + If unsure, say N. + config TRIM_UNUSED_KSYMS bool "Trim unused exported kernel symbols" depends on MODULES && !UNUSED_SYMBOLS diff --git a/kernel/module.c b/kernel/module.c index 6bb9b938f9c7..f76efcf2043e 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -1408,9 +1408,16 @@ static int verify_namespace_is_imported(const struct load_info *info, imported_namespace = get_next_modinfo( info, "import_ns", imported_namespace); } - pr_err("%s: module uses symbol (%s) from namespace %s, but does not import it.\n", - mod->name, kernel_symbol_name(sym), namespace); +#ifdef CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS + pr_warn( +#else + pr_err( +#endif + "%s: module uses symbol (%s) from namespace %s, but does not import it.\n", + mod->name, kernel_symbol_name(sym), namespace); +#ifndef CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS return -EINVAL; +#endif } return 0; } From patchwork Tue Sep 3 15:06:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Matthias_M=C3=A4nnich?= X-Patchwork-Id: 11128207 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 00FB014F7 for ; Tue, 3 Sep 2019 15:08:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D71742377F for ; Tue, 3 Sep 2019 15:08:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="PB5Ah+kY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729857AbfICPHm (ORCPT ); Tue, 3 Sep 2019 11:07:42 -0400 Received: from mail-yw1-f73.google.com ([209.85.161.73]:50314 "EHLO mail-yw1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729851AbfICPHm (ORCPT ); Tue, 3 Sep 2019 11:07:42 -0400 Received: by mail-yw1-f73.google.com with SMTP id a144so10372379ywe.17 for ; Tue, 03 Sep 2019 08:07:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=QzLwUka7MndmPbLBfBjtnVUWcO8y+yUapUjSVd2AkdE=; b=PB5Ah+kYC1m4B/Vqzh02d5Dma2M2yVL7Bdqf/cgU5C5/QHZXWWxWusz5yxJTxv/UaW cPQ+if9lMxNZfGZL8S6lAAv/KZXOdRW/TgOTyyk2SxYWVb84rGwfPhHTdzrwyml3fyYR zMB9ShCEW07O4VXQZsewgm0bwovFzEdsUHPpP51HT13xk3Eva1qhEajcX6jZ8XP0Sq9l WK3aEEJXUIn/x+ktaxUYG8u++q7nTs10fbIeFJFJgHQ61R003giZa7EC3s1heJ+v3BkU DhFAq5i9QktVcROUV7GZTvihIhoDpLPBW6QkwLuwo8b24v/88OsKzS4oZLrp9/OjXMdl ZYLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=QzLwUka7MndmPbLBfBjtnVUWcO8y+yUapUjSVd2AkdE=; b=IBMD7LEOKbVf7iJYdpEnE6BW1fy6/8DSuuVD9tvByRiW/ybqIRecVid0P5l3rnWsh1 rgsgS7gKalq0TqB1P1Oo57MJ9PX0yZmgkI4eyBGO66YAR0lJAHYcO/Wy3a9VV/aC11Q8 3bcPilLCk8iTnJMhNdXFnASRtWoFqODYZUStEKW0p8x7gjisWiViWFhSdPaB6byLMx1E j4rf7gFHq9/DrCHLWwfGDEg7q3lPoUytNL9dqJr/8vt1NhJa0h4QX4FtWHQZG3YZYR1t 6ZR9NP1CoSdNlKnmDQdelqDPyt7Jb/OoURsz7adEbwOqMuRMCdZztsxhSJJ4KoPTTAkY Dpbg== X-Gm-Message-State: APjAAAX1mL7OLmMjTCYC1nCm1AhI26ubuVBG42a/SbnN97Y59TILrAR3 dj5EeJd/nTbvmmAm+WjGMS4iD4bxnAQ+IQ== X-Google-Smtp-Source: APXvYqwwwghshBlXbu3SzPrPSRDK2LVE5Xdl4WcySrrwEMVrzGCbbqWqp4Yfsy68npcFDyQxAHFyHkK5McSccQ== X-Received: by 2002:a81:9ac2:: with SMTP id r185mr25908588ywg.210.1567523261200; Tue, 03 Sep 2019 08:07:41 -0700 (PDT) Date: Tue, 3 Sep 2019 16:06:32 +0100 In-Reply-To: <20190903150638.242049-1-maennich@google.com> Message-Id: <20190903150638.242049-7-maennich@google.com> Mime-Version: 1.0 References: <20180716122125.175792-1-maco@android.com> <20190903150638.242049-1-maennich@google.com> X-Mailer: git-send-email 2.23.0.187.g17f5b7556c-goog Subject: [PATCH v4 06/12] export: allow definition default namespaces in Makefiles or sources From: Matthias Maennich To: linux-kernel@vger.kernel.org Cc: kernel-team@android.com, maennich@google.com, arnd@arndb.de, gregkh@linuxfoundation.org, jeyu@kernel.org, joel@joelfernandes.org, lucas.de.marchi@gmail.com, maco@android.com, sspatil@google.com, will@kernel.org, yamada.masahiro@socionext.com, linux-kbuild@vger.kernel.org, linux-modules@vger.kernel.org, linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, linux-watchdog@vger.kernel.org Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org To avoid excessive usage of EXPORT_SYMBOL_NS(sym, MY_NAMESPACE), where MY_NAMESPACE will always be the namespace we are exporting to, allow exporting all definitions of EXPORT_SYMBOL() and friends by defining DEFAULT_SYMBOL_NAMESPACE. For example, to export all symbols defined in usb-common into the namespace USB_COMMON, add a line like this to drivers/usb/common/Makefile: ccflags-y += -DDEFAULT_SYMBOL_NAMESPACE=USB_COMMON That is equivalent to changing all EXPORT_SYMBOL(sym) definitions to EXPORT_SYMBOL_NS(sym, USB_COMMON). Subsequently all symbol namespaces functionality will apply. Another way of making use of this feature is to define the namespace within source or header files similar to how TRACE_SYSTEM defines are used: #undef DEFAULT_SYMBOL_NAMESPACE #define DEFAULT_SYMBOL_NAMESPACE USB_COMMON Please note that, as opposed to TRACE_SYSTEM, DEFAULT_SYMBOL_NAMESPACE has to be defined before including include/linux/export.h. If DEFAULT_SYMBOL_NAMESPACE is defined, a symbol can still be exported to another namespace by using EXPORT_SYMBOL_NS() and friends with explicitly specifying the namespace. Suggested-by: Arnd Bergmann Reviewed-by: Martijn Coenen Reviewed-by: Greg Kroah-Hartman Signed-off-by: Matthias Maennich --- include/linux/export.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/export.h b/include/linux/export.h index d59461e71478..2c5468d8ea9a 100644 --- a/include/linux/export.h +++ b/include/linux/export.h @@ -166,6 +166,12 @@ struct kernel_symbol { #define __EXPORT_SYMBOL ___EXPORT_SYMBOL #endif +#ifdef DEFAULT_SYMBOL_NAMESPACE +#undef __EXPORT_SYMBOL +#define __EXPORT_SYMBOL(sym, sec) \ + __EXPORT_SYMBOL_NS(sym, sec, DEFAULT_SYMBOL_NAMESPACE) +#endif + #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") From patchwork Tue Sep 3 15:06:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Matthias_M=C3=A4nnich?= X-Patchwork-Id: 11128155 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C154414F7 for ; Tue, 3 Sep 2019 15:07:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 953FE215EA for ; Tue, 3 Sep 2019 15:07:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ldoyE70k" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729855AbfICPHp (ORCPT ); Tue, 3 Sep 2019 11:07:45 -0400 Received: from mail-qk1-f202.google.com ([209.85.222.202]:46887 "EHLO mail-qk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729870AbfICPHp (ORCPT ); Tue, 3 Sep 2019 11:07:45 -0400 Received: by mail-qk1-f202.google.com with SMTP id n135so18815429qka.13 for ; Tue, 03 Sep 2019 08:07:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=RSyx3V/T3+Fb/fBnjK85DcZdNsViLHAQqUGk4FWkZsU=; b=ldoyE70kJF8tGNXA/RdsmM9WccjJ/l/oyRh7hHi08RWg0nZ0Rb9g+gDqK01q50s4LE kEVDyCivDnMhp2TLCfzMZYj7EbsAcC1SKLhl1eECH6O6bIxSkf2tkH8PeVaISi8BMrjQ bFXkoedgoNYakwEgLdUh8j5FZZjsKdK6CtIOvdnLDO3LaQhp7wzRMV3TRywQgOkYCBOv 2akNhCRlY8j1azQOET4yeA7EmwQcMc0+z3BB0hSY3z7eYrDCORt+rTpAmU8VUCpl7APr R6ehlcXY7D66jWN4vC0T8gA6QaXzDZCb1IaCgj/asymbAZciAkWxF0iDkOohDTp8DXxs BeSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=RSyx3V/T3+Fb/fBnjK85DcZdNsViLHAQqUGk4FWkZsU=; b=tFYPlFi98dE4EekVy9T7NiP8JB3MYXsLniMRptzgxSvUDdiH8Zo1T5POZ8o20zAEN7 AvnA/uWTRzdC8c3E7dX5CY7AT/ctcUaSDcoQLJCqdoLobXyeap9Fy+5eY4qtxNi2DNhw IZx9YM03NCkpZ4QDZbG6z9kGJGNCv3sRSbHTb/mxvPMWd2Al1G3pgG0Xt0zh+UxsDYQO IcHyzIvS/PDqoGSvCdVfyUn1qnamkhYqJ+dcnsFLYZ5Y5kUwh3QjATWbmOtBBzx4kYbN weSMsFqtCyxOzNU+zEEsRSCet4VzeIk+SDDtKlH3CC66U9WUxccbbw3jEWcb0Leoe7al nrDw== X-Gm-Message-State: APjAAAV3ntEq+5g7zEcrV0nFr9DA/MCERPHfhB/KBUiyfXX7cd3VAfh5 jLmj1+c7JzHVJhJKjU5+CMi1ctm176XcYQ== X-Google-Smtp-Source: APXvYqzWnbTLWyx6Y6Af5dccbNi55xGD4hNXquBtED1N8JNA/6qhN3gWGV+qHmrza6FyvvdYJCf4Aj27tPX94g== X-Received: by 2002:aed:3c52:: with SMTP id u18mr15781866qte.194.1567523264136; Tue, 03 Sep 2019 08:07:44 -0700 (PDT) Date: Tue, 3 Sep 2019 16:06:33 +0100 In-Reply-To: <20190903150638.242049-1-maennich@google.com> Message-Id: <20190903150638.242049-8-maennich@google.com> Mime-Version: 1.0 References: <20180716122125.175792-1-maco@android.com> <20190903150638.242049-1-maennich@google.com> X-Mailer: git-send-email 2.23.0.187.g17f5b7556c-goog Subject: [PATCH v4 07/12] modpost: add support for generating namespace dependencies From: Matthias Maennich To: linux-kernel@vger.kernel.org Cc: kernel-team@android.com, maennich@google.com, arnd@arndb.de, gregkh@linuxfoundation.org, jeyu@kernel.org, joel@joelfernandes.org, lucas.de.marchi@gmail.com, maco@android.com, sspatil@google.com, will@kernel.org, yamada.masahiro@socionext.com, linux-kbuild@vger.kernel.org, linux-modules@vger.kernel.org, linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, linux-watchdog@vger.kernel.org Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org This patch adds an option to modpost to generate a .ns_deps file per module, containing the namespace dependencies for that module. E.g. if the linked module my-module.ko would depend on the symbol myfunc.MY_NS in the namespace MY_NS, the my-module.ns_deps file created by modpost would contain the entry MY_NS to express the namespace dependency of my-module imposed by using the symbol myfunc. These files can subsequently be used by static analysis tools (like coccinelle scripts) to address issues with missing namespace imports. A later patch of this series will introduce such a script 'nsdeps' and a corresponding make target to automatically add missing MODULE_IMPORT_NS() definitions to the module's sources. For that it uses the information provided in the generated .ns_deps files. Co-developed-by: Martijn Coenen Signed-off-by: Martijn Coenen Reviewed-by: Greg Kroah-Hartman Signed-off-by: Matthias Maennich --- .gitignore | 1 + Makefile | 2 +- scripts/mod/modpost.c | 54 +++++++++++++++++++++++++++++++++++++++---- scripts/mod/modpost.h | 2 ++ 4 files changed, 53 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 2030c7a4d2f8..9ee63aa2a3fb 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,7 @@ *.lzo *.mod *.mod.c +*.ns_deps *.o *.o.* *.order diff --git a/Makefile b/Makefile index 0cbe8717bdb3..0cdb957ae2c3 100644 --- a/Makefile +++ b/Makefile @@ -1669,7 +1669,7 @@ clean: $(clean-dirs) -o -name '*.ko.*' \ -o -name '*.dtb' -o -name '*.dtb.S' -o -name '*.dt.yaml' \ -o -name '*.dwo' -o -name '*.lst' \ - -o -name '*.su' -o -name '*.mod' \ + -o -name '*.su' -o -name '*.mod' -o -name '*.ns_deps' \ -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ -o -name '*.lex.c' -o -name '*.tab.[ch]' \ -o -name '*.asn1.[ch]' \ diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index c2d49afaea1c..be72da25fe7c 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -38,6 +38,8 @@ static int sec_mismatch_count = 0; static int sec_mismatch_fatal = 0; /* ignore missing files */ static int ignore_missing_files; +/* write namespace dependencies */ +static int write_namespace_deps; enum export { export_plain, export_unused, export_gpl, @@ -2176,10 +2178,15 @@ static int check_exports(struct module *mod) else basename = mod->name; - if (exp->namespace && - !module_imports_namespace(mod, exp->namespace)) { - warn("module %s uses symbol %s from namespace %s, but does not import it.\n", - basename, exp->name, exp->namespace); + if (exp->namespace) { + add_namespace(&mod->required_namespaces, + exp->namespace); + + if (!write_namespace_deps && + !module_imports_namespace(mod, exp->namespace)) { + warn("module %s uses symbol %s from namespace %s, but does not import it.\n", + basename, exp->name, exp->namespace); + } } if (!mod->gpl_compatible) @@ -2484,6 +2491,31 @@ static void write_dump(const char *fname) free(buf.p); } +static void write_namespace_deps_files(void) +{ + struct module *mod; + struct namespace_list *ns; + struct buffer ns_deps_buf = {}; + + for (mod = modules; mod; mod = mod->next) { + char fname[PATH_MAX]; + + if (mod->skip) + continue; + + ns_deps_buf.pos = 0; + + for (ns = mod->required_namespaces; ns; ns = ns->next) + buf_printf(&ns_deps_buf, "%s\n", ns->namespace); + + if (ns_deps_buf.pos == 0) + continue; + + sprintf(fname, "%s.ns_deps", mod->name); + write_if_changed(&ns_deps_buf, fname); + } +} + struct ext_sym_list { struct ext_sym_list *next; const char *file; @@ -2500,7 +2532,7 @@ int main(int argc, char **argv) struct ext_sym_list *extsym_iter; struct ext_sym_list *extsym_start = NULL; - while ((opt = getopt(argc, argv, "i:I:e:mnsT:o:awE")) != -1) { + while ((opt = getopt(argc, argv, "i:I:e:mnsT:o:awEd")) != -1) { switch (opt) { case 'i': kernel_read = optarg; @@ -2541,6 +2573,9 @@ int main(int argc, char **argv) case 'E': sec_mismatch_fatal = 1; break; + case 'd': + write_namespace_deps = 1; + break; default: exit(1); } @@ -2575,6 +2610,9 @@ int main(int argc, char **argv) err |= check_modname_len(mod); err |= check_exports(mod); + if (write_namespace_deps) + continue; + add_header(&buf, mod); add_intree_flag(&buf, !external_module); add_retpoline(&buf); @@ -2587,6 +2625,12 @@ int main(int argc, char **argv) sprintf(fname, "%s.mod.c", mod->name); write_if_changed(&buf, fname); } + + if (write_namespace_deps) { + write_namespace_deps_files(); + return 0; + } + if (dump_write) write_dump(dump_write); if (sec_mismatch_count && sec_mismatch_fatal) diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index 9626bf3e7424..92a926d375d2 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -126,6 +126,8 @@ struct module { struct buffer dev_table_buf; char srcversion[25]; int is_dot_o; + // Required namespace dependencies + struct namespace_list *required_namespaces; // Actual imported namespaces struct namespace_list *imported_namespaces; }; From patchwork Tue Sep 3 15:06:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Matthias_M=C3=A4nnich?= X-Patchwork-Id: 11128197 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9881B112C for ; Tue, 3 Sep 2019 15:08:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7967D20882 for ; Tue, 3 Sep 2019 15:08:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="pghRn16I" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729891AbfICPHs (ORCPT ); Tue, 3 Sep 2019 11:07:48 -0400 Received: from mail-yb1-f202.google.com ([209.85.219.202]:56774 "EHLO mail-yb1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729877AbfICPHs (ORCPT ); Tue, 3 Sep 2019 11:07:48 -0400 Received: by mail-yb1-f202.google.com with SMTP id t1so14197879ybk.23 for ; Tue, 03 Sep 2019 08:07:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=b+cqXt6YX0mnoCtMoAi03cOiwWu215/p06/ubbgFzR4=; b=pghRn16IfODUbRoRofiFw9344SQdsDElwKyv5Z95AmcH9uCOS/7iVJBCyGHvc/XCEy gkY5kuzQ6cLmq8hF+aYXS8YpZRO1LElUudHSnNOlAg92jvEAVfMIX0sXYM+j80ne2XN5 ew4kT/L8zajaJGRIn38fVNp6Bga8rn18WL17+ND4o5SoAMvp4PhgdP+vUMjEOyttyKeo 8I4AKstWoIagp2ogkgcbLX8OT1rZ164y6do+U7Ih2Vm0fqPQXkeDQscyE/S/Fqfu824T 5jcb0MlM+415vcNXYgIcezGLpu/FmCO736XMgZ58KY59Ay0KHzA9qZHW8kUBknr4+GiS qE3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=b+cqXt6YX0mnoCtMoAi03cOiwWu215/p06/ubbgFzR4=; b=TWxmzBnkDPh/l6t4VdNHRa+WrtXvcav7e4EhmCE2kqbuhvClP03rq/TnA46uoAlfNU UiYufJfoRVCOIrd4MYMZirx5zG8kMorW/ez4F314FkUeR6ERXU772su6OQ8W4qiBURO/ I8A3Z/IwOsaayZgLv4eRiEaJ4W/na1eCbmnzumtGusM0AZ6gupKYz4BfWauwmuia3M7t 0BvjExi3Nbr5NpHCUF3ZDMAHG22kkT++0Za7Z/n5fKndTkT1dKoJGXERyY5cxAqVskKv lXZuU0UVK9vw+jHLJ1MV0qrQb1WcGL/0dMKoGt27tBgSTqRAhq0sgvwItFmAK83Qd82+ 9dLg== X-Gm-Message-State: APjAAAWQyZwlTZLqqdjuKB0yLm4tWCW5msegc/ucGPFk5EW/Wr5DJgek KmB2Dg86oTuCqBc5xvIoXn1CDSc1HGarbA== X-Google-Smtp-Source: APXvYqwGLfcjypBVL+sbGsInUOD2na+AqTJP3yxgIKU456ykAlcmq7n9nMIrTuQLo+AzVop6kWrMmmVg8foeIQ== X-Received: by 2002:a81:84d0:: with SMTP id u199mr17120277ywf.284.1567523267075; Tue, 03 Sep 2019 08:07:47 -0700 (PDT) Date: Tue, 3 Sep 2019 16:06:34 +0100 In-Reply-To: <20190903150638.242049-1-maennich@google.com> Message-Id: <20190903150638.242049-9-maennich@google.com> Mime-Version: 1.0 References: <20180716122125.175792-1-maco@android.com> <20190903150638.242049-1-maennich@google.com> X-Mailer: git-send-email 2.23.0.187.g17f5b7556c-goog Subject: [PATCH v4 08/12] scripts: Coccinelle script for namespace dependencies. From: Matthias Maennich To: linux-kernel@vger.kernel.org Cc: kernel-team@android.com, maennich@google.com, arnd@arndb.de, gregkh@linuxfoundation.org, jeyu@kernel.org, joel@joelfernandes.org, lucas.de.marchi@gmail.com, maco@android.com, sspatil@google.com, will@kernel.org, yamada.masahiro@socionext.com, linux-kbuild@vger.kernel.org, linux-modules@vger.kernel.org, linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, linux-watchdog@vger.kernel.org, Julia Lawall Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org A script that uses the '.ns_deps' files generated by modpost to automatically add the required symbol namespace dependencies to each module. Usage: 1) Move some symbols to a namespace with EXPORT_SYMBOL_NS() or define DEFAULT_SYMBOL_NAMESPACE 2) Run 'make' (or 'make modules') and get warnings about modules not importing that namespace. 3) Run 'make nsdeps' to automatically add required import statements to said modules. This makes it easer for subsystem maintainers to introduce and maintain symbol namespaces into their codebase. Co-developed-by: Martijn Coenen Signed-off-by: Martijn Coenen Acked-by: Julia Lawall Reviewed-by: Greg Kroah-Hartman Signed-off-by: Matthias Maennich --- MAINTAINERS | 5 ++ Makefile | 12 +++++ scripts/Makefile.modpost | 4 +- scripts/coccinelle/misc/add_namespace.cocci | 23 ++++++++ scripts/nsdeps | 60 +++++++++++++++++++++ 5 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 scripts/coccinelle/misc/add_namespace.cocci create mode 100644 scripts/nsdeps diff --git a/MAINTAINERS b/MAINTAINERS index e7a47b5210fd..3b170c11a0e6 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11436,6 +11436,11 @@ S: Maintained T: git git://git.kernel.org/pub/scm/linux/kernel/git/wtarreau/nolibc.git F: tools/include/nolibc/ +NSDEPS +M: Matthias Maennich +S: Maintained +F: scripts/nsdeps + NTB AMD DRIVER M: Shyam Sundar S K L: linux-ntb@googlegroups.com diff --git a/Makefile b/Makefile index 0cdb957ae2c3..573e90e738ad 100644 --- a/Makefile +++ b/Makefile @@ -1500,6 +1500,9 @@ help: @echo ' headerdep - Detect inclusion cycles in headers' @echo ' coccicheck - Check with Coccinelle' @echo '' + @echo 'Tools:' + @echo ' nsdeps - Generate missing symbol namespace dependencies' + @echo '' @echo 'Kernel selftest:' @echo ' kselftest - Build and run kernel selftest (run as root)' @echo ' Build, install, and boot kernel before' @@ -1687,6 +1690,15 @@ quiet_cmd_tags = GEN $@ tags TAGS cscope gtags: FORCE $(call cmd,tags) +# Script to generate missing namespace dependencies +# --------------------------------------------------------------------------- + +PHONY += nsdeps + +nsdeps: + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost nsdeps + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/$@ + # Scripts to check various things for consistency # --------------------------------------------------------------------------- diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 26e6574ecd08..743fe3a2e885 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -56,7 +56,8 @@ MODPOST = scripts/mod/modpost \ $(if $(KBUILD_EXTMOD),$(addprefix -e ,$(KBUILD_EXTRA_SYMBOLS))) \ $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ $(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \ - $(if $(KBUILD_MODPOST_WARN),-w) + $(if $(KBUILD_MODPOST_WARN),-w) \ + $(if $(filter nsdeps,$(MAKECMDGOALS)),-d) ifdef MODPOST_VMLINUX @@ -134,6 +135,7 @@ $(modules): %.ko :%.o %.mod.o FORCE targets += $(modules) +nsdeps: __modpost # Add FORCE to the prequisites of a target to force it to be always rebuilt. # --------------------------------------------------------------------------- diff --git a/scripts/coccinelle/misc/add_namespace.cocci b/scripts/coccinelle/misc/add_namespace.cocci new file mode 100644 index 000000000000..c832bb6445a8 --- /dev/null +++ b/scripts/coccinelle/misc/add_namespace.cocci @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +/// Adds missing MODULE_IMPORT_NS statements to source files +/// +/// This script is usually called from scripts/nsdeps with -D ns= to +/// add a missing namespace tag to a module source file. +/// + +@has_ns_import@ +declarer name MODULE_IMPORT_NS; +identifier virtual.ns; +@@ +MODULE_IMPORT_NS(ns); + +// Add missing imports, but only adjacent to a MODULE_LICENSE statement. +// That ensures we are adding it only to the main module source file. +@do_import depends on !has_ns_import@ +declarer name MODULE_LICENSE; +expression license; +identifier virtual.ns; +@@ +MODULE_LICENSE(license); ++ MODULE_IMPORT_NS(ns); diff --git a/scripts/nsdeps b/scripts/nsdeps new file mode 100644 index 000000000000..75dcf79a11ed --- /dev/null +++ b/scripts/nsdeps @@ -0,0 +1,60 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Linux kernel symbol namespace import generator +# +# This script requires a minimum spatch version. +SPATCH_REQ_VERSION="1.0.4" + +DIR="$(dirname $(readlink -f $0))/.." +SPATCH="`which ${SPATCH:=spatch}`" +if [ ! -x "$SPATCH" ]; then + echo 'spatch is part of the Coccinelle project and is available at http://coccinelle.lip6.fr/' + exit 1 +fi + +SPATCH_REQ_VERSION_NUM=$(echo $SPATCH_REQ_VERSION | ${DIR}/scripts/ld-version.sh) +SPATCH_VERSION=$($SPATCH --version | head -1 | awk '{print $3}') +SPATCH_VERSION_NUM=$(echo $SPATCH_VERSION | ${DIR}/scripts/ld-version.sh) + +if [ "$SPATCH_VERSION_NUM" -lt "$SPATCH_REQ_VERSION_NUM" ] ; then + echo "spatch needs to be version $SPATCH_REQ_VERSION or higher" + exit 1 +fi + +set -e + +generate_deps_for_ns() { + $SPATCH --very-quiet --in-place --sp-file \ + $srctree/scripts/coccinelle/misc/add_namespace.cocci -D ns=$1 $2 +} + +generate_deps() { + local mod_name=`basename $@ .ko` + local mod_file=`echo $@ | sed -e 's/\.ko/\.mod/'` + local ns_deps_file=`echo $@ | sed -e 's/\.ko/\.ns_deps/'` + if [ ! -f "$ns_deps_file" ]; then return; fi + local mod_source_files=`cat $mod_file | sed -n 1p \ + | sed -e 's/\.o/\.c/g' \ + | sed "s/[^ ]* */${srctree}\/&/g"` + for ns in `cat $ns_deps_file`; do + echo "Adding namespace $ns to module $mod_name (if needed)." + generate_deps_for_ns $ns $mod_source_files + # sort the imports + for source_file in $mod_source_files; do + sed '/MODULE_IMPORT_NS/Q' $source_file > ${source_file}.tmp + offset=$(wc -l ${source_file}.tmp | awk '{print $1;}') + cat $source_file | grep MODULE_IMPORT_NS | sort -u >> ${source_file}.tmp + tail -n +$((offset +1)) ${source_file} | grep -v MODULE_IMPORT_NS >> ${source_file}.tmp + if ! diff -q ${source_file} ${source_file}.tmp; then + mv ${source_file}.tmp ${source_file} + else + rm ${source_file}.tmp + fi + done + done +} + +for f in `cat $objtree/modules.order`; do + generate_deps $f +done + From patchwork Tue Sep 3 15:06:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Matthias_M=C3=A4nnich?= X-Patchwork-Id: 11128161 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B78FA112C for ; Tue, 3 Sep 2019 15:07:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 826C82168B for ; Tue, 3 Sep 2019 15:07:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="OehgC/Qp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729912AbfICPHw (ORCPT ); Tue, 3 Sep 2019 11:07:52 -0400 Received: from mail-yb1-f202.google.com ([209.85.219.202]:50560 "EHLO mail-yb1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729906AbfICPHv (ORCPT ); Tue, 3 Sep 2019 11:07:51 -0400 Received: by mail-yb1-f202.google.com with SMTP id p80so14160700ybc.17 for ; Tue, 03 Sep 2019 08:07:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=PXDMDCBfc2xecCOj15IRjy6gG7tFhf1boblcojHoIqc=; b=OehgC/QpGVW5WHRtYYFEBPQjfIK+N42Odb/gz465atQlpSIk1lvdVNY2fEt5bT5y/i ncnP5Uzjks7oK05vFxfW7R4g/0AHAm6ZfhdpT9wXG6QB9n3Z0n3y2ZjV4jnYLOuSPB+V X3WZHM6Z6AEL0iTYXZ2q8rc3cx61dR3VH7hA6VsD64SSclKjEvBcfHz00aeGDU4u9Wg0 kO46LRoLWUpD93faDcaTwE3uYYBlaEGBRH9xLFbyVy1nOz7+8Ec5oTMVlw5Xr2i9V05w 0afYMRX4Wu/UypBQBMVOR/dlbL/g92c6Fkmc05h9ztxwfejrJ3k5dAKR3nVZAllXy1E2 4rlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=PXDMDCBfc2xecCOj15IRjy6gG7tFhf1boblcojHoIqc=; b=G1Bcj+ArIC4kEI6skXTwG8J7boUonVHtXn9HJwPj/KSMVGnlh1kY6yCJoXJLUg8R0P ibKerzlynNrVH/EYGSP8aOzt2+FWcLZs/98wBeUKlCxBxUNJxAt2Kw8rNTvFMjIrRO0z 6CSKRai1E3FzOFldnIkvdJDVrXcU/4HA6Ji3koyAjBocJEI5qrFyc1URzltshHnzt7Lm lyW1xCHkBhifowq1IwRIz+uH2jpmhkT1zud5kswWABG9WHAwudq0tjF+clZ8HNkMcDt8 Lzo3sJ5ruYvMRH1rN/dfi+Jw8YFreUnCrNi4dVwlT0r4UeylrASJP52g7G2f+BSEDdUV ANeg== X-Gm-Message-State: APjAAAUrXcsvKggx2bms4mTFguCMvydGBb4AVsWZTkXEPJDsBlGhESYP tT8rYU0pdKL/5i/2SC47AqzF3mDFPsHu+A== X-Google-Smtp-Source: APXvYqylPWFHf2hpNQhFQu2/5vQMLUmJtcBW5//m7WkaHo/DcTGkmE7DrAleumJF4actayeB+yWtnVWCxpa+8g== X-Received: by 2002:a25:6191:: with SMTP id v139mr25130367ybb.396.1567523270130; Tue, 03 Sep 2019 08:07:50 -0700 (PDT) Date: Tue, 3 Sep 2019 16:06:35 +0100 In-Reply-To: <20190903150638.242049-1-maennich@google.com> Message-Id: <20190903150638.242049-10-maennich@google.com> Mime-Version: 1.0 References: <20180716122125.175792-1-maco@android.com> <20190903150638.242049-1-maennich@google.com> X-Mailer: git-send-email 2.23.0.187.g17f5b7556c-goog Subject: [PATCH v4 09/12] docs: Add documentation for Symbol Namespaces From: Matthias Maennich To: linux-kernel@vger.kernel.org Cc: kernel-team@android.com, maennich@google.com, arnd@arndb.de, gregkh@linuxfoundation.org, jeyu@kernel.org, joel@joelfernandes.org, lucas.de.marchi@gmail.com, maco@android.com, sspatil@google.com, will@kernel.org, yamada.masahiro@socionext.com, linux-kbuild@vger.kernel.org, linux-modules@vger.kernel.org, linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, linux-watchdog@vger.kernel.org Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org Describe using Symbol Namespaces from a perspective of a user. I.e. module authors or subsystem maintainers. Signed-off-by: Matthias Maennich Reviewed-by: Greg Kroah-Hartman --- Documentation/kbuild/namespaces.rst | 154 +++++++++++++++++++++++ Documentation/kernel-hacking/hacking.rst | 18 +++ 2 files changed, 172 insertions(+) create mode 100644 Documentation/kbuild/namespaces.rst diff --git a/Documentation/kbuild/namespaces.rst b/Documentation/kbuild/namespaces.rst new file mode 100644 index 000000000000..982ed7b568ac --- /dev/null +++ b/Documentation/kbuild/namespaces.rst @@ -0,0 +1,154 @@ +================= +Symbol Namespaces +================= + +The following document describes how to use Symbol Namespaces to structure the +export surface of in-kernel symbols exported through the family of +EXPORT_SYMBOL() macros. + +.. Table of Contents + + === 1 Introduction + === 2 How to define Symbol Namespaces + --- 2.1 Using the EXPORT_SYMBOL macros + --- 2.2 Using the DEFAULT_SYMBOL_NAMESPACE define + === 3 How to use Symbols exported in Namespaces + === 4 Loading Modules that use namespaced Symbols + === 5 Automatically creating MODULE_IMPORT_NS statements + +1. Introduction +=============== + +Symbol Namespaces have been introduced as a means to structure the export +surface of the in-kernel API. It allows subsystem maintainers to partition +their exported symbols into separate namespaces. That is useful for +documentation purposes (think of the SUBSYSTEM_DEBUG namespace) as well as for +limiting the availability of a set of symbols for use in other parts of the +kernel. As of today, modules that make use of symbols exported into namespaces, +are required to import the namespace. Otherwise the kernel will, depending on +its configuration, reject loading the module or warn about a missing import. + +2. How to define Symbol Namespaces +================================== + +Symbols can be exported into namespace using different methods. All of them are +changing the way EXPORT_SYMBOL and friends are instrumented to create ksymtab +entries. + +2.1 Using the EXPORT_SYMBOL macros +================================== + +In addition to the macros EXPORT_SYMBOL() and EXPORT_SYMBOL_GPL(), that allow +exporting of kernel symbols to the kernel symbol table, variants of these are +available to export symbols into a certain namespace: EXPORT_SYMBOL_NS() and +EXPORT_SYMBOL_NS_GPL(). They take one additional argument: the namespace. +Please note that due to macro expansion that argument needs to be a +preprocessor symbol. E.g. to export the symbol `usb_stor_suspend` into the +namespace `USB_STORAGE`, use:: + + EXPORT_SYMBOL_NS(usb_stor_suspend, USB_STORAGE); + +The corresponding ksymtab entry struct `kernel_symbol` will have the member +`namespace` set accordingly. A symbol that is exported without a namespace will +refer to `NULL`. There is no default namespace if none is defined. `modpost` +and kernel/module.c make use the namespace at build time or module load time, +respectively. + +2.2 Using the DEFAULT_SYMBOL_NAMESPACE define +============================================= + +Defining namespaces for all symbols of a subsystem can be very verbose and may +become hard to maintain. Therefore a default define (DEFAULT_SYMBOL_NAMESPACE) +is been provided, that, if set, will become the default for all EXPORT_SYMBOL() +and EXPORT_SYMBOL_GPL() macro expansions that do not specify a namespace. + +There are multiple ways of specifying this define and it depends on the +subsystem and the maintainer's preference, which one to use. The first option +is to define the default namespace in the `Makefile` of the subsystem. E.g. to +export all symbols defined in usb-common into the namespace USB_COMMON, add a +line like this to drivers/usb/common/Makefile:: + + ccflags-y += -DDEFAULT_SYMBOL_NAMESPACE=USB_COMMON + +That will affect all EXPORT_SYMBOL() and EXPORT_SYMBOL_GPL() statements. A +symbol exported with EXPORT_SYMBOL_NS() while this definition is present, will +still be exported into the namespace that is passed as the namespace argument +as this argument has preference over a default symbol namespace. + +A second option to define the default namespace is directly in the compilation +unit as preprocessor statement. The above example would then read:: + + #undef DEFAULT_SYMBOL_NAMESPACE + #define DEFAULT_SYMBOL_NAMESPACE USB_COMMON + +within the corresponding compilation unit before any EXPORT_SYMBOL macro is +used. + +3. How to use Symbols exported in Namespaces +============================================ + +In order to use symbols that are exported into namespaces, kernel modules need +to explicitly import these namespaces. Otherwise the kernel might reject to +load the module. The module code is required to use the macro MODULE_IMPORT_NS +for the namespaces it uses symbols from. E.g. a module using the +usb_stor_suspend symbol from above, needs to import the namespace USB_STORAGE +using a statement like:: + + MODULE_IMPORT_NS(USB_STORAGE); + +This will create a `modinfo` tag in the module for each imported namespace. +This has the side effect, that the imported namespaces of a module can be +inspected with modinfo:: + + $ modinfo drivers/usb/storage/ums-karma.ko + [...] + import_ns: USB_STORAGE + [...] + + +It is advisable to add the MODULE_IMPORT_NS() statement close to other module +metadata definitions like MODULE_AUTHOR() or MODULE_LICENSE(). Refer to section +5. for a way to create missing import statements automatically. + +4. Loading Modules that use namespaced Symbols +============================================== + +At module loading time (e.g. `insmod`), the kernel will check each symbol +referenced from the module for its availability and whether the namespace it +might be exported to has been imported by the module. The default behaviour of +the kernel is to reject loading modules that don't specify sufficient imports. +An error will be logged and loading will be failed with EINVAL. In order to +allow loading of modules that don't satisfy this precondition, a configuration +option is available: Setting MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS=y will +enable loading regardless, but will emit a warning. + +5. Automatically creating MODULE_IMPORT_NS statements +===================================================== + +Missing namespaces imports can easily be detected at build time. In fact, +modpost will emit a warning if a module uses a symbol from a namespace +without importing it. +MODULE_IMPORT_NS() statements will usually be added at a definite location +(along with other module meta data). To make the life of module authors (and +subsystem maintainers) easier, a script and make target is available to fixup +missing imports. Fixing missing imports can be done with:: + + $ make nsdeps + +A typical scenario for module authors would be:: + + - write code that depends on a symbol from a not imported namespace + - `make` + - notice the warning of modpost telling about a missing import + - run `make nsdeps` to add the import to the correct code location + +For subsystem maintainers introducing a namespace, the steps are very similar. +Again, `make nsdeps` will eventually add the missing namespace imports for +in-tree modules:: + + - move or add symbols to a namespace (e.g. with EXPORT_SYMBOL_NS()) + - `make` (preferably with an allmodconfig to cover all in-kernel + modules) + - notice the warning of modpost telling about a missing import + - run `make nsdeps` to add the import to the correct code location + diff --git a/Documentation/kernel-hacking/hacking.rst b/Documentation/kernel-hacking/hacking.rst index 5891a701a159..a3ddb213a5e1 100644 --- a/Documentation/kernel-hacking/hacking.rst +++ b/Documentation/kernel-hacking/hacking.rst @@ -594,6 +594,24 @@ internal implementation issue, and not really an interface. Some maintainers and developers may however require EXPORT_SYMBOL_GPL() when adding any new APIs or functionality. +:c:func:`EXPORT_SYMBOL_NS()` +---------------------------- + +Defined in ``include/linux/export.h`` + +This is the variant of `EXPORT_SYMBOL()` that allows specifying a symbol +namespace. Symbol Namespaces are documented in +``Documentation/kbuild/namespaces.rst``. + +:c:func:`EXPORT_SYMBOL_NS_GPL()` +-------------------------------- + +Defined in ``include/linux/export.h`` + +This is the variant of `EXPORT_SYMBOL_GPL()` that allows specifying a symbol +namespace. Symbol Namespaces are documented in +``Documentation/kbuild/namespaces.rst``. + Routines and Conventions ======================== From patchwork Tue Sep 3 15:06:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Matthias_M=C3=A4nnich?= X-Patchwork-Id: 11128165 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C470014F7 for ; Tue, 3 Sep 2019 15:07:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A5E382339D for ; Tue, 3 Sep 2019 15:07:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="EFphzrlX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729924AbfICPHy (ORCPT ); Tue, 3 Sep 2019 11:07:54 -0400 Received: from mail-qt1-f201.google.com ([209.85.160.201]:51610 "EHLO mail-qt1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729921AbfICPHy (ORCPT ); Tue, 3 Sep 2019 11:07:54 -0400 Received: by mail-qt1-f201.google.com with SMTP id h18so19187762qto.18 for ; Tue, 03 Sep 2019 08:07:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=zRWSVeb5W05ehvG18tGL2ilvhm06WavygbArZEKUTQI=; b=EFphzrlXR0Q3X5gcyhY/QpNLUIKGO6Mu86Y7KiyAnZSAJCuL+nBTfH/jlK5erD7K2r W8pEWRT1FseJg9jN2oX0QQ+pK6swlE6nXwrBZ6Wb5ategvz0WdbO4zdMpl4JlgBIHf2v IzNy2RHxCVLFsD+LRUIe4g3TZB+8D3g68RwEhZjlWK09mvWkkYF7Yd6gbZ943ljGv0Pe 1AAxqU/OY+EFee6I23XvaOzyBbuR/9P9VIte/Y05WhkZZKwnXhu3vmyH8723rsuiufZI mLPqCZpvo8SV8k8H0mF6pGEksWdC7a3+5KSIrnkafdHCyITOpeyiUevIBhWx42asYq9T wNTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=zRWSVeb5W05ehvG18tGL2ilvhm06WavygbArZEKUTQI=; b=j87SHq4yIXZFgwSsUpGKFVKTcVMizk0Yxi1ltWxSCzhZxuecj4Jh4QnB6//F4kRG4f t6XzTZI9IL84IXYi76p0RD+rsOt/HludHhgZ88A8BLOjZw1KsxSGDESJOhQjh5MdRkX/ Mq6Ssr/OzCOQiRrCaKk6+CxwgPpIUPs7iegbX0oZPRL0LpVlARWJur61BThZrH2gIGzv CwoxrSTtBTbCko6ecWqpHaXGe4VUsrHIlibyhzAZYWUdcgmsRAsRhyRoaCDhcHaqTwy7 OFvFa5l6YQViP0s7z5W7T9vAtZEY0mBYjDofjZIEuOcRjNgT9yWWrCe8UOpXaFXBOrPR mW0g== X-Gm-Message-State: APjAAAX642IGBN90nA/DWpyJXed14szA1D1f/cJilR9ZbRdO8yqYt87B Svr6pw9I+Nr1asVHLEcP68iqCRuzDMBBww== X-Google-Smtp-Source: APXvYqwXLQ60AAfU9iVgSfT4ANntf+V9n3+Zm6PoQo1JQsqHzpyZDSgMHAEiaguzYB+Iw7z7S32mkOrSiVC1PQ== X-Received: by 2002:ac8:5296:: with SMTP id s22mr17672802qtn.139.1567523273051; Tue, 03 Sep 2019 08:07:53 -0700 (PDT) Date: Tue, 3 Sep 2019 16:06:36 +0100 In-Reply-To: <20190903150638.242049-1-maennich@google.com> Message-Id: <20190903150638.242049-11-maennich@google.com> Mime-Version: 1.0 References: <20180716122125.175792-1-maco@android.com> <20190903150638.242049-1-maennich@google.com> X-Mailer: git-send-email 2.23.0.187.g17f5b7556c-goog Subject: [PATCH v4 10/12] usb-storage: remove single-use define for debugging From: Matthias Maennich To: linux-kernel@vger.kernel.org Cc: kernel-team@android.com, maennich@google.com, arnd@arndb.de, gregkh@linuxfoundation.org, jeyu@kernel.org, joel@joelfernandes.org, lucas.de.marchi@gmail.com, maco@android.com, sspatil@google.com, will@kernel.org, yamada.masahiro@socionext.com, linux-kbuild@vger.kernel.org, linux-modules@vger.kernel.org, linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, linux-watchdog@vger.kernel.org Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org USB_STORAGE was defined as "usb-storage: " and used in a single location as argument to printk. In order to be able to use the name 'USB_STORAGE', drop the definition and use the string directly for the printk call. Reviewed-by: Greg Kroah-Hartman Signed-off-by: Matthias Maennich --- drivers/usb/storage/debug.h | 2 -- drivers/usb/storage/scsiglue.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/usb/storage/debug.h b/drivers/usb/storage/debug.h index 6d64f342f587..16ce06039a4d 100644 --- a/drivers/usb/storage/debug.h +++ b/drivers/usb/storage/debug.h @@ -29,8 +29,6 @@ #include -#define USB_STORAGE "usb-storage: " - #ifdef CONFIG_USB_STORAGE_DEBUG void usb_stor_show_command(const struct us_data *us, struct scsi_cmnd *srb); void usb_stor_show_sense(const struct us_data *us, unsigned char key, diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c index 05b80211290d..df4de8323eff 100644 --- a/drivers/usb/storage/scsiglue.c +++ b/drivers/usb/storage/scsiglue.c @@ -379,7 +379,7 @@ static int queuecommand_lck(struct scsi_cmnd *srb, /* check for state-transition errors */ if (us->srb != NULL) { - printk(KERN_ERR USB_STORAGE "Error in %s: us->srb = %p\n", + printk(KERN_ERR "usb-storage: Error in %s: us->srb = %p\n", __func__, us->srb); return SCSI_MLQUEUE_HOST_BUSY; } From patchwork Tue Sep 3 15:06:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Matthias_M=C3=A4nnich?= X-Patchwork-Id: 11128177 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9902C1813 for ; Tue, 3 Sep 2019 15:08:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 661182339D for ; Tue, 3 Sep 2019 15:08:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="H2wObk8o" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729947AbfICPIB (ORCPT ); Tue, 3 Sep 2019 11:08:01 -0400 Received: from mail-yw1-f73.google.com ([209.85.161.73]:49848 "EHLO mail-yw1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729929AbfICPH4 (ORCPT ); Tue, 3 Sep 2019 11:07:56 -0400 Received: by mail-yw1-f73.google.com with SMTP id d132so7088459ywh.16 for ; Tue, 03 Sep 2019 08:07:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc:content-transfer-encoding; bh=u5uO9nHL9grY4Qf1Kv34RIYuP69k6hUWKvOump+fF1c=; b=H2wObk8oBmJaRvXI7+P7eSG1NaG2LXqvmczSJPOAEv8LMU+IasDj2jHJwpZjxZyEVv D7AhVPj1qNPL/7u4OE1FNAqo3oVC3msvs4wK2zC7vPwoqC6A52vi7DfMCmNWMycyG93g 9PyLi2vhOIZVFChWzS2inK364xh8MGTaYJ2F5yiiIUw09JuK7s/MxlNdCwg/FlzYXPj/ GivmeYvfGeLAFX/Pqh8GMiLAgOWZ1BFn88Stp3ojobvlyFC/9dQYxpi3BRe6UbfpxXUj XGkgaWavEXuqQV2+WlECC0L5XQtPiZg7A6+k3n8MhjCqEH7Effel3sblCD5YayDzAo1X dCOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc:content-transfer-encoding; bh=u5uO9nHL9grY4Qf1Kv34RIYuP69k6hUWKvOump+fF1c=; b=rdW8vEKSOT2ZSvDAyzIYtiTGzutl+t2aqv9f2yDD5WKaxDlEV/yJkKiZPinUOwrBIr DJa3TZ0D+NWN8i0eflTMabz/Q6mFVDRNwF8+FSm48Y+eSM2WR/ItHR5o1cA9AIwGd93P r3SBYoEsNYPzMIWVGblGUxIY9iRdy40I4sqBfsjcyJC0vXVZZQjidscCfrdGNpUWXydc +YVjpMaLi27c1AT9RhQAf2JGwsuEzmxlTmB0UBQcVfMGIfVYsT63y7ZVAeOY8GzoJPJs ejj+h3RILeaTuRtwlG5DRxPEUlU0IiSwgBhYTuzZyaJsJFuj98IN1/nVekPYzXnC6idA B1cQ== X-Gm-Message-State: APjAAAXUENFQlX+WYgILOM4XCQbv20p5Cex3f/m+jG7nti6eK9P1GrW1 PTfssihwV8a+mnlZXtspB51ywHEOJ/mRDQ== X-Google-Smtp-Source: APXvYqzglXq4SLdx+lV+20thl0smFmPEO+aA+qQdN7RCTsXFKV8KqbPEh3bekauJjJjekw+jWCau9LoscvM6Tw== X-Received: by 2002:a81:310e:: with SMTP id x14mr15409228ywx.430.1567523275811; Tue, 03 Sep 2019 08:07:55 -0700 (PDT) Date: Tue, 3 Sep 2019 16:06:37 +0100 In-Reply-To: <20190903150638.242049-1-maennich@google.com> Message-Id: <20190903150638.242049-12-maennich@google.com> Mime-Version: 1.0 References: <20180716122125.175792-1-maco@android.com> <20190903150638.242049-1-maennich@google.com> X-Mailer: git-send-email 2.23.0.187.g17f5b7556c-goog Subject: [PATCH v4 11/12] RFC: usb-storage: export symbols in USB_STORAGE namespace From: Matthias Maennich To: linux-kernel@vger.kernel.org Cc: kernel-team@android.com, maennich@google.com, arnd@arndb.de, gregkh@linuxfoundation.org, jeyu@kernel.org, joel@joelfernandes.org, lucas.de.marchi@gmail.com, maco@android.com, sspatil@google.com, will@kernel.org, yamada.masahiro@socionext.com, linux-kbuild@vger.kernel.org, linux-modules@vger.kernel.org, linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, linux-watchdog@vger.kernel.org Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org Modules using these symbols are required to explicitly import the namespace. This patch was generated with the following steps and serves as a reference to use the symbol namespace feature: 1) Define DEFAULT_SYMBOL_NAMESPACE in the corresponding Makefile 2) make (see warnings during modpost about missing imports) 3) make nsdeps Instead of a DEFAULT_SYMBOL_NAMESPACE definition, the EXPORT_SYMBOL_NS variants can be used to explicitly specify the namespace. The advantage of the method used here is that newly added symbols are automatically exported and existing ones are exported without touching their respective EXPORT_SYMBOL macro expansion. Reviewed-by: Greg Kroah-Hartman Signed-off-by: Matthias Maennich --- drivers/usb/storage/Makefile | 2 ++ drivers/usb/storage/alauda.c | 1 + drivers/usb/storage/cypress_atacb.c | 1 + drivers/usb/storage/datafab.c | 1 + drivers/usb/storage/ene_ub6250.c | 1 + drivers/usb/storage/freecom.c | 1 + drivers/usb/storage/isd200.c | 1 + drivers/usb/storage/jumpshot.c | 1 + drivers/usb/storage/karma.c | 1 + drivers/usb/storage/onetouch.c | 1 + drivers/usb/storage/realtek_cr.c | 1 + drivers/usb/storage/sddr09.c | 1 + drivers/usb/storage/sddr55.c | 1 + drivers/usb/storage/shuttle_usbat.c | 1 + drivers/usb/storage/uas.c | 1 + 15 files changed, 16 insertions(+) diff --git a/drivers/usb/storage/Makefile b/drivers/usb/storage/Makefile index a67ddcbb4e24..46635fa4a340 100644 --- a/drivers/usb/storage/Makefile +++ b/drivers/usb/storage/Makefile @@ -8,6 +8,8 @@ ccflags-y := -I $(srctree)/drivers/scsi +ccflags-y += -DDEFAULT_SYMBOL_NAMESPACE=USB_STORAGE + obj-$(CONFIG_USB_UAS) += uas.o obj-$(CONFIG_USB_STORAGE) += usb-storage.o diff --git a/drivers/usb/storage/alauda.c b/drivers/usb/storage/alauda.c index 6b8edf6178df..ddab2cd3d2e7 100644 --- a/drivers/usb/storage/alauda.c +++ b/drivers/usb/storage/alauda.c @@ -36,6 +36,7 @@ MODULE_DESCRIPTION("Driver for Alauda-based card readers"); MODULE_AUTHOR("Daniel Drake "); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(USB_STORAGE); /* * Status bytes diff --git a/drivers/usb/storage/cypress_atacb.c b/drivers/usb/storage/cypress_atacb.c index 4825902377eb..a6f3267bbef6 100644 --- a/drivers/usb/storage/cypress_atacb.c +++ b/drivers/usb/storage/cypress_atacb.c @@ -22,6 +22,7 @@ MODULE_DESCRIPTION("SAT support for Cypress USB/ATA bridges with ATACB"); MODULE_AUTHOR("Matthieu Castet "); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(USB_STORAGE); /* * The table of devices diff --git a/drivers/usb/storage/datafab.c b/drivers/usb/storage/datafab.c index 09353be199be..588818483f4b 100644 --- a/drivers/usb/storage/datafab.c +++ b/drivers/usb/storage/datafab.c @@ -54,6 +54,7 @@ MODULE_DESCRIPTION("Driver for Datafab USB Compact Flash reader"); MODULE_AUTHOR("Jimmie Mayfield "); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(USB_STORAGE); struct datafab_info { unsigned long sectors; /* total sector count */ diff --git a/drivers/usb/storage/ene_ub6250.c b/drivers/usb/storage/ene_ub6250.c index c26129d5b943..8b1b73065421 100644 --- a/drivers/usb/storage/ene_ub6250.c +++ b/drivers/usb/storage/ene_ub6250.c @@ -26,6 +26,7 @@ MODULE_DESCRIPTION("Driver for ENE UB6250 reader"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(USB_STORAGE); MODULE_FIRMWARE(SD_INIT1_FIRMWARE); MODULE_FIRMWARE(SD_INIT2_FIRMWARE); MODULE_FIRMWARE(SD_RW_FIRMWARE); diff --git a/drivers/usb/storage/freecom.c b/drivers/usb/storage/freecom.c index 4f542df37a44..34e7eaff1174 100644 --- a/drivers/usb/storage/freecom.c +++ b/drivers/usb/storage/freecom.c @@ -29,6 +29,7 @@ MODULE_DESCRIPTION("Driver for Freecom USB/IDE adaptor"); MODULE_AUTHOR("David Brown "); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(USB_STORAGE); #ifdef CONFIG_USB_STORAGE_DEBUG static void pdump(struct us_data *us, void *ibuffer, int length); diff --git a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c index 2b474d60b4db..c4da3fd6eff9 100644 --- a/drivers/usb/storage/isd200.c +++ b/drivers/usb/storage/isd200.c @@ -53,6 +53,7 @@ MODULE_DESCRIPTION("Driver for In-System Design, Inc. ISD200 ASIC"); MODULE_AUTHOR("Björn Stenberg "); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(USB_STORAGE); static int isd200_Initialization(struct us_data *us); diff --git a/drivers/usb/storage/jumpshot.c b/drivers/usb/storage/jumpshot.c index 917f170c4124..229bf0c1afc9 100644 --- a/drivers/usb/storage/jumpshot.c +++ b/drivers/usb/storage/jumpshot.c @@ -51,6 +51,7 @@ MODULE_DESCRIPTION("Driver for Lexar \"Jumpshot\" Compact Flash reader"); MODULE_AUTHOR("Jimmie Mayfield "); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(USB_STORAGE); /* * The table of devices diff --git a/drivers/usb/storage/karma.c b/drivers/usb/storage/karma.c index 395cf8fb5870..05cec81dcd3f 100644 --- a/drivers/usb/storage/karma.c +++ b/drivers/usb/storage/karma.c @@ -23,6 +23,7 @@ MODULE_DESCRIPTION("Driver for Rio Karma"); MODULE_AUTHOR("Bob Copeland , Keith Bennett "); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(USB_STORAGE); #define RIO_PREFIX "RIOP\x00" #define RIO_PREFIX_LEN 5 diff --git a/drivers/usb/storage/onetouch.c b/drivers/usb/storage/onetouch.c index 39a5009a41a6..a989fe930e21 100644 --- a/drivers/usb/storage/onetouch.c +++ b/drivers/usb/storage/onetouch.c @@ -25,6 +25,7 @@ MODULE_DESCRIPTION("Maxtor USB OneTouch hard drive button driver"); MODULE_AUTHOR("Nick Sillik "); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(USB_STORAGE); #define ONETOUCH_PKT_LEN 0x02 #define ONETOUCH_BUTTON KEY_PROG1 diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c index 1d9ce9cbc831..3789698d9d3c 100644 --- a/drivers/usb/storage/realtek_cr.c +++ b/drivers/usb/storage/realtek_cr.c @@ -35,6 +35,7 @@ MODULE_DESCRIPTION("Driver for Realtek USB Card Reader"); MODULE_AUTHOR("wwang "); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(USB_STORAGE); static int auto_delink_en = 1; module_param(auto_delink_en, int, S_IRUGO | S_IWUSR); diff --git a/drivers/usb/storage/sddr09.c b/drivers/usb/storage/sddr09.c index bc9da736bdfc..51bcd4a43690 100644 --- a/drivers/usb/storage/sddr09.c +++ b/drivers/usb/storage/sddr09.c @@ -47,6 +47,7 @@ MODULE_DESCRIPTION("Driver for SanDisk SDDR-09 SmartMedia reader"); MODULE_AUTHOR("Andries Brouwer , Robert Baruch "); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(USB_STORAGE); static int usb_stor_sddr09_dpcm_init(struct us_data *us); static int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us); diff --git a/drivers/usb/storage/sddr55.c b/drivers/usb/storage/sddr55.c index b8527c55335b..ba955d65eb0e 100644 --- a/drivers/usb/storage/sddr55.c +++ b/drivers/usb/storage/sddr55.c @@ -29,6 +29,7 @@ MODULE_DESCRIPTION("Driver for SanDisk SDDR-55 SmartMedia reader"); MODULE_AUTHOR("Simon Munton"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(USB_STORAGE); /* * The table of devices diff --git a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c index 854498e1012c..54aa1392c9ca 100644 --- a/drivers/usb/storage/shuttle_usbat.c +++ b/drivers/usb/storage/shuttle_usbat.c @@ -48,6 +48,7 @@ MODULE_DESCRIPTION("Driver for SCM Microsystems (a.k.a. Shuttle) USB-ATAPI cable"); MODULE_AUTHOR("Daniel Drake , Robert Baruch "); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(USB_STORAGE); /* Supported device types */ #define USBAT_DEV_HP8200 0x01 diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c index 047c5922618f..bf80d6f81f58 100644 --- a/drivers/usb/storage/uas.c +++ b/drivers/usb/storage/uas.c @@ -1219,5 +1219,6 @@ static struct usb_driver uas_driver = { module_usb_driver(uas_driver); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(USB_STORAGE); MODULE_AUTHOR( "Hans de Goede , Matthew Wilcox and Sarah Sharp"); From patchwork Tue Sep 3 15:06:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Matthias_M=C3=A4nnich?= X-Patchwork-Id: 11128179 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EDD8A18A6 for ; Tue, 3 Sep 2019 15:08:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BAF522339D for ; Tue, 3 Sep 2019 15:08:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="dUY3N9dI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729946AbfICPIA (ORCPT ); Tue, 3 Sep 2019 11:08:00 -0400 Received: from mail-yw1-f73.google.com ([209.85.161.73]:34042 "EHLO mail-yw1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729923AbfICPIA (ORCPT ); Tue, 3 Sep 2019 11:08:00 -0400 Received: by mail-yw1-f73.google.com with SMTP id b194so13267229ywh.1 for ; Tue, 03 Sep 2019 08:07:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc:content-transfer-encoding; bh=uiVNUyTgfDxnaV9scOzT4vW0KvshsQB635VtUxZQBM0=; b=dUY3N9dINS8P9nAXq9sYzaRpdrofHAbTSiuyGDpgFTyPgUaXpTpPrAcxu7cJf4WDhI 57eSTg+g6cbT9paImYywxXHeMtivP09GcRsdwzrT0KDk0tiyUfTtXCso9k3PipLzDzCE RHGY0I0FdOkD+lQmIuEQKGVyeJtgw32ICnqCFWaB+OyMdKxNeTzonO6aneGEErSf8EJc llR4PWpMiFg9Yn9DBDHmD38zqRzDv4M6IBVI6CnUwtt7YxGAemtAEmwBKnVdAgyw8dhO CD4Pa8nKSu9gnZo9CJbWTQ5cewRqHBtWklDDk9P63FAVy0bOpAK1BnHlCvaoZ3UzMuiK zN+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc:content-transfer-encoding; bh=uiVNUyTgfDxnaV9scOzT4vW0KvshsQB635VtUxZQBM0=; b=Zp11AhEUmm0zyQMw9TBLWh4jrOTbeuhDJWcjbhQW9UXjd3/SYPMboIe9rA731QobXM nctuMlVO9zj2gXiDPNQ+9qLHhxb+DeTgvohASTj0csrieHEPGnWMkbRn0GSgPo0Kbugb 4ep1B+2rJ/OPd7nTmlgq4r4K2k1tAMEnv7tqg2/patcD+GAmJLSBPzFylnZIWfVL/ev1 yVJ/MlqO/c4k8XnGeIlywQxcwIPIb/KSz0w/ubMmUQ4SVTw0NHBxUlqhYNQw6qgnRC3G VnmhqyGdyl6BgFaAnaOQmKqeP877d39SVM35fv4WoC+bOfYSiO/iARhNSkCzBRZFDb4R 9tQQ== X-Gm-Message-State: APjAAAU5J9eYyHjYp7OWkDGSBqhFQMusQ61h9N0X9fIhn/UF6+yoCN1G Z/Pm+EtczbZ8gNeF5Bd64iyBg3dXK1MIZQ== X-Google-Smtp-Source: APXvYqzvlO+tcuWOV9t9xdhpM2jnxlF1TDGX1QPt38w61xOPhCRE8T+4fcQrVBOpotKc7Vn7bDuQsM0WfLR+Yg== X-Received: by 2002:a81:a401:: with SMTP id b1mr8357693ywh.280.1567523278933; Tue, 03 Sep 2019 08:07:58 -0700 (PDT) Date: Tue, 3 Sep 2019 16:06:38 +0100 In-Reply-To: <20190903150638.242049-1-maennich@google.com> Message-Id: <20190903150638.242049-13-maennich@google.com> Mime-Version: 1.0 References: <20180716122125.175792-1-maco@android.com> <20190903150638.242049-1-maennich@google.com> X-Mailer: git-send-email 2.23.0.187.g17f5b7556c-goog Subject: [PATCH v4 12/12] RFC: watchdog: export core symbols in WATCHDOG_CORE namespace From: Matthias Maennich To: linux-kernel@vger.kernel.org Cc: kernel-team@android.com, maennich@google.com, arnd@arndb.de, gregkh@linuxfoundation.org, jeyu@kernel.org, joel@joelfernandes.org, lucas.de.marchi@gmail.com, maco@android.com, sspatil@google.com, will@kernel.org, yamada.masahiro@socionext.com, linux-kbuild@vger.kernel.org, linux-modules@vger.kernel.org, linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, linux-watchdog@vger.kernel.org Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org Modules using symbols from the WATCHDOG_CORE namespace are required to explicitly import the namespace. This patch was generated with the following steps and serves as a reference to use the symbol namespace feature: 1) Use EXPORT_SYMBOL_NS* macros instead of EXPORT_SYMBOL* for symbols in watchdog_core.c 2) make (see warnings during modpost about missing imports) 3) make nsdeps I used 'allmodconfig' for the above steps to ensure all occurrences are patched. Defining DEFAULT_SYMBOL_NAMESPACE in the Makefile is not trivial in this case as not only watchdog_core is defined in drivers/watchdog/Makefile. Hence this patch uses the variant of using the EXPORT_SYMBOL_NS* macros to export into a different namespace. An alternative to this patch would be a single definition line before any use of EXPORT_SYMBOL*: #define DEFAULT_SYMBOL_NAMESPACE WATCHDOG_CORE This patch serves as a reference on how to use the symbol namespaces. Reviewed-by: Greg Kroah-Hartman Signed-off-by: Matthias Maennich --- drivers/hwmon/ftsteutates.c | 1 + drivers/hwmon/sch56xx-common.c | 1 + drivers/rtc/rtc-abx80x.c | 1 + drivers/watchdog/armada_37xx_wdt.c | 1 + drivers/watchdog/asm9260_wdt.c | 1 + drivers/watchdog/aspeed_wdt.c | 1 + drivers/watchdog/at91sam9_wdt.c | 1 + drivers/watchdog/atlas7_wdt.c | 1 + drivers/watchdog/bcm2835_wdt.c | 1 + drivers/watchdog/bcm47xx_wdt.c | 1 + drivers/watchdog/bcm7038_wdt.c | 1 + drivers/watchdog/bcm_kona_wdt.c | 1 + drivers/watchdog/bd70528_wdt.c | 1 + drivers/watchdog/cadence_wdt.c | 1 + drivers/watchdog/da9052_wdt.c | 1 + drivers/watchdog/da9055_wdt.c | 1 + drivers/watchdog/da9062_wdt.c | 1 + drivers/watchdog/da9063_wdt.c | 1 + drivers/watchdog/davinci_wdt.c | 1 + drivers/watchdog/digicolor_wdt.c | 1 + drivers/watchdog/dw_wdt.c | 1 + drivers/watchdog/ebc-c384_wdt.c | 1 + drivers/watchdog/ep93xx_wdt.c | 1 + drivers/watchdog/ftwdt010_wdt.c | 1 + drivers/watchdog/gpio_wdt.c | 1 + drivers/watchdog/hpwdt.c | 1 + drivers/watchdog/i6300esb.c | 1 + drivers/watchdog/iTCO_wdt.c | 1 + drivers/watchdog/ie6xx_wdt.c | 1 + drivers/watchdog/imgpdc_wdt.c | 1 + drivers/watchdog/imx2_wdt.c | 1 + drivers/watchdog/intel-mid_wdt.c | 1 + drivers/watchdog/it87_wdt.c | 1 + drivers/watchdog/kempld_wdt.c | 1 + drivers/watchdog/lpc18xx_wdt.c | 1 + drivers/watchdog/max63xx_wdt.c | 1 + drivers/watchdog/max77620_wdt.c | 1 + drivers/watchdog/mei_wdt.c | 1 + drivers/watchdog/mena21_wdt.c | 1 + drivers/watchdog/menf21bmc_wdt.c | 1 + drivers/watchdog/menz69_wdt.c | 1 + drivers/watchdog/meson_gxbb_wdt.c | 1 + drivers/watchdog/meson_wdt.c | 1 + drivers/watchdog/mlx_wdt.c | 1 + drivers/watchdog/moxart_wdt.c | 1 + drivers/watchdog/mtk_wdt.c | 1 + drivers/watchdog/ni903x_wdt.c | 1 + drivers/watchdog/nic7018_wdt.c | 1 + drivers/watchdog/npcm_wdt.c | 1 + drivers/watchdog/of_xilinx_wdt.c | 1 + drivers/watchdog/omap_wdt.c | 1 + drivers/watchdog/pm8916_wdt.c | 1 + drivers/watchdog/qcom-wdt.c | 1 + drivers/watchdog/rave-sp-wdt.c | 1 + drivers/watchdog/renesas_wdt.c | 1 + drivers/watchdog/retu_wdt.c | 1 + drivers/watchdog/rn5t618_wdt.c | 1 + drivers/watchdog/rza_wdt.c | 1 + drivers/watchdog/s3c2410_wdt.c | 1 + drivers/watchdog/sama5d4_wdt.c | 1 + drivers/watchdog/sirfsoc_wdt.c | 1 + drivers/watchdog/softdog.c | 1 + drivers/watchdog/sp5100_tco.c | 1 + drivers/watchdog/sprd_wdt.c | 1 + drivers/watchdog/st_lpc_wdt.c | 1 + drivers/watchdog/stmp3xxx_rtc_wdt.c | 1 + drivers/watchdog/stpmic1_wdt.c | 1 + drivers/watchdog/sunxi_wdt.c | 1 + drivers/watchdog/tangox_wdt.c | 1 + drivers/watchdog/tegra_wdt.c | 1 + drivers/watchdog/tqmx86_wdt.c | 1 + drivers/watchdog/ts4800_wdt.c | 1 + drivers/watchdog/ts72xx_wdt.c | 1 + drivers/watchdog/twl4030_wdt.c | 1 + drivers/watchdog/uniphier_wdt.c | 1 + drivers/watchdog/via_wdt.c | 1 + drivers/watchdog/w83627hf_wdt.c | 1 + drivers/watchdog/watchdog_core.c | 10 +++++----- drivers/watchdog/wdat_wdt.c | 1 + drivers/watchdog/wm831x_wdt.c | 1 + drivers/watchdog/wm8350_wdt.c | 1 + drivers/watchdog/xen_wdt.c | 1 + drivers/watchdog/ziirave_wdt.c | 1 + 83 files changed, 87 insertions(+), 5 deletions(-) diff --git a/drivers/hwmon/ftsteutates.c b/drivers/hwmon/ftsteutates.c index 371ce7745f5e..fa67f7c565be 100644 --- a/drivers/hwmon/ftsteutates.c +++ b/drivers/hwmon/ftsteutates.c @@ -830,3 +830,4 @@ module_i2c_driver(fts_driver); MODULE_AUTHOR("Thilo Cestonaro "); MODULE_DESCRIPTION("FTS Teutates driver"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/hwmon/sch56xx-common.c b/drivers/hwmon/sch56xx-common.c index 6c84780e358e..06dd840f3bf7 100644 --- a/drivers/hwmon/sch56xx-common.c +++ b/drivers/hwmon/sch56xx-common.c @@ -571,6 +571,7 @@ static void __exit sch56xx_exit(void) MODULE_DESCRIPTION("SMSC SCH56xx Hardware Monitoring Common Code"); MODULE_AUTHOR("Hans de Goede "); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); module_init(sch56xx_init); module_exit(sch56xx_exit); diff --git a/drivers/rtc/rtc-abx80x.c b/drivers/rtc/rtc-abx80x.c index 73830670a41f..3ff3b96d14d7 100644 --- a/drivers/rtc/rtc-abx80x.c +++ b/drivers/rtc/rtc-abx80x.c @@ -880,3 +880,4 @@ MODULE_AUTHOR("Philippe De Muyter "); MODULE_AUTHOR("Alexandre Belloni "); MODULE_DESCRIPTION("Abracon ABX80X RTC driver"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/armada_37xx_wdt.c b/drivers/watchdog/armada_37xx_wdt.c index e5dcb26d85f0..00e153ae70eb 100644 --- a/drivers/watchdog/armada_37xx_wdt.c +++ b/drivers/watchdog/armada_37xx_wdt.c @@ -370,4 +370,5 @@ MODULE_AUTHOR("Marek Behun "); MODULE_DESCRIPTION("Armada 37xx CPU Watchdog"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(WATCHDOG_CORE); MODULE_ALIAS("platform:armada_37xx_wdt"); diff --git a/drivers/watchdog/asm9260_wdt.c b/drivers/watchdog/asm9260_wdt.c index 45047e514b8e..fd7289df2cb3 100644 --- a/drivers/watchdog/asm9260_wdt.c +++ b/drivers/watchdog/asm9260_wdt.c @@ -374,3 +374,4 @@ module_platform_driver(asm9260_wdt_driver); MODULE_DESCRIPTION("asm9260 WatchDog Timer Driver"); MODULE_AUTHOR("Oleksij Rempel "); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/aspeed_wdt.c b/drivers/watchdog/aspeed_wdt.c index cc71861e033a..2607158965d6 100644 --- a/drivers/watchdog/aspeed_wdt.c +++ b/drivers/watchdog/aspeed_wdt.c @@ -334,3 +334,4 @@ module_exit(aspeed_wdt_exit); MODULE_DESCRIPTION("Aspeed Watchdog Driver"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/at91sam9_wdt.c b/drivers/watchdog/at91sam9_wdt.c index 292b5a1ca831..e7aa31fe4336 100644 --- a/drivers/watchdog/at91sam9_wdt.c +++ b/drivers/watchdog/at91sam9_wdt.c @@ -416,3 +416,4 @@ module_platform_driver_probe(at91wdt_driver, at91wdt_probe); MODULE_AUTHOR("Renaud CERRATO "); MODULE_DESCRIPTION("Watchdog driver for Atmel AT91SAM9x processors"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/atlas7_wdt.c b/drivers/watchdog/atlas7_wdt.c index 9bfe650d802f..f67e6f101102 100644 --- a/drivers/watchdog/atlas7_wdt.c +++ b/drivers/watchdog/atlas7_wdt.c @@ -218,4 +218,5 @@ module_platform_driver(atlas7_wdt_driver); MODULE_DESCRIPTION("CSRatlas7 watchdog driver"); MODULE_AUTHOR("Guo Zeng "); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(WATCHDOG_CORE); MODULE_ALIAS("platform:atlas7-wdt"); diff --git a/drivers/watchdog/bcm2835_wdt.c b/drivers/watchdog/bcm2835_wdt.c index dec6ca019bea..2f41b8a6e2f6 100644 --- a/drivers/watchdog/bcm2835_wdt.c +++ b/drivers/watchdog/bcm2835_wdt.c @@ -242,3 +242,4 @@ MODULE_ALIAS("platform:bcm2835-wdt"); MODULE_AUTHOR("Lubomir Rintel "); MODULE_DESCRIPTION("Driver for Broadcom BCM2835 watchdog timer"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/bcm47xx_wdt.c b/drivers/watchdog/bcm47xx_wdt.c index 05425c1dfd4c..231009f01024 100644 --- a/drivers/watchdog/bcm47xx_wdt.c +++ b/drivers/watchdog/bcm47xx_wdt.c @@ -241,3 +241,4 @@ MODULE_AUTHOR("Aleksandar Radovanovic"); MODULE_AUTHOR("Hauke Mehrtens "); MODULE_DESCRIPTION("Watchdog driver for Broadcom BCM47xx"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/bcm7038_wdt.c b/drivers/watchdog/bcm7038_wdt.c index 979caa18d3c8..e66184997775 100644 --- a/drivers/watchdog/bcm7038_wdt.c +++ b/drivers/watchdog/bcm7038_wdt.c @@ -212,5 +212,6 @@ module_param(nowayout, bool, 0); MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); MODULE_DESCRIPTION("Driver for Broadcom 7038 SoCs Watchdog"); MODULE_AUTHOR("Justin Chen"); diff --git a/drivers/watchdog/bcm_kona_wdt.c b/drivers/watchdog/bcm_kona_wdt.c index eb850a8d19df..5b5a6a76c1aa 100644 --- a/drivers/watchdog/bcm_kona_wdt.c +++ b/drivers/watchdog/bcm_kona_wdt.c @@ -339,3 +339,4 @@ MODULE_ALIAS("platform:" BCM_KONA_WDT_NAME); MODULE_AUTHOR("Markus Mayer "); MODULE_DESCRIPTION("Broadcom Kona Watchdog Driver"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/bd70528_wdt.c b/drivers/watchdog/bd70528_wdt.c index b0152fef4fc7..790748a3a30a 100644 --- a/drivers/watchdog/bd70528_wdt.c +++ b/drivers/watchdog/bd70528_wdt.c @@ -288,3 +288,4 @@ module_platform_driver(bd70528_wdt); MODULE_AUTHOR("Matti Vaittinen "); MODULE_DESCRIPTION("BD70528 watchdog driver"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/cadence_wdt.c b/drivers/watchdog/cadence_wdt.c index f8d4e91d0383..a44f3140656e 100644 --- a/drivers/watchdog/cadence_wdt.c +++ b/drivers/watchdog/cadence_wdt.c @@ -438,3 +438,4 @@ module_platform_driver(cdns_wdt_driver); MODULE_AUTHOR("Xilinx, Inc."); MODULE_DESCRIPTION("Watchdog driver for Cadence WDT"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/da9052_wdt.c b/drivers/watchdog/da9052_wdt.c index d708c091bf1b..a5ceea0503bb 100644 --- a/drivers/watchdog/da9052_wdt.c +++ b/drivers/watchdog/da9052_wdt.c @@ -191,4 +191,5 @@ module_platform_driver(da9052_wdt_driver); MODULE_AUTHOR("Anthony Olech "); MODULE_DESCRIPTION("DA9052 SM Device Driver"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); MODULE_ALIAS("platform:da9052-watchdog"); diff --git a/drivers/watchdog/da9055_wdt.c b/drivers/watchdog/da9055_wdt.c index 389a4bdd208c..05b075f2ea90 100644 --- a/drivers/watchdog/da9055_wdt.c +++ b/drivers/watchdog/da9055_wdt.c @@ -166,4 +166,5 @@ module_platform_driver(da9055_wdt_driver); MODULE_AUTHOR("David Dajun Chen "); MODULE_DESCRIPTION("DA9055 watchdog"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); MODULE_ALIAS("platform:da9055-watchdog"); diff --git a/drivers/watchdog/da9062_wdt.c b/drivers/watchdog/da9062_wdt.c index e149e66a6ea9..dfc2025d36ba 100644 --- a/drivers/watchdog/da9062_wdt.c +++ b/drivers/watchdog/da9062_wdt.c @@ -232,4 +232,5 @@ module_platform_driver(da9062_wdt_driver); MODULE_AUTHOR("S Twiss "); MODULE_DESCRIPTION("WDT device driver for Dialog DA9062 and DA9061"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); MODULE_ALIAS("platform:da9062-watchdog"); diff --git a/drivers/watchdog/da9063_wdt.c b/drivers/watchdog/da9063_wdt.c index 3d65e92a4e3f..ae0cb7011762 100644 --- a/drivers/watchdog/da9063_wdt.c +++ b/drivers/watchdog/da9063_wdt.c @@ -239,4 +239,5 @@ module_platform_driver(da9063_wdt_driver); MODULE_AUTHOR("Mariusz Wojtasik "); MODULE_DESCRIPTION("Watchdog driver for Dialog DA9063"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); MODULE_ALIAS("platform:" DA9063_DRVNAME_WATCHDOG); diff --git a/drivers/watchdog/davinci_wdt.c b/drivers/watchdog/davinci_wdt.c index 2b3f3cd382ef..4fa01dfa4edb 100644 --- a/drivers/watchdog/davinci_wdt.c +++ b/drivers/watchdog/davinci_wdt.c @@ -274,4 +274,5 @@ MODULE_PARM_DESC(heartbeat, __MODULE_STRING(DEFAULT_HEARTBEAT)); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); MODULE_ALIAS("platform:davinci-wdt"); diff --git a/drivers/watchdog/digicolor_wdt.c b/drivers/watchdog/digicolor_wdt.c index 073d37867f47..ed86cf879dae 100644 --- a/drivers/watchdog/digicolor_wdt.c +++ b/drivers/watchdog/digicolor_wdt.c @@ -161,3 +161,4 @@ module_platform_driver(dc_wdt_driver); MODULE_AUTHOR("Baruch Siach "); MODULE_DESCRIPTION("Driver for Conexant Digicolor watchdog timer"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c index fef7c61f5555..e98ccb38eb1d 100644 --- a/drivers/watchdog/dw_wdt.c +++ b/drivers/watchdog/dw_wdt.c @@ -340,3 +340,4 @@ module_platform_driver(dw_wdt_driver); MODULE_AUTHOR("Jamie Iles"); MODULE_DESCRIPTION("Synopsys DesignWare Watchdog Driver"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/ebc-c384_wdt.c b/drivers/watchdog/ebc-c384_wdt.c index 8ef4b0df3855..7e4349472745 100644 --- a/drivers/watchdog/ebc-c384_wdt.c +++ b/drivers/watchdog/ebc-c384_wdt.c @@ -139,4 +139,5 @@ module_exit(ebc_c384_wdt_exit); MODULE_AUTHOR("William Breathitt Gray "); MODULE_DESCRIPTION("WinSystems EBC-C384 watchdog timer driver"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(WATCHDOG_CORE); MODULE_ALIAS("isa:" MODULE_NAME); diff --git a/drivers/watchdog/ep93xx_wdt.c b/drivers/watchdog/ep93xx_wdt.c index 38e26f160b9a..edfa422896d7 100644 --- a/drivers/watchdog/ep93xx_wdt.c +++ b/drivers/watchdog/ep93xx_wdt.c @@ -144,3 +144,4 @@ MODULE_AUTHOR("Alessandro Zummo "); MODULE_AUTHOR("H Hartley Sweeten "); MODULE_DESCRIPTION("EP93xx Watchdog"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/ftwdt010_wdt.c b/drivers/watchdog/ftwdt010_wdt.c index 21dcc7765688..c19186bc00b6 100644 --- a/drivers/watchdog/ftwdt010_wdt.c +++ b/drivers/watchdog/ftwdt010_wdt.c @@ -227,3 +227,4 @@ module_platform_driver(ftwdt010_wdt_driver); MODULE_AUTHOR("Linus Walleij"); MODULE_DESCRIPTION("Watchdog driver for Faraday Technology FTWDT010"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/gpio_wdt.c b/drivers/watchdog/gpio_wdt.c index 0923201ce874..6a90a7ecadeb 100644 --- a/drivers/watchdog/gpio_wdt.c +++ b/drivers/watchdog/gpio_wdt.c @@ -194,3 +194,4 @@ module_platform_driver(gpio_wdt_driver); MODULE_AUTHOR("Alexander Shiyan "); MODULE_DESCRIPTION("GPIO Watchdog"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c index 7d34bcf1c45b..fb4d228a0d7e 100644 --- a/drivers/watchdog/hpwdt.c +++ b/drivers/watchdog/hpwdt.c @@ -386,6 +386,7 @@ static struct pci_driver hpwdt_driver = { MODULE_AUTHOR("Tom Mingarelli"); MODULE_DESCRIPTION("hpe watchdog driver"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); MODULE_VERSION(HPWDT_VERSION); module_param(soft_margin, int, 0); diff --git a/drivers/watchdog/i6300esb.c b/drivers/watchdog/i6300esb.c index a30835f547b3..700a8c6cae00 100644 --- a/drivers/watchdog/i6300esb.c +++ b/drivers/watchdog/i6300esb.c @@ -351,3 +351,4 @@ module_pci_driver(esb_driver); MODULE_AUTHOR("Ross Biro and David Härdeman"); MODULE_DESCRIPTION("Watchdog driver for Intel 6300ESB chipsets"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c index c559f706ae7e..454d8ff3edc1 100644 --- a/drivers/watchdog/iTCO_wdt.c +++ b/drivers/watchdog/iTCO_wdt.c @@ -632,4 +632,5 @@ MODULE_AUTHOR("Wim Van Sebroeck "); MODULE_DESCRIPTION("Intel TCO WatchDog Timer Driver"); MODULE_VERSION(DRV_VERSION); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); MODULE_ALIAS("platform:" DRV_NAME); diff --git a/drivers/watchdog/ie6xx_wdt.c b/drivers/watchdog/ie6xx_wdt.c index 8f28993fab8b..76bcff28eaf9 100644 --- a/drivers/watchdog/ie6xx_wdt.c +++ b/drivers/watchdog/ie6xx_wdt.c @@ -314,4 +314,5 @@ module_exit(ie6xx_wdt_exit); MODULE_AUTHOR("Alexander Stein "); MODULE_DESCRIPTION("Intel Atom E6xx Watchdog Device Driver"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); MODULE_ALIAS("platform:" DRIVER_NAME); diff --git a/drivers/watchdog/imgpdc_wdt.c b/drivers/watchdog/imgpdc_wdt.c index b57ff3787052..6fe0fd7c0719 100644 --- a/drivers/watchdog/imgpdc_wdt.c +++ b/drivers/watchdog/imgpdc_wdt.c @@ -314,3 +314,4 @@ MODULE_AUTHOR("Jude Abraham "); MODULE_AUTHOR("Naidu Tellapati "); MODULE_DESCRIPTION("Imagination Technologies PDC Watchdog Timer Driver"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c index 32af3974e6bb..dc6d4132ec1f 100644 --- a/drivers/watchdog/imx2_wdt.c +++ b/drivers/watchdog/imx2_wdt.c @@ -433,4 +433,5 @@ module_platform_driver_probe(imx2_wdt_driver, imx2_wdt_probe); MODULE_AUTHOR("Wolfram Sang"); MODULE_DESCRIPTION("Watchdog driver for IMX2 and later"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(WATCHDOG_CORE); MODULE_ALIAS("platform:" DRIVER_NAME); diff --git a/drivers/watchdog/intel-mid_wdt.c b/drivers/watchdog/intel-mid_wdt.c index 2cdbd37c700c..b859fd6d263b 100644 --- a/drivers/watchdog/intel-mid_wdt.c +++ b/drivers/watchdog/intel-mid_wdt.c @@ -181,3 +181,4 @@ module_platform_driver(mid_wdt_driver); MODULE_AUTHOR("David Cohen "); MODULE_DESCRIPTION("Watchdog Driver for Intel MID platform"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/it87_wdt.c b/drivers/watchdog/it87_wdt.c index a4b71ebc8cab..610f5cdebf72 100644 --- a/drivers/watchdog/it87_wdt.c +++ b/drivers/watchdog/it87_wdt.c @@ -354,3 +354,4 @@ module_exit(it87_wdt_exit); MODULE_AUTHOR("Oliver Schuster"); MODULE_DESCRIPTION("Hardware Watchdog Device Driver for IT87xx EC-LPC I/O"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/kempld_wdt.c b/drivers/watchdog/kempld_wdt.c index 40bd518ed873..20a40e221dbb 100644 --- a/drivers/watchdog/kempld_wdt.c +++ b/drivers/watchdog/kempld_wdt.c @@ -550,3 +550,4 @@ module_platform_driver(kempld_wdt_driver); MODULE_DESCRIPTION("KEM PLD Watchdog Driver"); MODULE_AUTHOR("Michael Brunner "); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/lpc18xx_wdt.c b/drivers/watchdog/lpc18xx_wdt.c index 78cf11c94941..4e34a4bd0b24 100644 --- a/drivers/watchdog/lpc18xx_wdt.c +++ b/drivers/watchdog/lpc18xx_wdt.c @@ -316,3 +316,4 @@ module_platform_driver(lpc18xx_wdt_driver); MODULE_AUTHOR("Ariel D'Alessandro "); MODULE_DESCRIPTION("NXP LPC18xx Watchdog Timer Driver"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/max63xx_wdt.c b/drivers/watchdog/max63xx_wdt.c index 3a899628a834..053c9285adac 100644 --- a/drivers/watchdog/max63xx_wdt.c +++ b/drivers/watchdog/max63xx_wdt.c @@ -284,3 +284,4 @@ MODULE_PARM_DESC(nodelay, "(max6373/74 only, default=0)"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/max77620_wdt.c b/drivers/watchdog/max77620_wdt.c index be6a53c30002..304817d379a7 100644 --- a/drivers/watchdog/max77620_wdt.c +++ b/drivers/watchdog/max77620_wdt.c @@ -209,3 +209,4 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started " MODULE_AUTHOR("Laxman Dewangan "); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/mei_wdt.c b/drivers/watchdog/mei_wdt.c index 5391bf3e6b11..5e03226cada1 100644 --- a/drivers/watchdog/mei_wdt.c +++ b/drivers/watchdog/mei_wdt.c @@ -662,4 +662,5 @@ module_mei_cl_driver(mei_wdt_driver); MODULE_AUTHOR("Intel Corporation"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(WATCHDOG_CORE); MODULE_DESCRIPTION("Device driver for Intel MEI iAMT watchdog"); diff --git a/drivers/watchdog/mena21_wdt.c b/drivers/watchdog/mena21_wdt.c index 99d2359d5a8a..b759c66f1446 100644 --- a/drivers/watchdog/mena21_wdt.c +++ b/drivers/watchdog/mena21_wdt.c @@ -225,4 +225,5 @@ module_platform_driver(a21_wdt_driver); MODULE_AUTHOR("MEN Mikro Elektronik"); MODULE_DESCRIPTION("MEN A21 Watchdog"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); MODULE_ALIAS("platform:a21-watchdog"); diff --git a/drivers/watchdog/menf21bmc_wdt.c b/drivers/watchdog/menf21bmc_wdt.c index 81ebdfc371f4..358881618e2f 100644 --- a/drivers/watchdog/menf21bmc_wdt.c +++ b/drivers/watchdog/menf21bmc_wdt.c @@ -181,4 +181,5 @@ module_platform_driver(menf21bmc_wdt); MODULE_DESCRIPTION("MEN 14F021P00 BMC Watchdog driver"); MODULE_AUTHOR("Andreas Werner "); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(WATCHDOG_CORE); MODULE_ALIAS("platform:menf21bmc_wdt"); diff --git a/drivers/watchdog/menz69_wdt.c b/drivers/watchdog/menz69_wdt.c index ed18238c5407..d13fcfc0f59c 100644 --- a/drivers/watchdog/menz69_wdt.c +++ b/drivers/watchdog/menz69_wdt.c @@ -167,4 +167,5 @@ module_mcb_driver(men_z069_driver); MODULE_AUTHOR("Johannes Thumshirn "); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(WATCHDOG_CORE); MODULE_ALIAS("mcb:16z069"); diff --git a/drivers/watchdog/meson_gxbb_wdt.c b/drivers/watchdog/meson_gxbb_wdt.c index d17c1a6ed723..f30f85380679 100644 --- a/drivers/watchdog/meson_gxbb_wdt.c +++ b/drivers/watchdog/meson_gxbb_wdt.c @@ -204,3 +204,4 @@ module_platform_driver(meson_gxbb_wdt_driver); MODULE_AUTHOR("Neil Armstrong "); MODULE_DESCRIPTION("Amlogic Meson GXBB Watchdog timer driver"); MODULE_LICENSE("Dual BSD/GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/meson_wdt.c b/drivers/watchdog/meson_wdt.c index 459f3ae02c91..0d60bb5aa688 100644 --- a/drivers/watchdog/meson_wdt.c +++ b/drivers/watchdog/meson_wdt.c @@ -228,5 +228,6 @@ MODULE_PARM_DESC(nowayout, __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); MODULE_AUTHOR("Carlo Caione "); MODULE_DESCRIPTION("Meson Watchdog Timer Driver"); diff --git a/drivers/watchdog/mlx_wdt.c b/drivers/watchdog/mlx_wdt.c index 03b9ac4b99af..2df48a6ed04b 100644 --- a/drivers/watchdog/mlx_wdt.c +++ b/drivers/watchdog/mlx_wdt.c @@ -287,4 +287,5 @@ module_platform_driver(mlxreg_wdt_driver); MODULE_AUTHOR("Michael Shych "); MODULE_DESCRIPTION("Mellanox watchdog driver"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); MODULE_ALIAS("platform:mlx-wdt"); diff --git a/drivers/watchdog/moxart_wdt.c b/drivers/watchdog/moxart_wdt.c index 6340a1f5f471..02dbfe2accfa 100644 --- a/drivers/watchdog/moxart_wdt.c +++ b/drivers/watchdog/moxart_wdt.c @@ -164,4 +164,5 @@ MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds"); MODULE_DESCRIPTION("MOXART watchdog driver"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); MODULE_AUTHOR("Jonas Jensen "); diff --git a/drivers/watchdog/mtk_wdt.c b/drivers/watchdog/mtk_wdt.c index 9c3d0033260d..074c04324738 100644 --- a/drivers/watchdog/mtk_wdt.c +++ b/drivers/watchdog/mtk_wdt.c @@ -247,6 +247,7 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); MODULE_AUTHOR("Matthias Brugger "); MODULE_DESCRIPTION("Mediatek WatchDog Timer Driver"); MODULE_VERSION(DRV_VERSION); diff --git a/drivers/watchdog/ni903x_wdt.c b/drivers/watchdog/ni903x_wdt.c index 4cebad324b20..724d47f2f325 100644 --- a/drivers/watchdog/ni903x_wdt.c +++ b/drivers/watchdog/ni903x_wdt.c @@ -255,3 +255,4 @@ MODULE_DESCRIPTION("NI 903x Watchdog"); MODULE_AUTHOR("Jeff Westfahl "); MODULE_AUTHOR("Kyle Roeschley "); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/nic7018_wdt.c b/drivers/watchdog/nic7018_wdt.c index 2a46cc662943..efe0f188c79a 100644 --- a/drivers/watchdog/nic7018_wdt.c +++ b/drivers/watchdog/nic7018_wdt.c @@ -250,3 +250,4 @@ module_platform_driver(watchdog_driver); MODULE_DESCRIPTION("National Instruments NIC7018 Watchdog driver"); MODULE_AUTHOR("Hui Chun Ong "); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/npcm_wdt.c b/drivers/watchdog/npcm_wdt.c index 9c773c3d6d5d..aa2022a44985 100644 --- a/drivers/watchdog/npcm_wdt.c +++ b/drivers/watchdog/npcm_wdt.c @@ -248,3 +248,4 @@ module_platform_driver(npcm_wdt_driver); MODULE_AUTHOR("Joel Stanley"); MODULE_DESCRIPTION("Watchdog driver for NPCM"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/of_xilinx_wdt.c b/drivers/watchdog/of_xilinx_wdt.c index 7fe4f7c3f7ce..8d93e2089c6d 100644 --- a/drivers/watchdog/of_xilinx_wdt.c +++ b/drivers/watchdog/of_xilinx_wdt.c @@ -308,3 +308,4 @@ module_platform_driver(xwdt_driver); MODULE_AUTHOR("Alejandro Cabrera "); MODULE_DESCRIPTION("Xilinx Watchdog driver"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c index 9b91882fe3c4..49565608924a 100644 --- a/drivers/watchdog/omap_wdt.c +++ b/drivers/watchdog/omap_wdt.c @@ -375,4 +375,5 @@ module_platform_driver(omap_wdt_driver); MODULE_AUTHOR("George G. Davis"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); MODULE_ALIAS("platform:omap_wdt"); diff --git a/drivers/watchdog/pm8916_wdt.c b/drivers/watchdog/pm8916_wdt.c index 2d3652004e39..f13c1c2bec07 100644 --- a/drivers/watchdog/pm8916_wdt.c +++ b/drivers/watchdog/pm8916_wdt.c @@ -210,3 +210,4 @@ module_platform_driver(pm8916_wdt_driver); MODULE_AUTHOR("Loic Poulain "); MODULE_DESCRIPTION("Qualcomm pm8916 watchdog driver"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/qcom-wdt.c b/drivers/watchdog/qcom-wdt.c index 7be7f87be28f..1ae02d3b5cb2 100644 --- a/drivers/watchdog/qcom-wdt.c +++ b/drivers/watchdog/qcom-wdt.c @@ -272,3 +272,4 @@ module_platform_driver(qcom_watchdog_driver); MODULE_DESCRIPTION("QCOM KPSS Watchdog Driver"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/rave-sp-wdt.c b/drivers/watchdog/rave-sp-wdt.c index 2c95615b6354..7fac3fabfcfb 100644 --- a/drivers/watchdog/rave-sp-wdt.c +++ b/drivers/watchdog/rave-sp-wdt.c @@ -329,6 +329,7 @@ module_platform_driver(rave_sp_wdt_driver); MODULE_DEVICE_TABLE(of, rave_sp_wdt_of_match); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); MODULE_AUTHOR("Andrey Vostrikov "); MODULE_AUTHOR("Nikita Yushchenko "); MODULE_AUTHOR("Andrey Smirnov "); diff --git a/drivers/watchdog/renesas_wdt.c b/drivers/watchdog/renesas_wdt.c index 00662a8e039c..ec5b1ec6c292 100644 --- a/drivers/watchdog/renesas_wdt.c +++ b/drivers/watchdog/renesas_wdt.c @@ -315,4 +315,5 @@ module_platform_driver(rwdt_driver); MODULE_DESCRIPTION("Renesas WDT Watchdog Driver"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(WATCHDOG_CORE); MODULE_AUTHOR("Wolfram Sang "); diff --git a/drivers/watchdog/retu_wdt.c b/drivers/watchdog/retu_wdt.c index 258dfcf9cbda..6a3e2b8e5226 100644 --- a/drivers/watchdog/retu_wdt.c +++ b/drivers/watchdog/retu_wdt.c @@ -168,3 +168,4 @@ MODULE_DESCRIPTION("Retu watchdog"); MODULE_AUTHOR("Amit Kucheria"); MODULE_AUTHOR("Aaro Koskinen "); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/rn5t618_wdt.c b/drivers/watchdog/rn5t618_wdt.c index 234876047431..8f7bc6b1cb64 100644 --- a/drivers/watchdog/rn5t618_wdt.c +++ b/drivers/watchdog/rn5t618_wdt.c @@ -191,3 +191,4 @@ module_platform_driver(rn5t618_wdt_driver); MODULE_AUTHOR("Beniamino Galvani "); MODULE_DESCRIPTION("RN5T618 watchdog driver"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/rza_wdt.c b/drivers/watchdog/rza_wdt.c index 7b6c365f7cd3..31ff9acc9af2 100644 --- a/drivers/watchdog/rza_wdt.c +++ b/drivers/watchdog/rza_wdt.c @@ -245,3 +245,4 @@ module_platform_driver(rza_wdt_driver); MODULE_DESCRIPTION("Renesas RZ/A WDT Driver"); MODULE_AUTHOR("Chris Brandt "); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c index 2395f353e52d..5c1800d41411 100644 --- a/drivers/watchdog/s3c2410_wdt.c +++ b/drivers/watchdog/s3c2410_wdt.c @@ -739,3 +739,4 @@ module_platform_driver(s3c2410wdt_driver); MODULE_AUTHOR("Ben Dooks , Dimitry Andric "); MODULE_DESCRIPTION("S3C2410 Watchdog Device Driver"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/sama5d4_wdt.c b/drivers/watchdog/sama5d4_wdt.c index d193a60430b2..725f68703f1e 100644 --- a/drivers/watchdog/sama5d4_wdt.c +++ b/drivers/watchdog/sama5d4_wdt.c @@ -321,3 +321,4 @@ module_platform_driver(sama5d4_wdt_driver); MODULE_AUTHOR("Atmel Corporation"); MODULE_DESCRIPTION("Atmel SAMA5D4 Watchdog Timer driver"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/sirfsoc_wdt.c b/drivers/watchdog/sirfsoc_wdt.c index 734cf2966ecb..bcb75d9978f0 100644 --- a/drivers/watchdog/sirfsoc_wdt.c +++ b/drivers/watchdog/sirfsoc_wdt.c @@ -213,4 +213,5 @@ module_platform_driver(sirfsoc_wdt_driver); MODULE_DESCRIPTION("SiRF SoC watchdog driver"); MODULE_AUTHOR("Xianglong Du "); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(WATCHDOG_CORE); MODULE_ALIAS("platform:sirfsoc-wdt"); diff --git a/drivers/watchdog/softdog.c b/drivers/watchdog/softdog.c index 3e4885c1545e..8d50543f7340 100644 --- a/drivers/watchdog/softdog.c +++ b/drivers/watchdog/softdog.c @@ -165,3 +165,4 @@ module_exit(softdog_exit); MODULE_AUTHOR("Alan Cox"); MODULE_DESCRIPTION("Software Watchdog Device Driver"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/sp5100_tco.c b/drivers/watchdog/sp5100_tco.c index 93bd302ae7c5..716b9c43baf1 100644 --- a/drivers/watchdog/sp5100_tco.c +++ b/drivers/watchdog/sp5100_tco.c @@ -486,3 +486,4 @@ module_exit(sp5100_tco_exit); MODULE_AUTHOR("Priyanka Gupta"); MODULE_DESCRIPTION("TCO timer driver for SP5100/SB800 chipset"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/sprd_wdt.c b/drivers/watchdog/sprd_wdt.c index edba4e278685..55e883e8dcf4 100644 --- a/drivers/watchdog/sprd_wdt.c +++ b/drivers/watchdog/sprd_wdt.c @@ -384,3 +384,4 @@ module_platform_driver(sprd_watchdog_driver); MODULE_AUTHOR("Eric Long "); MODULE_DESCRIPTION("Spreadtrum Watchdog Timer Controller Driver"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/st_lpc_wdt.c b/drivers/watchdog/st_lpc_wdt.c index 14ab6559c748..4a7e6b4694fa 100644 --- a/drivers/watchdog/st_lpc_wdt.c +++ b/drivers/watchdog/st_lpc_wdt.c @@ -305,3 +305,4 @@ module_platform_driver(st_wdog_driver); MODULE_AUTHOR("David Paris "); MODULE_DESCRIPTION("ST LPC Watchdog Driver"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/stmp3xxx_rtc_wdt.c b/drivers/watchdog/stmp3xxx_rtc_wdt.c index 7caf3aa71c6a..f1dd033c2b4b 100644 --- a/drivers/watchdog/stmp3xxx_rtc_wdt.c +++ b/drivers/watchdog/stmp3xxx_rtc_wdt.c @@ -150,4 +150,5 @@ module_platform_driver(stmp3xxx_wdt_driver); MODULE_DESCRIPTION("STMP3XXX RTC Watchdog Driver"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(WATCHDOG_CORE); MODULE_AUTHOR("Wolfram Sang "); diff --git a/drivers/watchdog/stpmic1_wdt.c b/drivers/watchdog/stpmic1_wdt.c index 45d0c543466f..6cdbe4bf5aaa 100644 --- a/drivers/watchdog/stpmic1_wdt.c +++ b/drivers/watchdog/stpmic1_wdt.c @@ -138,3 +138,4 @@ module_platform_driver(stpmic1_wdt_driver); MODULE_DESCRIPTION("Watchdog driver for STPMIC1 device"); MODULE_AUTHOR("Pascal Paillet "); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/sunxi_wdt.c b/drivers/watchdog/sunxi_wdt.c index 5f05a45ac187..dea10c79b817 100644 --- a/drivers/watchdog/sunxi_wdt.c +++ b/drivers/watchdog/sunxi_wdt.c @@ -289,6 +289,7 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started " "(default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); MODULE_AUTHOR("Carlo Caione "); MODULE_AUTHOR("Henrik Nordstrom "); MODULE_DESCRIPTION("sunxi WatchDog Timer Driver"); diff --git a/drivers/watchdog/tangox_wdt.c b/drivers/watchdog/tangox_wdt.c index 1afb0e9d808c..bc9025d31977 100644 --- a/drivers/watchdog/tangox_wdt.c +++ b/drivers/watchdog/tangox_wdt.c @@ -207,3 +207,4 @@ module_platform_driver(tangox_wdt_driver); MODULE_AUTHOR("Mans Rullgard "); MODULE_DESCRIPTION("SMP86xx/SMP87xx Watchdog driver"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/tegra_wdt.c b/drivers/watchdog/tegra_wdt.c index dfe06e506cad..06acd8251928 100644 --- a/drivers/watchdog/tegra_wdt.c +++ b/drivers/watchdog/tegra_wdt.c @@ -276,3 +276,4 @@ module_platform_driver(tegra_wdt_driver); MODULE_AUTHOR("NVIDIA Corporation"); MODULE_DESCRIPTION("Tegra Watchdog Driver"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/tqmx86_wdt.c b/drivers/watchdog/tqmx86_wdt.c index 72d0b0adde38..35b8bfffa34d 100644 --- a/drivers/watchdog/tqmx86_wdt.c +++ b/drivers/watchdog/tqmx86_wdt.c @@ -124,3 +124,4 @@ MODULE_AUTHOR("Andrew Lunn "); MODULE_DESCRIPTION("TQMx86 Watchdog"); MODULE_ALIAS("platform:tqmx86-wdt"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/ts4800_wdt.c b/drivers/watchdog/ts4800_wdt.c index c137ad2bd5c3..b07f75f9049b 100644 --- a/drivers/watchdog/ts4800_wdt.c +++ b/drivers/watchdog/ts4800_wdt.c @@ -200,4 +200,5 @@ module_platform_driver(ts4800_wdt_driver); MODULE_AUTHOR("Damien Riegel "); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(WATCHDOG_CORE); MODULE_ALIAS("platform:ts4800_wdt"); diff --git a/drivers/watchdog/ts72xx_wdt.c b/drivers/watchdog/ts72xx_wdt.c index bf918f5fa131..efd74cfabbf8 100644 --- a/drivers/watchdog/ts72xx_wdt.c +++ b/drivers/watchdog/ts72xx_wdt.c @@ -174,4 +174,5 @@ module_platform_driver(ts72xx_wdt_driver); MODULE_AUTHOR("Mika Westerberg "); MODULE_DESCRIPTION("TS-72xx SBC Watchdog"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); MODULE_ALIAS("platform:ts72xx-wdt"); diff --git a/drivers/watchdog/twl4030_wdt.c b/drivers/watchdog/twl4030_wdt.c index 355e428c0b99..98bcebe3a0b7 100644 --- a/drivers/watchdog/twl4030_wdt.c +++ b/drivers/watchdog/twl4030_wdt.c @@ -123,5 +123,6 @@ module_platform_driver(twl4030_wdt_driver); MODULE_AUTHOR("Nokia Corporation"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); MODULE_ALIAS("platform:twl4030_wdt"); diff --git a/drivers/watchdog/uniphier_wdt.c b/drivers/watchdog/uniphier_wdt.c index 8e9242c23022..3a6d2d3a8f3c 100644 --- a/drivers/watchdog/uniphier_wdt.c +++ b/drivers/watchdog/uniphier_wdt.c @@ -255,3 +255,4 @@ MODULE_PARM_DESC(nowayout, MODULE_AUTHOR("Keiji Hayashibara "); MODULE_DESCRIPTION("UniPhier Watchdog Device Driver"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/via_wdt.c b/drivers/watchdog/via_wdt.c index eeb39f96e72e..899a4fe1d7b6 100644 --- a/drivers/watchdog/via_wdt.c +++ b/drivers/watchdog/via_wdt.c @@ -259,3 +259,4 @@ module_pci_driver(wdt_driver); MODULE_AUTHOR("Marc Vertes"); MODULE_DESCRIPTION("Driver for watchdog timer on VIA chipset"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/w83627hf_wdt.c b/drivers/watchdog/w83627hf_wdt.c index 38b31e9947aa..b66aea20a96e 100644 --- a/drivers/watchdog/w83627hf_wdt.c +++ b/drivers/watchdog/w83627hf_wdt.c @@ -528,5 +528,6 @@ module_init(wdt_init); module_exit(wdt_exit); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); MODULE_AUTHOR("Pádraig Brady "); MODULE_DESCRIPTION("w83627hf/thf WDT driver"); diff --git a/drivers/watchdog/watchdog_core.c b/drivers/watchdog/watchdog_core.c index 21e8085b848b..9deb22af5daa 100644 --- a/drivers/watchdog/watchdog_core.c +++ b/drivers/watchdog/watchdog_core.c @@ -145,7 +145,7 @@ int watchdog_init_timeout(struct watchdog_device *wdd, return ret; } -EXPORT_SYMBOL_GPL(watchdog_init_timeout); +EXPORT_SYMBOL_NS_GPL(watchdog_init_timeout, WATCHDOG_CORE); static int watchdog_restart_notifier(struct notifier_block *nb, unsigned long action, void *data) @@ -180,7 +180,7 @@ void watchdog_set_restart_priority(struct watchdog_device *wdd, int priority) { wdd->restart_nb.priority = priority; } -EXPORT_SYMBOL_GPL(watchdog_set_restart_priority); +EXPORT_SYMBOL_NS_GPL(watchdog_set_restart_priority, WATCHDOG_CORE); static int __watchdog_register_device(struct watchdog_device *wdd) { @@ -279,7 +279,7 @@ int watchdog_register_device(struct watchdog_device *wdd) return ret; } -EXPORT_SYMBOL_GPL(watchdog_register_device); +EXPORT_SYMBOL_NS_GPL(watchdog_register_device, WATCHDOG_CORE); static void __watchdog_unregister_device(struct watchdog_device *wdd) { @@ -311,7 +311,7 @@ void watchdog_unregister_device(struct watchdog_device *wdd) mutex_unlock(&wtd_deferred_reg_mutex); } -EXPORT_SYMBOL_GPL(watchdog_unregister_device); +EXPORT_SYMBOL_NS_GPL(watchdog_unregister_device, WATCHDOG_CORE); static void devm_watchdog_unregister_device(struct device *dev, void *res) { @@ -348,7 +348,7 @@ int devm_watchdog_register_device(struct device *dev, return ret; } -EXPORT_SYMBOL_GPL(devm_watchdog_register_device); +EXPORT_SYMBOL_NS_GPL(devm_watchdog_register_device, WATCHDOG_CORE); static int __init watchdog_deferred_registration(void) { diff --git a/drivers/watchdog/wdat_wdt.c b/drivers/watchdog/wdat_wdt.c index e7cf41aa26c3..027339a557ce 100644 --- a/drivers/watchdog/wdat_wdt.c +++ b/drivers/watchdog/wdat_wdt.c @@ -523,4 +523,5 @@ module_platform_driver(wdat_wdt_driver); MODULE_AUTHOR("Mika Westerberg "); MODULE_DESCRIPTION("ACPI Hardware Watchdog (WDAT) driver"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(WATCHDOG_CORE); MODULE_ALIAS("platform:wdat_wdt"); diff --git a/drivers/watchdog/wm831x_wdt.c b/drivers/watchdog/wm831x_wdt.c index 030ce240620d..a17e2ac251a1 100644 --- a/drivers/watchdog/wm831x_wdt.c +++ b/drivers/watchdog/wm831x_wdt.c @@ -282,4 +282,5 @@ module_platform_driver(wm831x_wdt_driver); MODULE_AUTHOR("Mark Brown"); MODULE_DESCRIPTION("WM831x Watchdog"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); MODULE_ALIAS("platform:wm831x-watchdog"); diff --git a/drivers/watchdog/wm8350_wdt.c b/drivers/watchdog/wm8350_wdt.c index 33c62d51f00a..f81e661662e6 100644 --- a/drivers/watchdog/wm8350_wdt.c +++ b/drivers/watchdog/wm8350_wdt.c @@ -175,4 +175,5 @@ module_platform_driver(wm8350_wdt_driver); MODULE_AUTHOR("Mark Brown"); MODULE_DESCRIPTION("WM8350 Watchdog"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); MODULE_ALIAS("platform:wm8350-wdt"); diff --git a/drivers/watchdog/xen_wdt.c b/drivers/watchdog/xen_wdt.c index b343f421dc72..8b21a4b51047 100644 --- a/drivers/watchdog/xen_wdt.c +++ b/drivers/watchdog/xen_wdt.c @@ -206,3 +206,4 @@ module_exit(xen_wdt_cleanup_module); MODULE_AUTHOR("Jan Beulich "); MODULE_DESCRIPTION("Xen WatchDog Timer Driver"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(WATCHDOG_CORE); diff --git a/drivers/watchdog/ziirave_wdt.c b/drivers/watchdog/ziirave_wdt.c index dec660c509b3..2d81c7b546f2 100644 --- a/drivers/watchdog/ziirave_wdt.c +++ b/drivers/watchdog/ziirave_wdt.c @@ -751,3 +751,4 @@ module_i2c_driver(ziirave_wdt_driver); MODULE_AUTHOR("Martyn Welch