mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Helge Deller <deller@gmx.de>
To: Huacai Chen <chenhuacai@kernel.org>
Cc: WANG Xuerui <kernel@xen0n.name>,
	loongarch@lists.linux.dev, Guenter Roeck <linux@roeck-us.net>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] LoongArch: Fix lockdep static memory detection
Date: Fri, 15 Sep 2023 10:16:01 +0200	[thread overview]
Message-ID: <b1c729bf-86b9-8a1f-c6af-a69be2b4a44c@gmx.de> (raw)
In-Reply-To: <CAAhV-H56oqmQhA1PKh3E6z0A04qfRPehQ8ATOiirAU2O+z=fgw@mail.gmail.com>

On 9/15/23 05:22, Huacai Chen wrote:
> Hi Helge,
>
> On Wed, Sep 13, 2023 at 3:18 AM Helge Deller <deller@gmx.de> wrote:
>>
>> Since commit 0a6b58c5cd0d ("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,

> I think altinstructions cannot  be put into _initdata because it will
> be used by modules.

No.
arch/loongarch/kernel/vmlinux.lds.S is used for the static parts of the kernel
and altinstructions are replaced before modules are loaded.
For altinstructions in modules the linker script scripts/module.lds.S is used.

Helge


>> - PLT symbols behind the read-only section, and
>> - *(.la_abs) into the data section.
>>
>> Signed-off-by: Helge Deller <deller@gmx.de>
>> Reported-by: Guenter Roeck <linux@roeck-us.net>
>> Fixes: 0a6b58c5cd0d ("lockdep: fix static memory detection even more")
>> Cc: stable <stable@kernel.org> # v6.4+
>>
>> diff --git a/arch/loongarch/kernel/vmlinux.lds.S b/arch/loongarch/kernel/vmlinux.lds.S
>> index b1686afcf876..bb2ec86f37a8 100644
>> --- a/arch/loongarch/kernel/vmlinux.lds.S
>> +++ b/arch/loongarch/kernel/vmlinux.lds.S
>> @@ -53,33 +53,6 @@ SECTIONS
>>          . = ALIGN(PECOFF_SEGMENT_ALIGN);
>>          _etext = .;
>>
>> -       /*
>> -        * struct alt_inst entries. From the header (alternative.h):
>> -        * "Alternative instructions for different CPU types or capabilities"
>> -        * Think locking instructions on spinlocks.
>> -        */
>> -       . = ALIGN(4);
>> -       .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
>> -               __alt_instructions = .;
>> -               *(.altinstructions)
>> -               __alt_instructions_end = .;
>> -       }
>> -
>> -#ifdef CONFIG_RELOCATABLE
>> -       . = ALIGN(8);
>> -       .la_abs : AT(ADDR(.la_abs) - LOAD_OFFSET) {
>> -               __la_abs_begin = .;
>> -               *(.la_abs)
>> -               __la_abs_end = .;
>> -       }
>> -#endif
>> -
>> -       .got : ALIGN(16) { *(.got) }
>> -       .plt : ALIGN(16) { *(.plt) }
>> -       .got.plt : ALIGN(16) { *(.got.plt) }
>> -
>> -       .data.rel : { *(.data.rel*) }
>> -
>>          . = ALIGN(PECOFF_SEGMENT_ALIGN);
>>          __init_begin = .;
>>          __inittext_begin = .;
>> @@ -94,6 +67,18 @@ SECTIONS
>>
>>          __initdata_begin = .;
>>
>> +       /*
>> +        * struct alt_inst entries. From the header (alternative.h):
>> +        * "Alternative instructions for different CPU types or capabilities"
>> +        * Think locking instructions on spinlocks.
>> +        */
>> +       . = ALIGN(4);
>> +       .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
>> +               __alt_instructions = .;
>> +               *(.altinstructions)
>> +               __alt_instructions_end = .;
>> +       }
>> +
>>          INIT_DATA_SECTION(16)
>>          .exit.data : {
>>                  EXIT_DATA
>> @@ -113,6 +98,11 @@ SECTIONS
>>
>>          _sdata = .;
>>          RO_DATA(4096)
>> +
>> +       .got : ALIGN(16) { *(.got) }
>> +       .plt : ALIGN(16) { *(.plt) }
>> +       .got.plt : ALIGN(16) { *(.got.plt) }
>> +
>>          RW_DATA(1 << CONFIG_L1_CACHE_SHIFT, PAGE_SIZE, THREAD_SIZE)
>>
>>          .rela.dyn : ALIGN(8) {
>> @@ -121,6 +111,17 @@ SECTIONS
>>                  __rela_dyn_end = .;
>>          }
>>
>> +       .data.rel : { *(.data.rel*) }
>> +
>> +#ifdef CONFIG_RELOCATABLE
>> +       . = ALIGN(8);
>> +       .la_abs : AT(ADDR(.la_abs) - LOAD_OFFSET) {
>> +               __la_abs_begin = .;
>> +               *(.la_abs)
>> +               __la_abs_end = .;
>> +       }
>> +#endif
>> +
>>          .sdata : {
>>                  *(.sdata)
>>          }


  reply	other threads:[~2023-09-15  8:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-12 19:18 Helge Deller
2023-09-12 20:31 ` Guenter Roeck
2023-09-14 16:40   ` Helge Deller
2023-09-15  3:22 ` Huacai Chen
2023-09-15  8:16   ` Helge Deller [this message]
2023-09-15  9:23     ` Huacai Chen
2023-09-15 10:10       ` Helge Deller
2023-09-15 14:07         ` Guenter Roeck
2023-09-15 14:19           ` WANG Xuerui
2023-09-15 15:17             ` Huacai Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b1c729bf-86b9-8a1f-c6af-a69be2b4a44c@gmx.de \
    --to=deller@gmx.de \
    --cc=chenhuacai@kernel.org \
    --cc=geert@linux-m68k.org \
    --cc=kernel@xen0n.name \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=loongarch@lists.linux.dev \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®