Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4690351rdb; Fri, 15 Sep 2023 09:20:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHQVnzxKjOZKAPd04RTe3jqthCF83tH+c3Mvr5ODfK4/t8yMOPWg2/+JtO/s4M88Cv4ByxB X-Received: by 2002:a05:6358:905:b0:13e:d853:cc22 with SMTP id r5-20020a056358090500b0013ed853cc22mr2828582rwi.4.1694794849973; Fri, 15 Sep 2023 09:20:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694794849; cv=none; d=google.com; s=arc-20160816; b=gij11XmWzO9p4U6JgTdu3iBp9+XY4qPNkKB9wEKPVN4LYKSjPdDasvoNKjnzCpu9kU aOigHOfLBJHuVGLPZegNQC3YAKImJVDEZJGIKn6x0aEX47u4lRHbJh54JJe9KcNNyaWX wkx2pECeB7hNAVBB0si/3J57QcW2hdWbTz69JVNGc3jVqVcBt933Qy4Ju9Fjgc28jsjy rLDpKB2TLFJa6Cm0Tb8E6STgCtK+nyX8mtVB9fk7t+gBMuVZ9bh+hITYosrnrBGJPp/M h5s5EVLh/jtwwQ0NbbcjZz68hlhBsSkKPeRbJQcX/Do7dmdpr2EzUex4SfqrI3YD/5sY kNCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=CbCJk+kPeWAvTKwCL09pit7Y62OjsIglLbjdL510O5k=; fh=Lq+0v0ZfkWe502KeB5UIyes70k+jnZNDBUkyGZFgsDk=; b=eNIGdua4soGkMAHqZ+kS+YNGIfjIn9vr5kDiQxrXBEb8j0lgyTOrC1XZC9iwQfbZdm TcHcXGtipnWa6tEKA0wYqYxOxLBYxmnCs2BzIj/bqC0/PYA9wnRa8yDkrKtOMcnRZndV q1aKLQzm6clC8S8nGAh/k3fyBd4GQSt9D9E0peuHSeMhEM562qnAMjCyiPmPyLpkPk9t LyXNUurMfavaULiV9GE95FqXx90O6XRQ3FQsdfoZrB5mryn7D4iz+aLsu11TWfL2u/20 wP8X5bz9EfcKtF4SC/p1DPL6cGc3TDRc/1UD8P3tPJ7Q2upnizsyYlLutGqU39xNIaFb 5r5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=M3PoYplX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id p186-20020a6342c3000000b005641ddd0309si3500562pga.599.2023.09.15.09.20.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 09:20:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=M3PoYplX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id AC38E8398045; Fri, 15 Sep 2023 07:19:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235487AbjIOOT2 (ORCPT + 99 others); Fri, 15 Sep 2023 10:19:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235323AbjIOOT0 (ORCPT ); Fri, 15 Sep 2023 10:19:26 -0400 Received: from mailbox.box.xen0n.name (mail.xen0n.name [115.28.160.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD4C6F3 for ; Fri, 15 Sep 2023 07:19:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xen0n.name; s=mail; t=1694787557; bh=176LZTE9f+ZeUVaUfrPwdkcY1mDZJcgB9YwcRXOgUNM=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=M3PoYplXoLAUov40mxtbCoQp8PGM+SnXBpOpmDdNA1WhCxr9e4zdGzPdncYzd+2de eDcaHXvk2D7czctgwSAXLhmGCy5EXzIPpHikXD6ZP55jyxhJCj7DyzWOPjL20VsIr2 1p8+n2irKhIcgH7fkmkw7bDXzxriGwR04w2nqNXQ= Received: from [192.168.9.172] (unknown [101.88.25.36]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mailbox.box.xen0n.name (Postfix) with ESMTPSA id 67FF16010F; Fri, 15 Sep 2023 22:19:17 +0800 (CST) Message-ID: <2bbc2df8-5fcf-b216-7aa0-192e27bac6e7@xen0n.name> Date: Fri, 15 Sep 2023 22:19:15 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Subject: Re: [PATCH] LoongArch: Fix lockdep static memory detection Content-Language: en-US To: Guenter Roeck , Helge Deller , Huacai Chen Cc: loongarch@lists.linux.dev, Linus Torvalds , Geert Uytterhoeven , linux-kernel@vger.kernel.org References: <1160d063-8396-b126-15ca-a46807ec4258@gmx.de> <644b77db-7214-88c3-7ba6-9c805a134e63@roeck-us.net> From: WANG Xuerui In-Reply-To: <644b77db-7214-88c3-7ba6-9c805a134e63@roeck-us.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,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 fry.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 (fry.vger.email [0.0.0.0]); Fri, 15 Sep 2023 07:19:31 -0700 (PDT) Hi, On 9/15/23 22:07, Guenter Roeck wrote: > Hi Helge, > > On 9/15/23 03:10, Helge Deller wrote: >> On 9/15/23 11:23, Huacai Chen wrote: >>> On Fri, Sep 15, 2023 at 4:16 PM Helge Deller wrote: >>>> >>>> On 9/15/23 05:22, Huacai Chen wrote: >>>>> Hi Helge, >>>>> >>>>> On Wed, Sep 13, 2023 at 3:18 AM 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. >>>> >>>> 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. >> >>> OK, then what about .got/.plt? It seems arm64 also doesn't put them in >>> the data section. >> >> arm64 seems to throw away all plt entries already at link time (and >> just keeps >> the got.plt in the read-only data section). >> It even checks at link time, that there are no plt entries in the >> binary: >>          ASSERT(SIZEOF(.plt) == 0, "Unexpected run-time procedure >> linkages detected!") >> >> I don't know for loongarch, but if you need the plt entries for >> loongarch, it's >> safest & best to put them into the read-only data section too, which >> is what my patch does. >> Up to now, you have them completely outside of code & data sections. >> >> In the end you need to decide for your platform. My patch is a >> suggestion, which I think >> is correct (untested by me, but Guenter replied he tested it). >> But to fix the lockdep problem at minimum the move of the .data.rel >> section >> is needed. >> > > Just my $0.02 .. it might make sense to concentrate on the minimum to > get the immediate > problem fixed. Loongarch maintainers can then decide at their own pace > if they want > to apply any of the other changes you suggested. After all, unless I > am missing > something, those additional changes are not really needed in stable > releases. Sorry for coming late, but as reviewer of arch/loongarch, I'd agree with Guenter and Helge here: let's fix the immediate problem and investigate the rest later -- it's not like the problems are *definitely* orthogonal in this case, and at least *some* progress would be appreciated. I'll try to reproduce the problem and test the fix during the weekend, so hopefully Huacai can get the fix in before -rc2 or -rc3. Thanks for the attention and fix. -- WANG "xen0n" Xuerui Linux/LoongArch mailing list: https://lore.kernel.org/loongarch/