Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4317216rdb; Thu, 14 Sep 2023 20:28:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFjr+NqUrhTxOSkdfAUfh0lq5CltQfIQjW4dj15UVxp7EfubZ05+mBdz27+0OyrnRngJl/G X-Received: by 2002:a05:6870:d68f:b0:1bb:c50d:7451 with SMTP id z15-20020a056870d68f00b001bbc50d7451mr514464oap.46.1694748524541; Thu, 14 Sep 2023 20:28:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694748524; cv=none; d=google.com; s=arc-20160816; b=cuR5raZuKnuseCBi0JfYthUtEPNF1AGqYMAgmQAYgI1OUh/c1w3wYl8m4rHDNLgGAU JRDlqZDY8sG45IILCY4pAKrT6Oq/QxLCjCNivKDzzHGesMQe/4/WGKkyh+0x3NaUxr7W nj9iu6lcY77NOOGrk/EDdmdG8kvWOgKghZIq7KnX3zl54iLNfdMDwIju5WfdlItfLlEi ZfSvAql9I3Zc42NINp7ZdpgKqFR2XzgKlndbmK+F9wW4kmxONk51UKsKCILNQr1wDVtx FPKnVIyClpL/6tO8cNrDvn4GYZJMCgnY1OxWFUmhcRzM/n4u7hK+4ZsOTuD/idbx9LjM BiJA== 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=/jiPwozN2ZU0NDpPqC6qu0kCYDOsSI3NX7WkCDvGgVg=; fh=OvmHJZXs0vd6m+JnA0aM+MGkIbG0S1aIFn/QN1n/Pw4=; b=Ise6IxSqfQXd2rRO9I73uQulrNT0ByfS284ZOWzXc0ifVuR4EOERSk4YwuOGr4jiR0 lsTTrudqj3u7ihGjTmLzlk2mmYKRYddqC3SAQ0+rTRecZJlwg8z7J5WP3IjuSxpfNojo PiL9o2i3z8szwtCuDuxCwKahEeCqEDSctLaHiaR+47/K7NEfHE+vG5cpYJsxmTgyEh32 Runkt4vC3U92FMEkKJ86UN39BEPHRcCR1RALtJ24N+g3M6/cMktzCFffDstqWtBgup/r QNHy2wzhTTDJ9GV98P/viUlgZl1WETK2NrTW0MdadVe06it4hhUjT7U3k7L1BJ5cy/hT Q3CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EhlYIyWu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id a14-20020a63e84e000000b00577461b010fsi2599198pgk.685.2023.09.14.20.28.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 20:28:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EhlYIyWu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id E5FB3832CBF7; Thu, 14 Sep 2023 20:22:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231913AbjIODWk (ORCPT + 99 others); Thu, 14 Sep 2023 23:22:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231452AbjIODWj (ORCPT ); Thu, 14 Sep 2023 23:22:39 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A16DB1FCE for ; Thu, 14 Sep 2023 20:22:35 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3FF59C433CA for ; Fri, 15 Sep 2023 03:22:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694748155; bh=WZo85cFKx2yQFlaOIwHXEnceHiEm8QQ7OFUyZqTOQ34=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=EhlYIyWuYeFpGAs2CHf/mjTCmlO55knSL4DzD82xvs51JFy+SB5sKf+KbcOK3ztR7 1QbVr3v9zKFPFxmUyqmfOs/xS1iUuPtk9UDSL8kz5PWzNxjw/kixmjCTjGnCguH1I+ Iz5USwmU8uSvz6HAGSvWeub0seZD5EB1Lk7N7s1JUHOlWNd83XEr/5j1x+Oc2YvFyR P/gwsxVLE0rEdaYbd06CxDvEb8YNt0ZMZEQyWziqX6Mzk8zfJYl5nYo7FwVOG4oTUY TUkhR2qgQQaDqUvMLE3MOHh/E4POve69/XQcn5pu2SxtJcmEbFbcX42rmbaaIqQIa2 XljzP6MQnlvqA== Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-9a648f9d8e3so223419466b.1 for ; Thu, 14 Sep 2023 20:22:35 -0700 (PDT) X-Gm-Message-State: AOJu0Ywozh9NSbXj7ek4vx3plELboGGr/pFl/RnmtoZ5m9+9Q01shdri 1wcq0Wm9n17Z4q4BLmwoHpakmY9PCtNR3Wyv6WE= X-Received: by 2002:a17:906:4ca:b0:994:54ff:10f6 with SMTP id g10-20020a17090604ca00b0099454ff10f6mr312832eja.30.1694748153698; Thu, 14 Sep 2023 20:22:33 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Huacai Chen Date: Fri, 15 Sep 2023 11:22:20 +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 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 (morse.vger.email [0.0.0.0]); Thu, 14 Sep 2023 20:22:42 -0700 (PDT) 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 morse.vger.email Hi Helge, On Wed, Sep 13, 2023 at 3:18=E2=80=AFAM Helge Deller 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. Huacai > - 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/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 > . =3D ALIGN(PECOFF_SEGMENT_ALIGN); > _etext =3D .; > > - /* > - * struct alt_inst entries. From the header (alternative.h): > - * "Alternative instructions for different CPU types or capabilit= ies" > - * 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 capabilit= ies" > + * 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) > }