Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4449191rdb; Fri, 15 Sep 2023 02:31:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHfhUDkyU8ysYjUKcqD/DTQe6oJ3a0xnZX1j9n4oThaQ4ytpbn622d0f0EhwqSoBzhU/qia X-Received: by 2002:a05:6870:4185:b0:1bf:fd8a:826e with SMTP id y5-20020a056870418500b001bffd8a826emr1116284oac.55.1694770301620; Fri, 15 Sep 2023 02:31:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694770301; cv=none; d=google.com; s=arc-20160816; b=H4s35rwv5F4nm63N4DB685dR0Goa23S+CCfQ8WJTr9O62B9RTVJeX9vmOSIzUGt6Nt 22Tc2BqYbshZpgOmpkUHjzcovMD2zPf+cb+W5B5RScTZPPT2C8rw3L2L7wgKquYwi3qY DBccAiMX7/38lRd0IKbt4OvbGUPdBmAR8/OYjcGG5RWA1PRu5lesQd0v2ozUrRddT5h6 KmhETIX57G6FBkiH+orGosNjlt1dqI8+JjzJQmutxAVvx0V+Vh/ev3D/QDysj+/ePgmp wK/lLO9fO8YpVxPlPIGoJwnpsRrUJ+3VLBldw5AOKbJC64N+XFSPUzLxcL/MquZnlhdz FzUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=on/TXoLzNUVLdUk+pCch9q5IN8rJEFnl6hbaxUq7Ik8=; fh=OvmHJZXs0vd6m+JnA0aM+MGkIbG0S1aIFn/QN1n/Pw4=; b=JZTJvFpG9Vc5Xfq7F97R3b8Lw8bV7RDfSJgYh9biTqlMXjXg9J5gHuUe4FM4v+LddL gq58ufKG2m6T+ziZ/VLRd/zxGgliFpy8KThQVW0wrn9nXhnDzRPE+PxB+NW3/cVCc1AB 8hLjBI4s7eRyHfb+KC5OFgy45rxDEkbVxl3qOxYZVjn7tYW3HS6gONEGwTEE7byBEU39 9T+ij+FIO7/I8xNoiddc3GmCuPr1itStPTHLSWuKJc106znrFk+HxKUhHFy/KaTM2qR4 bx1X4BgHSLneL0IYu1YbgabfbDoLzLn1spWuPjM9WDIdl8lFfKDIofaN1KpRj52vLtdE 2U/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=j6vKH5sE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id x64-20020a638643000000b005776a454f3csi2822147pgd.379.2023.09.15.02.31.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 02:31:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=j6vKH5sE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 3340E832E341; Fri, 15 Sep 2023 02:26:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233440AbjIOJ0s (ORCPT + 99 others); Fri, 15 Sep 2023 05:26:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233529AbjIOJ0o (ORCPT ); Fri, 15 Sep 2023 05:26:44 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38F9A4237 for ; Fri, 15 Sep 2023 02:23:31 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 803E7C433CD for ; Fri, 15 Sep 2023 09:23:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694769810; bh=LWjbHHD1AKzOXNTWg1RLXHiP86HEf3dv2TI9RydxFBM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=j6vKH5sEITz8dU/Xz6I4urspsE8PFEvVLHpF3344usS+0ulGoIwkeYGIzKC1E/Lhy C7+F/lbrGxs+OeCYM6AVd3kyhOBRfwQhmifbMOE8wBy/sOm6vat88QTxd6LBHmeK9X q7bhFVKmD6yvlQWTuXGMlI3gy/9flRFo9XK4WYFRlRW5ls5M/a1LTVHzuN+OkbiE87 5o4SdCb3qrUVPtDDQzVaezzTyZvVZ6Pfd16zvUxokqGhkGqFsBmkGwzVvZAcBbaEVX i8RQBeDwa9xkX9NylLYzpbVLZcRAUMZZtZFJpkix2CyWSlDhmJyWEVDc3k2RVyT0G1 sxF1UFr5nUK+g== Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2bfb0a2682fso31477421fa.2 for ; Fri, 15 Sep 2023 02:23:30 -0700 (PDT) X-Gm-Message-State: AOJu0YwmfAYeiUcZZ4AeVPjQ1ZRXfoty7DeSKDit6E2O+wq4kYeGpv+X 2sbIJkrLrSShaT5iPbRF8Xek9SUqEtFBZ70ayxE= X-Received: by 2002:a2e:7e12:0:b0:2bc:d6d8:8ab5 with SMTP id z18-20020a2e7e12000000b002bcd6d88ab5mr984500ljc.24.1694769808663; Fri, 15 Sep 2023 02:23:28 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Huacai Chen Date: Fri, 15 Sep 2023 17:23:16 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] LoongArch: Fix lockdep static memory detection To: Helge Deller Cc: WANG Xuerui , loongarch@lists.linux.dev, Guenter Roeck , Linus Torvalds , Geert Uytterhoeven , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 15 Sep 2023 02:26:49 -0700 (PDT) On Fri, Sep 15, 2023 at 4:16=E2=80=AFPM Helge Deller wrote: > > On 9/15/23 05:22, Huacai Chen wrote: > > Hi Helge, > > > > On Wed, Sep 13, 2023 at 3:18=E2=80=AFAM Helge Deller wr= ote: > >> > >> 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 k= ernel > and altinstructions are replaced before modules are loaded. > For altinstructions in modules the linker script scripts/module.lds.S is = used. OK, then what about .got/.plt? It seems arm64 also doesn't put them in the data section. Huacai > > Helge > > > >> - PLT symbols behind the read-only section, and > >> - *(.la_abs) into the data section. > >> > >> Signed-off-by: Helge Deller > >> Reported-by: Guenter Roeck > >> Fixes: 0a6b58c5cd0d ("lockdep: fix static memory detection even more") > >> Cc: stable # v6.4+ > >> > >> diff --git a/arch/loongarch/kernel/vmlinux.lds.S b/arch/loongarch/kern= el/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 > >> . =3D ALIGN(PECOFF_SEGMENT_ALIGN); > >> _etext =3D .; > >> > >> - /* > >> - * struct alt_inst entries. From the header (alternative.h): > >> - * "Alternative instructions for different CPU types or capabi= lities" > >> - * Think locking instructions on spinlocks. > >> - */ > >> - . =3D ALIGN(4); > >> - .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) { > >> - __alt_instructions =3D .; > >> - *(.altinstructions) > >> - __alt_instructions_end =3D .; > >> - } > >> - > >> -#ifdef CONFIG_RELOCATABLE > >> - . =3D ALIGN(8); > >> - .la_abs : AT(ADDR(.la_abs) - LOAD_OFFSET) { > >> - __la_abs_begin =3D .; > >> - *(.la_abs) > >> - __la_abs_end =3D .; > >> - } > >> -#endif > >> - > >> - .got : ALIGN(16) { *(.got) } > >> - .plt : ALIGN(16) { *(.plt) } > >> - .got.plt : ALIGN(16) { *(.got.plt) } > >> - > >> - .data.rel : { *(.data.rel*) } > >> - > >> . =3D ALIGN(PECOFF_SEGMENT_ALIGN); > >> __init_begin =3D .; > >> __inittext_begin =3D .; > >> @@ -94,6 +67,18 @@ SECTIONS > >> > >> __initdata_begin =3D .; > >> > >> + /* > >> + * struct alt_inst entries. From the header (alternative.h): > >> + * "Alternative instructions for different CPU types or capabi= lities" > >> + * Think locking instructions on spinlocks. > >> + */ > >> + . =3D ALIGN(4); > >> + .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) { > >> + __alt_instructions =3D .; > >> + *(.altinstructions) > >> + __alt_instructions_end =3D .; > >> + } > >> + > >> INIT_DATA_SECTION(16) > >> .exit.data : { > >> EXIT_DATA > >> @@ -113,6 +98,11 @@ SECTIONS > >> > >> _sdata =3D .; > >> 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 =3D .; > >> } > >> > >> + .data.rel : { *(.data.rel*) } > >> + > >> +#ifdef CONFIG_RELOCATABLE > >> + . =3D ALIGN(8); > >> + .la_abs : AT(ADDR(.la_abs) - LOAD_OFFSET) { > >> + __la_abs_begin =3D .; > >> + *(.la_abs) > >> + __la_abs_end =3D .; > >> + } > >> +#endif > >> + > >> .sdata : { > >> *(.sdata) > >> } >