Files
Maxim Levitsky cff5e1e162 module: Rename EXPORT_SYMBOL_GPL_FOR_MODULES to EXPORT_SYMBOL_FOR_MODULES
JIRA: https://issues.redhat.com/browse/RHEL-151869

commit 6d3c3ca4c77e93660cce5819bf707f75df03e0c8
Author: Vlastimil Babka <vbabka@suse.cz>
Date:   Fri Aug 8 15:28:47 2025 +0200

    module: Rename EXPORT_SYMBOL_GPL_FOR_MODULES to EXPORT_SYMBOL_FOR_MODULES

    Christoph suggested that the explicit _GPL_ can be dropped from the
    module namespace export macro, as it's intended for in-tree modules
    only. It would be possible to restrict it technically, but it was
    pointed out [2] that some cases of using an out-of-tree build of an
    in-tree module with the same name are legitimate. But in that case those
    also have to be GPL anyway so it's unnecessary to spell it out in the
    macro name.

    Link: https://lore.kernel.org/all/aFleJN_fE-RbSoFD@infradead.org/ [1]
    Link: https://lore.kernel.org/all/CAK7LNATRkZHwJGpojCnvdiaoDnP%2BaeUXgdey5sb_8muzdWTMkA@mail.gmail.com/ [2]
    Suggested-by: Christoph Hellwig <hch@infradead.org>
    Reviewed-by: Shivank Garg <shivankg@amd.com>
    Acked-by: David Hildenbrand <david@redhat.com>
    Acked-by: Nicolas Schier <n.schier@avm.de>
    Reviewed-by: Daniel Gomez <da.gomez@samsung.com>
    Reviewed-by: Christian Brauner <brauner@kernel.org>
    Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
    Link: https://lore.kernel.org/20250808-export_modules-v4-1-426945bcc5e1@suse.cz
    Signed-off-by: Christian Brauner <brauner@kernel.org>

Conflicts:
 drivers/tty/serial/8250/8250_rsa.c - missing  'serial: 8250: export RSA functions'
 fs/anon_inodes.c - ooo backport
 drivers/media/platform/cadence/cdns-csi2rx.c - ooo backport
 drivers/vfio/pci/vfio_pci_dmabuf.c - ooo backport

RHEL-ONLY:
 The support for EXPORT_SYMBOL_GPL_FOR_MODULES was only partially backported,
 and it is not usable because the common module code lacks the machinery
 needed to detect symbols exported this way.

 Since this feature is not strictly needed in RHEL, instead of attempting to complete the backport,
 I chose to "short-circuit" it by defining EXPORT_SYMBOL_FOR_MODULES as EXPORT_SYMBOL_GPL.

 This is functionally correct and carries less risk than backporting the original patch series.

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
2026-07-21 13:51:41 -04:00

82 lines
2.2 KiB
C

/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef _LINUX_EXPORT_H
#define _LINUX_EXPORT_H
#include <linux/compiler.h>
#include <linux/linkage.h>
#include <linux/stringify.h>
/*
* This comment block is used by fixdep. Please do not remove.
*
* When CONFIG_MODVERSIONS is changed from n to y, all source files having
* EXPORT_SYMBOL variants must be re-compiled because genksyms is run as a
* side effect of the *.o build rule.
*/
#ifdef CONFIG_64BIT
#define __EXPORT_SYMBOL_REF(sym) \
.balign 8 ASM_NL \
.quad sym
#else
#define __EXPORT_SYMBOL_REF(sym) \
.balign 4 ASM_NL \
.long sym
#endif
/*
* LLVM integrated assembler cam merge adjacent string literals (like
* C and GNU-as) passed to '.ascii', but not to '.asciz' and chokes on:
*
* .asciz "MODULE_" "kvm" ;
*/
#define ___EXPORT_SYMBOL(sym, license, ns...) \
.section ".export_symbol","a" ASM_NL \
__export_symbol_##sym: ASM_NL \
.asciz license ASM_NL \
.ascii ns "\0" ASM_NL \
__EXPORT_SYMBOL_REF(sym) ASM_NL \
.previous
#if defined(__DISABLE_EXPORTS)
/*
* Allow symbol exports to be disabled completely so that C code may
* be reused in other execution contexts such as the UEFI stub or the
* decompressor.
*/
#define __EXPORT_SYMBOL(sym, license, ns)
#elif defined(__GENKSYMS__)
#define __EXPORT_SYMBOL(sym, license, ns) __GENKSYMS_EXPORT_SYMBOL(sym)
#elif defined(__ASSEMBLY__)
#define __EXPORT_SYMBOL(sym, license, ns) \
___EXPORT_SYMBOL(sym, license, ns)
#else
#define __EXPORT_SYMBOL(sym, license, ns) \
extern typeof(sym) sym; \
__ADDRESSABLE(sym) \
asm(__stringify(___EXPORT_SYMBOL(sym, license, ns)))
#endif
#ifdef DEFAULT_SYMBOL_NAMESPACE
#define _EXPORT_SYMBOL(sym, license) __EXPORT_SYMBOL(sym, license, DEFAULT_SYMBOL_NAMESPACE)
#else
#define _EXPORT_SYMBOL(sym, license) __EXPORT_SYMBOL(sym, license, "")
#endif
#define EXPORT_SYMBOL(sym) _EXPORT_SYMBOL(sym, "")
#define EXPORT_SYMBOL_GPL(sym) _EXPORT_SYMBOL(sym, "GPL")
#define EXPORT_SYMBOL_NS(sym, ns) __EXPORT_SYMBOL(sym, "", ns)
#define EXPORT_SYMBOL_NS_GPL(sym, ns) __EXPORT_SYMBOL(sym, "GPL", ns)
#define EXPORT_SYMBOL_FOR_MODULES(sym, mods) EXPORT_SYMBOL_GPL(sym)
#endif /* _LINUX_EXPORT_H */