Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp219828rwe; Wed, 31 Aug 2022 01:18:20 -0700 (PDT) X-Google-Smtp-Source: AA6agR5K6YDEOhQajJXCGtltTjzQnk6/3qIbNUYYi9if6bJWOuv2UTVOtfTntMGpZTB28+U67n3b X-Received: by 2002:a17:907:2bf7:b0:730:996d:5e8d with SMTP id gv55-20020a1709072bf700b00730996d5e8dmr20120674ejc.382.1661933900603; Wed, 31 Aug 2022 01:18:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661933900; cv=none; d=google.com; s=arc-20160816; b=v7YZCmifawAKdGhcUZCddtONB6N8oOBhIQIFg45vFB7ghNfNb6SgoAkZp7i080rOIN dmSSTFXXVJTArJK1WHHquWWwg12SdwGv6XeT8RAqha+04R0vDxqSCq0jJB7uZQiHSetL p7hbp49j/+oV6J8Uolnyk4kZU+OKPaKAHCJFd2pShqWoDg0V87XCyxvU+6dK2A104tWz WLuGl+Pu2A0Aie/67qjiLz6oI55B/5B3M/iphi+QlWPdiyC+TtGQ+kNXKxPGPir3+GdV EmC/Sub5GYKeItJd4g8g4mQe6K97cLCmOm4+ZJKgxQBlfBTrvFi0FNFltoEdhyPzKE/7 phtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=Hzd9JNebw/wRj323+c79PhY8kEaOxBrldyWz5ddJf2w=; b=0T8TsfadtsnIuaCg0ueo3gxSVa5ejsgYO7LX+OZiG4SvS8Pr3mWNXvp0DV0fj1okz9 GERb40qUpWX+AURID1LeHDrJvwOc0Zey/27kbD4Vgtcxhbq0C2FY5P57ysBIrNctoYUe tf+hTUYVPP0zentpyP232oyvjjpA3Cu8R5j6pMmjxUWG+dRcBIvGNxjpRtfyBTrV3n2/ yAzqO7Ie3KXa9zrdR2u5uQGcN6QSIR0TUVI5tSPdvzfNrmYGE9sAKFX26bOayDThcyaF nvQKAmAc8IwhWWjcUHI1JrbEpXV5A76iOM1HvxDjrFv4Q7Or5IaPVc0S1vu/wGbDhsXd eY6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b=S2xBrLTQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=xry111.site Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a8-20020a50e708000000b00446f42b19a3si9000119edn.58.2022.08.31.01.17.54; Wed, 31 Aug 2022 01:18:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b=S2xBrLTQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=xry111.site Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229882AbiHaIJI (ORCPT + 99 others); Wed, 31 Aug 2022 04:09:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230323AbiHaIJF (ORCPT ); Wed, 31 Aug 2022 04:09:05 -0400 Received: from xry111.site (xry111.site [89.208.246.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D78CC4837 for ; Wed, 31 Aug 2022 01:09:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1661933340; bh=dYM2ABHuBdNpbMeDD+pD09EJ4JGxsgtH346VLGYcKyI=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=S2xBrLTQ52BqHdMDrb/+Rj1dLynVRoX5yR9uxfrtB1v84BvZFdzMeRLSIl2VC6Rar U8Z9PHDsL9MM1UxWmrkaSXy/2cnfKDYDfH3UHcpJ+ttIoBP3WXLIObH3WUK6xxOa+H Ep2AfDsZ4MhNl687mOXXLSqvyBEBUPOyTeRlIotY= Received: from [IPv6:240e:358:118a:f800:dc73:854d:832e:4] (unknown [IPv6:240e:358:118a:f800:dc73:854d:832e:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 0702F66809; Wed, 31 Aug 2022 04:08:53 -0400 (EDT) Message-ID: Subject: Re: [PATCH v7 0/5] LoongArch: Support toolchain with new relocation types From: Xi Ruoyao To: Jinyang He , Huacai Chen , WANG Xuerui Cc: loongarch@lists.linux.dev, LKML , Youling Tang Date: Wed, 31 Aug 2022 16:08:39 +0800 In-Reply-To: References: <20220830104806.128365-1-xry111@xry111.site> <5b87173faeef587a2ffaaa6f58d34e0940231067.camel@xry111.site> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.45.2 MIME-Version: 1.0 X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FROM_SUSPICIOUS_NTLD, PDS_OTHER_BAD_TLD,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2022-08-31 at 14:58 +0800, Jinyang He wrote: > That's right. Also I am wondering why new toolchain produce .got* in > kernel. It's unneeded. In the past, gcc create la.global and parsed > to la.pcrel by gas, and kernel works well. Now it seems we lost this > feature in gcc. I checked the x86 asm code just now. And some info > follows, >=20 > LoongArch64, ./net/ipv4/udp_diag.s, *have reloc hint* > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pcalau12i=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 $r4,%got_pc_hi20(udplite_table) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ld.d=C2=A0=C2=A0=C2=A0 $= r4,$r4,%got_pc_lo12(udplite_table) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 b=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 udp_dump >=20 > x86_64, ./net/ipv4/udp_diag.s > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 movq=C2=A0=C2=A0=C2=A0 $= udplite_table, %rdi > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 jmp=C2=A0=C2=A0=C2=A0=C2= =A0 udp_dump >=20 > It seems related to -fno-PIE and -cmodel=3Dkernel on x86_64. > Hope new gcc with this feature now. On x86_64 -mcmodel=3Dkernel means "all code and data are located in [- 2GiB, 0) range. We actually don't strictly require a "high" range as we're mostly a PIC-friendly architecture: note that we use a pcalau12i/addi.d pair for PIC addressing in [PC-2GiB, PC+2GiB, and a lu12i.w/addi.d pair for "non-PIC" addressing in [-2GiB, 2GiB), both are 2-insn sequence. If we can put the main kernel image and the modules in one 2GiB VA range, we can avoid GOT completely. But it's not possible for now because main kernel image is loaded in XKPRANGE but the modules are in XKVRANGE. So the best we can achieve before implementing CONFIG_RELOCATION is using GOT in modules, and avoid GOT in the main kernel image (with a new code model in GCC, which will benefit both the kernel and statically linked executables). --=20 Xi Ruoyao School of Aerospace Science and Technology, Xidian University