Skip to content

Commit 62d0fd5

Browse files
committed
arch: split MODULE_ARCH_VERMAGIC definitions out to <asm/vermagic.h>
As the bug report [1] pointed out, <linux/vermagic.h> must be included after <linux/module.h>. I believe we should not impose any include order restriction. We often sort include directives alphabetically, but it is just coding style convention. Technically, we can include header files in any order by making every header self-contained. Currently, arch-specific MODULE_ARCH_VERMAGIC is defined in <asm/module.h>, which is not included from <linux/vermagic.h>. Hence, the straight-forward fix-up would be as follows: |--- a/include/linux/vermagic.h |+++ b/include/linux/vermagic.h |@@ -1,5 +1,6 @@ | /* SPDX-License-Identifier: GPL-2.0 */ | #include <generated/utsrelease.h> |+#include <linux/module.h> | | /* Simply sanity version stamp for modules. */ | #ifdef CONFIG_SMP This works enough, but for further cleanups, I split MODULE_ARCH_VERMAGIC definitions into <asm/vermagic.h>. With this, <linux/module.h> and <linux/vermagic.h> will be orthogonal, and the location of MODULE_ARCH_VERMAGIC definitions will be consistent. For arc and ia64, MODULE_PROC_FAMILY is only used for defining MODULE_ARCH_VERMAGIC. I squashed it. For hexagon, nds32, and xtensa, I removed <asm/modules.h> entirely because they contained nothing but MODULE_ARCH_VERMAGIC definition. Kbuild will automatically generate <asm/modules.h> at build-time, wrapping <asm-generic/module.h>. [1] https://lore.kernel.org/lkml/[email protected] Reported-by: Borislav Petkov <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]> Acked-by: Jessica Yu <[email protected]>
1 parent 3d4b223 commit 62d0fd5

File tree

24 files changed

+287
-225
lines changed

24 files changed

+287
-225
lines changed

arch/arc/include/asm/module.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
44
*
55
* Amit Bhor, Sameer Dhavale: Codito Technologies 2004
6-
76
*/
87

98
#ifndef _ASM_ARC_MODULE_H
@@ -19,8 +18,4 @@ struct mod_arch_specific {
1918
const char *secstr;
2019
};
2120

22-
#define MODULE_PROC_FAMILY "ARC700"
23-
24-
#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
25-
2621
#endif /* _ASM_ARC_MODULE_H */

arch/arc/include/asm/vermagic.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
3+
#ifndef _ASM_VERMAGIC_H
4+
#define _ASM_VERMAGIC_H
5+
6+
#define MODULE_ARCH_VERMAGIC "ARC700"
7+
8+
#endif /* _ASM_VERMAGIC_H */

arch/arm/include/asm/module.h

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -37,30 +37,6 @@ struct mod_arch_specific {
3737
struct module;
3838
u32 get_module_plt(struct module *mod, unsigned long loc, Elf32_Addr val);
3939

40-
/*
41-
* Add the ARM architecture version to the version magic string
42-
*/
43-
#define MODULE_ARCH_VERMAGIC_ARMVSN "ARMv" __stringify(__LINUX_ARM_ARCH__) " "
44-
45-
/* Add __virt_to_phys patching state as well */
46-
#ifdef CONFIG_ARM_PATCH_PHYS_VIRT
47-
#define MODULE_ARCH_VERMAGIC_P2V "p2v8 "
48-
#else
49-
#define MODULE_ARCH_VERMAGIC_P2V ""
50-
#endif
51-
52-
/* Add instruction set architecture tag to distinguish ARM/Thumb kernels */
53-
#ifdef CONFIG_THUMB2_KERNEL
54-
#define MODULE_ARCH_VERMAGIC_ARMTHUMB "thumb2 "
55-
#else
56-
#define MODULE_ARCH_VERMAGIC_ARMTHUMB ""
57-
#endif
58-
59-
#define MODULE_ARCH_VERMAGIC \
60-
MODULE_ARCH_VERMAGIC_ARMVSN \
61-
MODULE_ARCH_VERMAGIC_ARMTHUMB \
62-
MODULE_ARCH_VERMAGIC_P2V
63-
6440
#ifdef CONFIG_THUMB2_KERNEL
6541
#define HAVE_ARCH_KALLSYMS_SYMBOL_VALUE
6642
static inline unsigned long kallsyms_symbol_value(const Elf_Sym *sym)

arch/arm/include/asm/vermagic.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef _ASM_VERMAGIC_H
3+
#define _ASM_VERMAGIC_H
4+
5+
#include <linux/stringify.h>
6+
7+
/*
8+
* Add the ARM architecture version to the version magic string
9+
*/
10+
#define MODULE_ARCH_VERMAGIC_ARMVSN "ARMv" __stringify(__LINUX_ARM_ARCH__) " "
11+
12+
/* Add __virt_to_phys patching state as well */
13+
#ifdef CONFIG_ARM_PATCH_PHYS_VIRT
14+
#define MODULE_ARCH_VERMAGIC_P2V "p2v8 "
15+
#else
16+
#define MODULE_ARCH_VERMAGIC_P2V ""
17+
#endif
18+
19+
/* Add instruction set architecture tag to distinguish ARM/Thumb kernels */
20+
#ifdef CONFIG_THUMB2_KERNEL
21+
#define MODULE_ARCH_VERMAGIC_ARMTHUMB "thumb2 "
22+
#else
23+
#define MODULE_ARCH_VERMAGIC_ARMTHUMB ""
24+
#endif
25+
26+
#define MODULE_ARCH_VERMAGIC \
27+
MODULE_ARCH_VERMAGIC_ARMVSN \
28+
MODULE_ARCH_VERMAGIC_ARMTHUMB \
29+
MODULE_ARCH_VERMAGIC_P2V
30+
31+
#endif /* _ASM_VERMAGIC_H */

arch/arm64/include/asm/module.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
#include <asm-generic/module.h>
99

10-
#define MODULE_ARCH_VERMAGIC "aarch64"
11-
1210
#ifdef CONFIG_ARM64_MODULE_PLTS
1311
struct mod_plt_sec {
1412
int plt_shndx;

arch/arm64/include/asm/vermagic.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
/*
3+
* Copyright (C) 2012 ARM Ltd.
4+
*/
5+
#ifndef _ASM_VERMAGIC_H
6+
#define _ASM_VERMAGIC_H
7+
8+
#define MODULE_ARCH_VERMAGIC "aarch64"
9+
10+
#endif /* _ASM_VERMAGIC_H */

arch/hexagon/include/asm/module.h renamed to arch/hexagon/include/asm/vermagic.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
* Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
44
*/
55

6-
#ifndef _ASM_MODULE_H
7-
#define _ASM_MODULE_H
6+
#ifndef _ASM_VERMAGIC_H
7+
#define _ASM_VERMAGIC_H
88

9-
#include <asm-generic/module.h>
9+
#include <linux/stringify.h>
1010

1111
#define MODULE_ARCH_VERMAGIC __stringify(PROCESSOR_MODEL_NAME) " "
1212

13-
#endif
13+
#endif /* _ASM_VERMAGIC_H */

arch/ia64/include/asm/module.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ struct mod_arch_specific {
2626
unsigned int next_got_entry; /* index of next available got entry */
2727
};
2828

29-
#define MODULE_PROC_FAMILY "ia64"
30-
#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY \
31-
"gcc-" __stringify(__GNUC__) "." __stringify(__GNUC_MINOR__)
32-
3329
#define ARCH_SHF_SMALL SHF_IA_64_SHORT
3430

3531
#endif /* _ASM_IA64_MODULE_H */

arch/ia64/include/asm/vermagic.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* Copyright (C) 2003 Hewlett-Packard Co
4+
* David Mosberger-Tang <[email protected]>
5+
*/
6+
7+
#ifndef _ASM_VERMAGIC_H
8+
#define _ASM_VERMAGIC_H
9+
10+
#include <linux/stringify.h>
11+
12+
#define MODULE_ARCH_VERMAGIC "ia64" \
13+
"gcc-" __stringify(__GNUC__) "." __stringify(__GNUC_MINOR__)
14+
15+
#endif /* _ASM_VERMAGIC_H */

arch/mips/include/asm/module.h

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -83,65 +83,4 @@ search_module_dbetables(unsigned long addr)
8383
}
8484
#endif
8585

86-
#ifdef CONFIG_CPU_BMIPS
87-
#define MODULE_PROC_FAMILY "BMIPS "
88-
#elif defined CONFIG_CPU_MIPS32_R1
89-
#define MODULE_PROC_FAMILY "MIPS32_R1 "
90-
#elif defined CONFIG_CPU_MIPS32_R2
91-
#define MODULE_PROC_FAMILY "MIPS32_R2 "
92-
#elif defined CONFIG_CPU_MIPS32_R6
93-
#define MODULE_PROC_FAMILY "MIPS32_R6 "
94-
#elif defined CONFIG_CPU_MIPS64_R1
95-
#define MODULE_PROC_FAMILY "MIPS64_R1 "
96-
#elif defined CONFIG_CPU_MIPS64_R2
97-
#define MODULE_PROC_FAMILY "MIPS64_R2 "
98-
#elif defined CONFIG_CPU_MIPS64_R6
99-
#define MODULE_PROC_FAMILY "MIPS64_R6 "
100-
#elif defined CONFIG_CPU_R3000
101-
#define MODULE_PROC_FAMILY "R3000 "
102-
#elif defined CONFIG_CPU_TX39XX
103-
#define MODULE_PROC_FAMILY "TX39XX "
104-
#elif defined CONFIG_CPU_VR41XX
105-
#define MODULE_PROC_FAMILY "VR41XX "
106-
#elif defined CONFIG_CPU_R4X00
107-
#define MODULE_PROC_FAMILY "R4X00 "
108-
#elif defined CONFIG_CPU_TX49XX
109-
#define MODULE_PROC_FAMILY "TX49XX "
110-
#elif defined CONFIG_CPU_R5000
111-
#define MODULE_PROC_FAMILY "R5000 "
112-
#elif defined CONFIG_CPU_R5500
113-
#define MODULE_PROC_FAMILY "R5500 "
114-
#elif defined CONFIG_CPU_NEVADA
115-
#define MODULE_PROC_FAMILY "NEVADA "
116-
#elif defined CONFIG_CPU_R10000
117-
#define MODULE_PROC_FAMILY "R10000 "
118-
#elif defined CONFIG_CPU_RM7000
119-
#define MODULE_PROC_FAMILY "RM7000 "
120-
#elif defined CONFIG_CPU_SB1
121-
#define MODULE_PROC_FAMILY "SB1 "
122-
#elif defined CONFIG_CPU_LOONGSON32
123-
#define MODULE_PROC_FAMILY "LOONGSON32 "
124-
#elif defined CONFIG_CPU_LOONGSON2EF
125-
#define MODULE_PROC_FAMILY "LOONGSON2EF "
126-
#elif defined CONFIG_CPU_LOONGSON64
127-
#define MODULE_PROC_FAMILY "LOONGSON64 "
128-
#elif defined CONFIG_CPU_CAVIUM_OCTEON
129-
#define MODULE_PROC_FAMILY "OCTEON "
130-
#elif defined CONFIG_CPU_XLR
131-
#define MODULE_PROC_FAMILY "XLR "
132-
#elif defined CONFIG_CPU_XLP
133-
#define MODULE_PROC_FAMILY "XLP "
134-
#else
135-
#error MODULE_PROC_FAMILY undefined for your processor configuration
136-
#endif
137-
138-
#ifdef CONFIG_32BIT
139-
#define MODULE_KERNEL_TYPE "32BIT "
140-
#elif defined CONFIG_64BIT
141-
#define MODULE_KERNEL_TYPE "64BIT "
142-
#endif
143-
144-
#define MODULE_ARCH_VERMAGIC \
145-
MODULE_PROC_FAMILY MODULE_KERNEL_TYPE
146-
14786
#endif /* _ASM_MODULE_H */

0 commit comments

Comments
 (0)