Received: by 10.213.65.68 with SMTP id h4csp261594imn; Tue, 13 Mar 2018 03:37:10 -0700 (PDT) X-Google-Smtp-Source: AG47ELvY2vM5y1VBes79KOfsRQ4YkZtIlxQm4dHCDA+jA8ZgRpUINZkb2dV2SU4Fk7c2Ti+A1IAR X-Received: by 2002:a17:902:8a94:: with SMTP id p20-v6mr122687plo.74.1520937430854; Tue, 13 Mar 2018 03:37:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520937430; cv=none; d=google.com; s=arc-20160816; b=mC4yVL7xX2s2zy9hgS3PD8b/O+htxu2I0aFmMuXsngvwGD4QBvlAfMHm53EWWD08Io aybehW3jw98HrBGEsMmmhAM02zM+rque+eyMJZycU9e4qUcmHmnrMz98RIRbA4vfewGd MdrDzittNVDNKpet8aNfJ21T98m1QROzm3HsdT1mgl58+Mp8BYVQkwuC2dD8vG3Gm47t BgP4bDgBDX5giCslfKqZtt4fYQgl3pXXl0s4d2WIyfMETH/7HqWxYzvKJftOY3NR4YLG gN1+ly6xeybu3W2kjLItYFgcELxKEyJCU4G26/0zv5n3CM8imD3ItblFwJHcddn1WIc+ crwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=DpVewOVrVEF+6Chu5+U1WpIdesdGqCv5eYijA35KB0o=; b=ADCa/TkgQa+yXHHQSNsIdnng9hBnl8rWGWgOupOrouK7mkRngqN6Xs+YZlxloZmdFj Y4FjYezecabsiNyjliL+W3YZYJDwLHfz0ozrl5LXw9VfrQGA+QplG/i8HPQ0szDOD3f5 4vGD3KR93QI+OyjbcgLOl+XC9MS3dYBgTbrrm9fRf6bdBwfhXHOPKdSjlPhy9F949UIE 9wIwvYgRD/0rFDsyzgjdduCPSqD3sohCmc+GChZhR+MyY0s8Xz+O9+kwAC3hujXfv3uR 2Ggg6f3nBTWKRnfqBsrwJqHRH20vCfdmH1JL2Osewc+MZotlJeFY9KTzz0OnpXrChvgl uOlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GspvD0lI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b9si22195pgn.443.2018.03.13.03.36.56; Tue, 13 Mar 2018 03:37:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GspvD0lI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932751AbeCMKgB (ORCPT + 99 others); Tue, 13 Mar 2018 06:36:01 -0400 Received: from mail-it0-f66.google.com ([209.85.214.66]:51099 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932778AbeCMKf4 (ORCPT ); Tue, 13 Mar 2018 06:35:56 -0400 Received: by mail-it0-f66.google.com with SMTP id d13so15158051itf.0 for ; Tue, 13 Mar 2018 03:35:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=DpVewOVrVEF+6Chu5+U1WpIdesdGqCv5eYijA35KB0o=; b=GspvD0lI/tIun+Abv575/dGF89i46EnHcXjWV/55GfYg1NKHGyMdS6k/Y7KWIC7T7u +yVZocCjUmHBjATRSqlE/wzlpzkDJ/Z6OSwwHfF5LXHCwmOREdT60GvVINw6ok+l+As9 +2koJoFAjbDVOuylxU8pRpbnrE89uME9wPj1vfRqR/sqrnX93qm+m3IUdIkoQM8iQifp 2Yf8PlSFrjqBTnpjjOpev6UwTbNi3HVJenh5hU6XbGhoDWE9uDdHvjuB9Csu1yNnYDAE MtnOBW2I7j9gfFmztkQhLjHp1ApbRKYdNiahheMh6TPt/vHiMFnQ/4Uh7mc3OUOKjcIm pGew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=DpVewOVrVEF+6Chu5+U1WpIdesdGqCv5eYijA35KB0o=; b=p+HltHrkQGELevZ0q0zVUsnVz8Cd+mRuhouJ1Qnra/BBruSBScXNMutZjbjpX+zz6V RqyQiKB/JHGJo0zEATkYLvzDlxSHy/6lAVYTOh44Hs8RxphBNpyOT++9eyIzonRZ1MFa GmpRpu0r0CgZ4xZvXsHAzYuEtfOIyAjRjO/Sm/5TCvSoSZFpah4cBkgGu6lcnagacMxK Ul7c8IhV0PZQbC5aOlxsV7aiN1QjNIKlkJNMJMtQb4sDCyT3/wXq5nDgvMyRtFqO97Zc +IVP8U4Nkmf8qALLhLz7n6nyl8+Nw4278/gMdnfidn1yjmIA9J7MJveA3RCZPZuA5P9v 3RrA== X-Gm-Message-State: AElRT7Guo7s+ldGpPYqfLI5dpsFq6pgJkLY2jOuANab8jJyURLPBpse9 3/09+08zx8vtNVUlTlYgsyDvP3XvUntNvdDXa/Hrbbzt X-Received: by 10.36.5.138 with SMTP id 132mr274329itl.47.1520937355843; Tue, 13 Mar 2018 03:35:55 -0700 (PDT) MIME-Version: 1.0 Received: by 10.2.180.55 with HTTP; Tue, 13 Mar 2018 03:35:55 -0700 (PDT) In-Reply-To: References: From: Zong Li Date: Tue, 13 Mar 2018 18:35:55 +0800 Message-ID: Subject: Re: [PATCH 00/11] RISC-V: Resolve the issue of loadable module on 64-bit To: Zong Li , palmer@sifive.com, albert@sifive.com, linux-riscv@lists.infradead.org, Linux Kernel Mailing List , greentime@andestech.com, patches@groups.riscv.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2018-03-13 16:35 GMT+08:00 Zong Li : > > These patches resolve the some issues of loadable module. > - symbol out of ranges > - unknown relocation types > > The reference of external variable and function symbols > cannot exceed 32-bit offset ranges in kernel module. > The module only can work on the 32-bit OS or the 64-bit > OS with sv32 virtual addressing. > > These patches will generate the .got, .got.plt and > .plt sections during loading module, let it can refer > to the symbol which locate more than 32-bit offset. > These sections depend on the relocation types: > - R_RISCV_GOT_HI20 > - R_RISCV_CALL_PLT > > These patches also support more relocation types > - R_RISCV_CALL > - R_RISCV_HI20 > - R_RISCV_LO12_I > - R_RISCV_LO12_S > - R_RISCV_RVC_BRANCH > - R_RISCV_RVC_JUMP > - R_RISCV_ALIGN > - R_RISCV_ADD32 > - R_RISCV_SUB32 > > Zong Li (11): > RISC-V: Add sections of PLT and GOT for kernel module > RISC-V: Add section of GOT.PLT for kernel module > RISC-V: Support GOT_HI20/CALL_PLT relocation type in kernel module > RISC-V: Support CALL relocation type in kernel module > RISC-V: Support HI20/LO12_I/LO12_S relocation type in kernel module > RISC-V: Support RVC_BRANCH/JUMP relocation type in kernel modulewq > RISC-V: Support ALIGN relocation type in kernel module > RISC-V: Support ADD32 relocation type in kernel module > RISC-V: Support SUB32 relocation type in kernel module > RISC-V: Enable module support in defconfig > RISC-V: Add definition of relocation types > > arch/riscv/Kconfig | 5 ++ > arch/riscv/Makefile | 3 + > arch/riscv/configs/defconfig | 2 + > arch/riscv/include/asm/module.h | 112 +++++++++++++++++++++++ > arch/riscv/include/uapi/asm/elf.h | 24 +++++ > arch/riscv/kernel/Makefile | 1 + > arch/riscv/kernel/module-sections.c | 156 ++++++++++++++++++++++++++++++++ > arch/riscv/kernel/module.c | 175 ++++++++++++++++++++++++++++++++++-- > arch/riscv/kernel/module.lds | 8 ++ > 9 files changed, 480 insertions(+), 6 deletions(-) > create mode 100644 arch/riscv/include/asm/module.h > create mode 100644 arch/riscv/kernel/module-sections.c > create mode 100644 arch/riscv/kernel/module.lds > > -- > 2.16.1 > This is the list of testing modules: # lsmod btrfs 7876158 0 - Live 0xffffffd00745d000 ramoops 90806 0 - Live 0xffffffd0024b8000 lzo 10554 0 - Live 0xffffffd002050000 zstd_decompress 567575 1 btrfs, Live 0xffffffd00238b000 zstd_compress 1543837 1 btrfs, Live 0xffffffd002211000 zram 101300 0 - Live 0xffffffd0021b8000 xxhash 62254 2 zstd_decompress,zstd_compress, Live 0xffffffd0020cf000 xor 33246 1 btrfs, Live 0xffffffd002042000 xfs 4395343 0 - Live 0xffffffd00399e000 tun 252041 0 - Live 0xffffffd0038e0000 test_user_copy 5265 0 - Live 0xffffffd003783000 test_static_keys 19606 0 - Live 0xffffffd003717000 test_static_key_base 7374 1 test_static_keys, Live 0xffffffd0036dc000 test_printf 7804 0 [permanent], Live 0xffffffd00369c000 test_module 1557 0 - Live 0xffffffd003646000 test_kmod 49100 0 - Live 0xffffffd0035f2000 test_bpf 1599301 0 - Live 0xffffffd003000000 test_bitmap 4403 0 - Live 0xffffffd002dd8000 reed_solomon 38866 1 ramoops, Live 0xffffffd002d86000 raid6_pq 161872 1 btrfs, Live 0xffffffd002b9e000 netdevsim 65401 0 - Live 0xffffffd002910000 lzo_decompress 9580 2 btrfs,lzo, Live 0xffffffd002813000 lzo_compress 21527 2 btrfs,lzo, Live 0xffffffd0027d9000 libcrc32c 2730 1 xfs, Live 0xffffffd00273c000 fuse 676371 0 - Live 0xffffffd0024d0000 exportfs 24850 1 xfs, Live 0xffffffd0020c7000 echainiv 11953 0 - Live 0xffffffd00205a000