Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp1728242imn; Sun, 31 Jul 2022 19:59:34 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tTU/UTAM0KQCQkfRJeqZxJgbRqinoGuyrorOjlqkZ+MD6dIhM55B+DcE/EH+nD/yaGwrFV X-Received: by 2002:a05:6402:4014:b0:43b:cd24:fff3 with SMTP id d20-20020a056402401400b0043bcd24fff3mr14367890eda.351.1659322774159; Sun, 31 Jul 2022 19:59:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659322774; cv=none; d=google.com; s=arc-20160816; b=aFJDP1BqqE8MDXvW9Y7KLsKjLhDuGT92dadGPbBwrUQO3DIQlWo5HYG07xasVOAWJ7 G37gz+gjXQl1rUiwSzZygsI3WT/PzuwFfZU4I8pkVzBuByVpqWypO+mSzvwwW576ktTe qK8USzwQulNZcVWNLzjMs77if+1cvA5vnLBUh1MNud8CEe+YbM0XMDYpMRawuqwsFbWf lqx138B4gNt/T0aS9BjeZHWfhuCJT8rBRyGKoaPBFNutINRGspFguLFXBduJzNtpDV3I Lq3zm6Ez2qZ33A1EAf0VegId3tW1o7cnHaYjB9td4fefghj0VyNk3AJ5XqkGCglM8qR9 iYlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Rz2g2lOxtBV4KejRqU9xUEsPsaQrI5pxGewEZz2IRME=; b=LSmfnfZo6BtblZ3Raa9+SvhhuvzmhZhYn/56frA/22AFJIeF0txWv9Ak8UyXSBmQ8U lKE/qArCtPAO93+uypJ1fsSVJSK3OCap2r8br0Pu25610zRmiAjNli1Z5mMdf9us0Al8 YlfYkJy1eh/kkEA2zdxOz2r0yiapoRQ/HWSmoMDHWhv+6yyX99EEITbcoqcKLwGmLlCB htCJ++xOI0e9vHBKINtB2dxDuDwWYx5QCJ81ZDPdkLR+BT1bbQ6vnvtnN0fP3nM6QuEO JXd1kgR126u/emfZ+80Qay6D9E0zXaQ0MFFcrYUdy3IErkZduoLzZM+PSYJKq0Kb0fAV lmXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Pr8KinnJ; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p27-20020a1709060e9b00b0072b36dc02dfsi10349159ejf.262.2022.07.31.19.59.09; Sun, 31 Jul 2022 19:59:34 -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=@kernel.org header.s=k20201202 header.b=Pr8KinnJ; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239112AbiHACe2 (ORCPT + 99 others); Sun, 31 Jul 2022 22:34:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237027AbiHACe0 (ORCPT ); Sun, 31 Jul 2022 22:34:26 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A83D12D18 for ; Sun, 31 Jul 2022 19:34:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id AC631B80DD0 for ; Mon, 1 Aug 2022 02:34:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E8B0C43140 for ; Mon, 1 Aug 2022 02:34:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659321262; bh=EfneEUvjIoNJJWXc+KdfORZ9jl55i2DJcu1ROCr2G2U=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Pr8KinnJoW+ynQVeLOeqw3R8Ujg43YomRM61cx0lBN4NkMuxGgUwnnR7wezo3tnH6 lIsnlwXG+ElGV4D8L9h5OIYQFbvsLfS1OxVvXYTSO35UY008ssvqLHbYs5jAiKiqpu /G/Hca/KdxgXPHbRREWbbx+v0axtO9nWFLarE9cNaRJ8nTxXIoyTEkatFyJQFis5T+ 8xt33I0kGBIeMAxSkyaaXN5rimMnsWgFwNmpcVHbDXJdkT/XJppAgkvHNtqXV8Sxd+ /6e2zfdVFgj+6ijZRL2iWE5ltNklh3s21tAgzJXtlf3tPgtklmtlW5qAKZ5RO+DRSZ uDVOpR7O+h9CA== Received: by mail-vk1-f177.google.com with SMTP id l13so746125vka.12 for ; Sun, 31 Jul 2022 19:34:22 -0700 (PDT) X-Gm-Message-State: AJIora85lLUjKePPU7GwDFiahNLc+1W8kwiOw6vSfV45GXS4NQDHNfTW F3ANNgtHkvvQRjgyjS8sVpC7Lvr24+O03ItJS3A= X-Received: by 2002:a1f:a502:0:b0:376:8deb:2b40 with SMTP id o2-20020a1fa502000000b003768deb2b40mr5194206vke.35.1659321261400; Sun, 31 Jul 2022 19:34:21 -0700 (PDT) MIME-Version: 1.0 References: <32a74a218c76611f897fd1df1ad0059068621133.camel@xry111.site> <0179679b736aea7258981dec2d83107cce74dfc1.camel@xry111.site> <6b5d2188f93ed72b67a4bbb7116113f833fe1ee5.camel@xry111.site> <7cad6e78014168a8906e130e1cf3809077d2bda7.camel@xry111.site> <1d0783b87bda3e454a111862fcc5b5faffcb16b0.camel@xry111.site> <00eede4b1380888a500f74b1e818bb25a550632b.camel@xry111.site> <7512ae16-b171-d072-674f-a6b9a5e764d6@loongson.cn> In-Reply-To: <7512ae16-b171-d072-674f-a6b9a5e764d6@loongson.cn> From: Huacai Chen Date: Mon, 1 Aug 2022 10:34:07 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 0/4] LoongArch: Support new relocation types To: Youling Tang Cc: Xi Ruoyao , loongarch@lists.linux.dev, LKML , WANG Xuerui , Jinyang He , Lulu Cheng Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 Hi, all, On Mon, Aug 1, 2022 at 10:16 AM Youling Tang wrote: > > Hi, Ruoyao > > On 07/30/2022 10:52 AM, Xi Ruoyao wrote: > > On Sat, 2022-07-30 at 10:24 +0800, Xi Ruoyao wrote: > >> On Sat, 2022-07-30 at 01:55 +0800, Xi Ruoyao wrote: > >>> On Fri, 2022-07-29 at 20:19 +0800, Youling Tang wrote: > >>> > >>>> On 07/29/2022 07:45 PM, Xi Ruoyao wrote: > >>>>> Hmm... The problem is the "addresses" of per-cpu symbols are > >>>>> faked: they > >>>>> are actually offsets from $r21. So we can't just load such an > >>>>> offset > >>>>> with PCALA addressing. > >>>>> > >>>>> It looks like we'll need to introduce an attribute for GCC to > >>>>> make > >>>>> an > >>>>> variable "must be addressed via GOT", and add the attribute into > >>>>> PER_CPU_ATTRIBUTES. > >>> > >>>> Yes, we need a GCC attribute to specify the per-cpu variable. > >>> > >>> GCC patch adding "addr_global" attribute for LoongArch: > >>> https://gcc.gnu.org/pipermail/gcc-patches/2022-July/599064.html > >>> > >>> An experiment to use it: > >>> https://github.com/xry111/linux/commit/c1d5d70 > >> > >> Correction: https://github.com/xry111/linux/commit/c1d5d708 > >> > >> It seems 7-bit SHA is not enough for kernel repo. > > > > If addr_global is rejected or not implemented (for example, building the > > kernel with GCC 12), *I expect* the following hack to work (I've not > > tested it because I'm AFK now). Using visibility in kernel seems > > strange, but I think it may make some sense because the modules are some > > sort of similar to an ELF shared object being dlopen()'ed, and our way > > to inject per-CPU symbols is analog to ELF interposition. > > > > arch/loongarch/include/asm/percpu.h: > > > > #if !__has_attribute(__addr_global__) && defined(MODULE) > > /* Magically remove "static" for per-CPU variables. */ > > # define ARCH_NEEDS_WEAK_PER_CPU > > /* Force GOT-relocation for per-CPU variables. */ > > # define PER_CPU_ATTRIBUTES __attribute__((__visibility__("default"))) > > #endif > > > > arch/loongarch/Makefile: > > > > # Hack for per-CPU variables, see PER_CPU_ATTRIBUTES in > > # include/asm/percpu.h > > if (call gcc-does-not-support-addr-global) > > KBUILD_CFLAGS_MODULE += -fPIC -fvisibility=hidden > > endif > > > Using the old toolchain (GCC 12) can successfully load the nf_tables.ko > module after applying the above patch. I don't like such a hack..., can we consider using old relocation types when building by old toolchains? Huacai > > Thanks, > Youling >