Skip to content

Commit 68ffa23

Browse files
hdellerchenhuacai
authored andcommitted
LoongArch: Fix lockdep static memory detection
Since commit 0a6b58c ("lockdep: fix static memory detection even more") the lockdep code uses is_kernel_core_data(), is_kernel_rodata() and init_section_contains() to verify if a lock is located inside a kernel static data section. This change triggers a failure on LoongArch, for which the vmlinux.lds.S script misses to put the locks (as part of in the .data.rel symbols) into the Linux data section. This patch fixes the lockdep problem by moving *(.data.rel*) symbols into the kernel data section (from _sdata to _edata). Additionally, move other wrongly assigned symbols too: - altinstructions into the _initdata section, - PLT symbols behind the read-only section, and - *(.la_abs) into the data section. Cc: stable <stable@kernel.org> # v6.4+ Fixes: 0a6b58c ("lockdep: fix static memory detection even more") Reported-by: Guenter Roeck <linux@roeck-us.net> Tested-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Helge Deller <deller@gmx.de> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
1 parent ce9ecca commit 68ffa23

File tree

1 file changed

+28
-27
lines changed

1 file changed

+28
-27
lines changed

arch/loongarch/kernel/vmlinux.lds.S

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -53,33 +53,6 @@ SECTIONS
5353
. = ALIGN(PECOFF_SEGMENT_ALIGN);
5454
_etext = .;
5555

56-
/*
57-
* struct alt_inst entries. From the header (alternative.h):
58-
* "Alternative instructions for different CPU types or capabilities"
59-
* Think locking instructions on spinlocks.
60-
*/
61-
. = ALIGN(4);
62-
.altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
63-
__alt_instructions = .;
64-
*(.altinstructions)
65-
__alt_instructions_end = .;
66-
}
67-
68-
#ifdef CONFIG_RELOCATABLE
69-
. = ALIGN(8);
70-
.la_abs : AT(ADDR(.la_abs) - LOAD_OFFSET) {
71-
__la_abs_begin = .;
72-
*(.la_abs)
73-
__la_abs_end = .;
74-
}
75-
#endif
76-
77-
.got : ALIGN(16) { *(.got) }
78-
.plt : ALIGN(16) { *(.plt) }
79-
.got.plt : ALIGN(16) { *(.got.plt) }
80-
81-
.data.rel : { *(.data.rel*) }
82-
8356
. = ALIGN(PECOFF_SEGMENT_ALIGN);
8457
__init_begin = .;
8558
__inittext_begin = .;
@@ -94,6 +67,18 @@ SECTIONS
9467

9568
__initdata_begin = .;
9669

70+
/*
71+
* struct alt_inst entries. From the header (alternative.h):
72+
* "Alternative instructions for different CPU types or capabilities"
73+
* Think locking instructions on spinlocks.
74+
*/
75+
. = ALIGN(4);
76+
.altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
77+
__alt_instructions = .;
78+
*(.altinstructions)
79+
__alt_instructions_end = .;
80+
}
81+
9782
INIT_DATA_SECTION(16)
9883
.exit.data : {
9984
EXIT_DATA
@@ -113,6 +98,11 @@ SECTIONS
11398

11499
_sdata = .;
115100
RO_DATA(4096)
101+
102+
.got : ALIGN(16) { *(.got) }
103+
.plt : ALIGN(16) { *(.plt) }
104+
.got.plt : ALIGN(16) { *(.got.plt) }
105+
116106
RW_DATA(1 << CONFIG_L1_CACHE_SHIFT, PAGE_SIZE, THREAD_SIZE)
117107

118108
.rela.dyn : ALIGN(8) {
@@ -121,6 +111,17 @@ SECTIONS
121111
__rela_dyn_end = .;
122112
}
123113

114+
.data.rel : { *(.data.rel*) }
115+
116+
#ifdef CONFIG_RELOCATABLE
117+
. = ALIGN(8);
118+
.la_abs : AT(ADDR(.la_abs) - LOAD_OFFSET) {
119+
__la_abs_begin = .;
120+
*(.la_abs)
121+
__la_abs_end = .;
122+
}
123+
#endif
124+
124125
.sdata : {
125126
*(.sdata)
126127
}

0 commit comments

Comments
 (0)