Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp2797051rdb; Tue, 12 Sep 2023 12:19:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHLywrl4zDx/kMcoqbNaEit79ZVyHogE9tN2vaXb5eB3TedUtQHu6gpLUUXn65XPIrmAO3v X-Received: by 2002:a05:6a20:549f:b0:148:97d9:4a71 with SMTP id i31-20020a056a20549f00b0014897d94a71mr372380pzk.39.1694546392623; Tue, 12 Sep 2023 12:19:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694546392; cv=none; d=google.com; s=arc-20160816; b=q2DHVOb2Sx0gK5611MNNZFErZMij85BsbzpABLxBNZj0PsxJd2gpSDkcEEQmk5bb+9 VwwOx5iNFHWZNVs4OvJXTT8EvLP+2ii+9bzJOTtEYPbvjwIm46k9NnuXfGSPDbzkHccz /dGMzZpQEpB03j1em4g2Uw4DL65qlxRDrmztGlU1zGG8xhO2X6RiVtI63HC72rei/qPy 5/1Cmhs0IpcFet8Em/rDirYPTtVCj2hDhyurFm4mu0ONPJZ3ENkcXXhNAJysS5vtcVYg L4nfuj7MQEUP5USB4eUeMKwc9bP8LMwDrHp95HNN1JWMcIpM1lJ6AXQlGznT7wCvlm5n eZ/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:to:from:date; bh=rIQvBZu9KcNTUibAJpvMDUrHoEWYVjguzWOhZfbdZoo=; fh=7RgR9kjqmu2liFG1SSAK7W74bENpkdzpuN7j/jwMF9U=; b=iJ7C8OD/FVbYQrUxfwfvgfxiCeKzCwLe/7k/PSihBLJk6mnHOhU6cNrrQNACLldZl4 8AyPaCQE3sbksxPVzkoLzgVO9t0EDlBeppStas6UmsrpU+jUzCk2262bws3OAlk7ans4 +xDbzJhDJ1bbpE9Lp3DdNcnLq7Sm3MRg/YsdC8Nxko+souoNint41BbR7uR7km234PaY B1dGMl8wLfF77qLjgcTs9Ms7E7KpFjZx+xdvmG2+ORPnCbQ0d9h6v/c9gRsLDNlnihnz o1OYnnHHYYbhLgof4i2Sk/Yg6dHx1AgUBmBoa5vxU4o/9StrzJaHDgVZMkfuuNPubKUL w+FA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id ct5-20020a056a000f8500b0068a68054661si8356538pfb.71.2023.09.12.12.19.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 12:19:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 194C181B0CE9; Tue, 12 Sep 2023 12:18:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231219AbjILTSs (ORCPT + 99 others); Tue, 12 Sep 2023 15:18:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229946AbjILTSr (ORCPT ); Tue, 12 Sep 2023 15:18:47 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45841C1 for ; Tue, 12 Sep 2023 12:18:43 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F4046C433C7; Tue, 12 Sep 2023 19:18:40 +0000 (UTC) Date: Tue, 12 Sep 2023 21:18:37 +0200 From: Helge Deller To: Huacai Chen , WANG Xuerui , loongarch@lists.linux.dev, Guenter Roeck , Linus Torvalds , Geert Uytterhoeven , linux-kernel@vger.kernel.org Subject: [PATCH] LoongArch: Fix lockdep static memory detection Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 (agentk.vger.email [0.0.0.0]); Tue, 12 Sep 2023 12:18:49 -0700 (PDT) X-Spam-Status: No, score=-0.5 required=5.0 tests=FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,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 agentk.vger.email 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, - 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 . = 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) }