forked from mirrors/linux
		
	init/modpost: conditionally check section mismatch to __meminit*
This reverts commit eb8f689046 ("Use separate sections for __dev/
_cpu/__mem code/data").
Check section mismatch to __meminit* only when CONFIG_MEMORY_HOTPLUG=n.
With this change, the linker script and modpost become simpler, and we
can get rid of the __ref annotations from the memory hotplug code.
[sfr@canb.auug.org.au: remove MEM_KEEP from arch/powerpc/kernel/vmlinux.lds.S]
  Link: https://lkml.kernel.org/r/20240710093213.2aefb25f@canb.auug.org.au
Link: https://lkml.kernel.org/r/20240706160511.2331061-2-masahiroy@kernel.org
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Reviewed-by: Wei Yang <richard.weiyang@gmail.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
			
			
This commit is contained in:
		
							parent
							
								
									7a7127aa33
								
							
						
					
					
						commit
						73db3abdca
					
				
					 4 changed files with 15 additions and 38 deletions
				
			
		|  | @ -123,8 +123,6 @@ SECTIONS | ||||||
| 		 */ | 		 */ | ||||||
| 		*(.sfpr);
 | 		*(.sfpr);
 | ||||||
| 		*(.text.asan.* .text.tsan.*) | 		*(.text.asan.* .text.tsan.*) | ||||||
| 		MEM_KEEP(init.text) |  | ||||||
| 		MEM_KEEP(exit.text) |  | ||||||
| 	} :text | 	} :text | ||||||
| 
 | 
 | ||||||
| 	. = ALIGN(PAGE_SIZE);
 | 	. = ALIGN(PAGE_SIZE);
 | ||||||
|  |  | ||||||
|  | @ -141,14 +141,6 @@ | ||||||
|  * often happens at runtime) |  * often happens at runtime) | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #if defined(CONFIG_MEMORY_HOTPLUG) |  | ||||||
| #define MEM_KEEP(sec)    *(.mem##sec) |  | ||||||
| #define MEM_DISCARD(sec) |  | ||||||
| #else |  | ||||||
| #define MEM_KEEP(sec) |  | ||||||
| #define MEM_DISCARD(sec) *(.mem##sec) |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| #ifndef CONFIG_HAVE_DYNAMIC_FTRACE_NO_PATCHABLE | #ifndef CONFIG_HAVE_DYNAMIC_FTRACE_NO_PATCHABLE | ||||||
| #define KEEP_PATCHABLE		KEEP(*(__patchable_function_entries)) | #define KEEP_PATCHABLE		KEEP(*(__patchable_function_entries)) | ||||||
| #define PATCHABLE_DISCARDS | #define PATCHABLE_DISCARDS | ||||||
|  | @ -357,7 +349,6 @@ | ||||||
| 	*(.data..decrypted)						\ | 	*(.data..decrypted)						\ | ||||||
| 	*(.ref.data)							\ | 	*(.ref.data)							\ | ||||||
| 	*(.data..shared_aligned) /* percpu related */			\ | 	*(.data..shared_aligned) /* percpu related */			\ | ||||||
| 	MEM_KEEP(init.data*)						\ |  | ||||||
| 	*(.data.unlikely)						\ | 	*(.data.unlikely)						\ | ||||||
| 	__start_once = .;						\ | 	__start_once = .;						\ | ||||||
| 	*(.data.once)							\ | 	*(.data.once)							\ | ||||||
|  | @ -542,7 +533,6 @@ | ||||||
| 	/* __*init sections */						\ | 	/* __*init sections */						\ | ||||||
| 	__init_rodata : AT(ADDR(__init_rodata) - LOAD_OFFSET) {		\ | 	__init_rodata : AT(ADDR(__init_rodata) - LOAD_OFFSET) {		\ | ||||||
| 		*(.ref.rodata)						\ | 		*(.ref.rodata)						\ | ||||||
| 		MEM_KEEP(init.rodata)					\ |  | ||||||
| 	}								\ | 	}								\ | ||||||
| 									\ | 									\ | ||||||
| 	/* Built-in module parameters. */				\ | 	/* Built-in module parameters. */				\ | ||||||
|  | @ -593,8 +583,7 @@ | ||||||
| 		*(.text.unknown .text.unknown.*)			\ | 		*(.text.unknown .text.unknown.*)			\ | ||||||
| 		NOINSTR_TEXT						\ | 		NOINSTR_TEXT						\ | ||||||
| 		*(.ref.text)						\ | 		*(.ref.text)						\ | ||||||
| 		*(.text.asan.* .text.tsan.*)				\ | 		*(.text.asan.* .text.tsan.*) | ||||||
| 	MEM_KEEP(init.text*)						\ |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| /* sched.text is aling to function alignment to secure we have same
 | /* sched.text is aling to function alignment to secure we have same
 | ||||||
|  | @ -701,7 +690,6 @@ | ||||||
| #define INIT_DATA							\ | #define INIT_DATA							\ | ||||||
| 	KEEP(*(SORT(___kentry+*)))					\ | 	KEEP(*(SORT(___kentry+*)))					\ | ||||||
| 	*(.init.data .init.data.*)					\ | 	*(.init.data .init.data.*)					\ | ||||||
| 	MEM_DISCARD(init.data*)						\ |  | ||||||
| 	KERNEL_CTORS()							\ | 	KERNEL_CTORS()							\ | ||||||
| 	MCOUNT_REC()							\ | 	MCOUNT_REC()							\ | ||||||
| 	*(.init.rodata .init.rodata.*)					\ | 	*(.init.rodata .init.rodata.*)					\ | ||||||
|  | @ -709,7 +697,6 @@ | ||||||
| 	TRACE_SYSCALLS()						\ | 	TRACE_SYSCALLS()						\ | ||||||
| 	KPROBE_BLACKLIST()						\ | 	KPROBE_BLACKLIST()						\ | ||||||
| 	ERROR_INJECT_WHITELIST()					\ | 	ERROR_INJECT_WHITELIST()					\ | ||||||
| 	MEM_DISCARD(init.rodata)					\ |  | ||||||
| 	CLK_OF_TABLES()							\ | 	CLK_OF_TABLES()							\ | ||||||
| 	RESERVEDMEM_OF_TABLES()						\ | 	RESERVEDMEM_OF_TABLES()						\ | ||||||
| 	TIMER_OF_TABLES()						\ | 	TIMER_OF_TABLES()						\ | ||||||
|  | @ -727,8 +714,7 @@ | ||||||
| 
 | 
 | ||||||
| #define INIT_TEXT							\ | #define INIT_TEXT							\ | ||||||
| 	*(.init.text .init.text.*)					\ | 	*(.init.text .init.text.*)					\ | ||||||
| 	*(.text.startup)						\ | 	*(.text.startup) | ||||||
| 	MEM_DISCARD(init.text*) |  | ||||||
| 
 | 
 | ||||||
| #define EXIT_DATA							\ | #define EXIT_DATA							\ | ||||||
| 	*(.exit.data .exit.data.*)					\ | 	*(.exit.data .exit.data.*)					\ | ||||||
|  |  | ||||||
|  | @ -84,11 +84,15 @@ | ||||||
| 
 | 
 | ||||||
| #define __exit          __section(".exit.text") __exitused __cold notrace | #define __exit          __section(".exit.text") __exitused __cold notrace | ||||||
| 
 | 
 | ||||||
| /* Used for MEMORY_HOTPLUG */ | #ifdef CONFIG_MEMORY_HOTPLUG | ||||||
| #define __meminit        __section(".meminit.text") __cold notrace \ | #define __meminit | ||||||
| 						  __latent_entropy | #define __meminitdata | ||||||
| #define __meminitdata    __section(".meminit.data") | #define __meminitconst | ||||||
| #define __meminitconst   __section(".meminit.rodata") | #else | ||||||
|  | #define __meminit	__init | ||||||
|  | #define __meminitdata	__initdata | ||||||
|  | #define __meminitconst	__initconst | ||||||
|  | #endif | ||||||
| 
 | 
 | ||||||
| /* For assembly routines */ | /* For assembly routines */ | ||||||
| #define __HEAD		.section	".head.text","ax" | #define __HEAD		.section	".head.text","ax" | ||||||
|  |  | ||||||
|  | @ -776,17 +776,14 @@ static void check_section(const char *modname, struct elf_info *elf, | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| #define ALL_INIT_DATA_SECTIONS \ | #define ALL_INIT_DATA_SECTIONS \ | ||||||
| 	".init.setup", ".init.rodata", ".meminit.rodata", \ | 	".init.setup", ".init.rodata", ".init.data" | ||||||
| 	".init.data", ".meminit.data" |  | ||||||
| 
 | 
 | ||||||
| #define ALL_PCI_INIT_SECTIONS	\ | #define ALL_PCI_INIT_SECTIONS	\ | ||||||
| 	".pci_fixup_early", ".pci_fixup_header", ".pci_fixup_final", \ | 	".pci_fixup_early", ".pci_fixup_header", ".pci_fixup_final", \ | ||||||
| 	".pci_fixup_enable", ".pci_fixup_resume", \ | 	".pci_fixup_enable", ".pci_fixup_resume", \ | ||||||
| 	".pci_fixup_resume_early", ".pci_fixup_suspend" | 	".pci_fixup_resume_early", ".pci_fixup_suspend" | ||||||
| 
 | 
 | ||||||
| #define ALL_XXXINIT_SECTIONS ".meminit.*" | #define ALL_INIT_SECTIONS ".init.*" | ||||||
| 
 |  | ||||||
| #define ALL_INIT_SECTIONS INIT_SECTIONS, ALL_XXXINIT_SECTIONS |  | ||||||
| #define ALL_EXIT_SECTIONS ".exit.*" | #define ALL_EXIT_SECTIONS ".exit.*" | ||||||
| 
 | 
 | ||||||
| #define DATA_SECTIONS ".data", ".data.rel" | #define DATA_SECTIONS ".data", ".data.rel" | ||||||
|  | @ -797,9 +794,7 @@ static void check_section(const char *modname, struct elf_info *elf, | ||||||
| 		".fixup", ".entry.text", ".exception.text", \ | 		".fixup", ".entry.text", ".exception.text", \ | ||||||
| 		".coldtext", ".softirqentry.text" | 		".coldtext", ".softirqentry.text" | ||||||
| 
 | 
 | ||||||
| #define INIT_SECTIONS      ".init.*" | #define ALL_TEXT_SECTIONS  ".init.text", ".exit.text", \ | ||||||
| 
 |  | ||||||
| #define ALL_TEXT_SECTIONS  ".init.text", ".meminit.text", ".exit.text", \ |  | ||||||
| 		TEXT_SECTIONS, OTHER_TEXT_SECTIONS | 		TEXT_SECTIONS, OTHER_TEXT_SECTIONS | ||||||
| 
 | 
 | ||||||
| enum mismatch { | enum mismatch { | ||||||
|  | @ -839,12 +834,6 @@ static const struct sectioncheck sectioncheck[] = { | ||||||
| 	.bad_tosec = { ALL_INIT_SECTIONS, ALL_EXIT_SECTIONS, NULL }, | 	.bad_tosec = { ALL_INIT_SECTIONS, ALL_EXIT_SECTIONS, NULL }, | ||||||
| 	.mismatch = TEXTDATA_TO_ANY_INIT_EXIT, | 	.mismatch = TEXTDATA_TO_ANY_INIT_EXIT, | ||||||
| }, | }, | ||||||
| /* Do not reference init code/data from meminit code/data */ |  | ||||||
| { |  | ||||||
| 	.fromsec = { ALL_XXXINIT_SECTIONS, NULL }, |  | ||||||
| 	.bad_tosec = { INIT_SECTIONS, NULL }, |  | ||||||
| 	.mismatch = XXXINIT_TO_SOME_INIT, |  | ||||||
| }, |  | ||||||
| /* Do not use exit code/data from init code */ | /* Do not use exit code/data from init code */ | ||||||
| { | { | ||||||
| 	.fromsec = { ALL_INIT_SECTIONS, NULL }, | 	.fromsec = { ALL_INIT_SECTIONS, NULL }, | ||||||
|  | @ -859,7 +848,7 @@ static const struct sectioncheck sectioncheck[] = { | ||||||
| }, | }, | ||||||
| { | { | ||||||
| 	.fromsec = { ALL_PCI_INIT_SECTIONS, NULL }, | 	.fromsec = { ALL_PCI_INIT_SECTIONS, NULL }, | ||||||
| 	.bad_tosec = { INIT_SECTIONS, NULL }, | 	.bad_tosec = { ALL_INIT_SECTIONS, NULL }, | ||||||
| 	.mismatch = ANY_INIT_TO_ANY_EXIT, | 	.mismatch = ANY_INIT_TO_ANY_EXIT, | ||||||
| }, | }, | ||||||
| { | { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Masahiro Yamada
						Masahiro Yamada