Received: by 10.213.65.68 with SMTP id h4csp586322imn; Tue, 20 Mar 2018 10:12:58 -0700 (PDT) X-Google-Smtp-Source: AG47ELtnlKwKqW4D1sRDFG8bjhRziUXVpe0+jSrBam+6SvMO51szoWpx3nzQxAT/MjlaS+dX7CcV X-Received: by 10.99.144.199 with SMTP id a190mr12452380pge.359.1521565978605; Tue, 20 Mar 2018 10:12:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521565978; cv=none; d=google.com; s=arc-20160816; b=w2Ec3vhLcxUYwmWiM3rx0JQbdpI4kPZMVxLAB2mM8IbtclXJj8azoxQOlEjEwiB6Zf FxtEZ3F4F3uKs8ifaNUpZWvv0BH5KqAW/b23fMOmy2ee+Jx8pifdF0Q95ccxT+SpP9ZD 6LO0lf1AmcCbA3OZeJpu8DmM7INgmq5WLt0um5IFUbZVfs263ReI14ExlyIYx7Q9i/k/ gUo5Q7WukzKGSHZFFHAzqPJpHiPtG82RQH74gyGpR5beYTqCVpvo6LQpEgO6sqm3F59d AkqJP17NN98c2bjdyKit3FzGIL1KLv2bdIw/L3+JXeJKJJZA5ixUdgBR6k+NQmDwMkP6 sqfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:to:from:cc:in-reply-to:subject:date:dkim-signature :arc-authentication-results; bh=gPs3j28XI4adk7FQ7za0FEaoGF/gtH15gePfWVIoGWQ=; b=UE0dQeqPSJmj003Eck4co3AgbJgr8UiML/bXAo1GVO2mxLFmdYw8VsAqkS+pYwf4Hq 0gYluDE1Xboee29U2F9HdRpqYx8QrLWpG2YECCXVkTD73Ijm7x3R249rUfSJg6I3mXGA SfYqBu97RH+GFDVWA4D0coDyGuF9ls6YzYjTUO3v2TNFalS5Q8VbtuEbT7SRFoiwg16S Efw0LQiAvOO8LLyt/Gn17x0loK/rhQCi8+Ggp+URABm1MR1kTaEkIfLUmmk5tRvo8iYZ oPYU3kZJHiA3Z6ydHMe638h8qHiMCjAED6N2jGOx+bQ8ru7Bu992UGc/8jLAjdcuaVGp qXuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=EenXq1Hf; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n3si1576147pfi.302.2018.03.20.10.12.43; Tue, 20 Mar 2018 10:12:58 -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=@sifive.com header.s=google header.b=EenXq1Hf; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751670AbeCTRLt (ORCPT + 99 others); Tue, 20 Mar 2018 13:11:49 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:35776 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751320AbeCTRLr (ORCPT ); Tue, 20 Mar 2018 13:11:47 -0400 Received: by mail-pl0-f65.google.com with SMTP id p9-v6so1394219pls.2 for ; Tue, 20 Mar 2018 10:11:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=date:subject:in-reply-to:cc:from:to:message-id:mime-version :content-transfer-encoding; bh=gPs3j28XI4adk7FQ7za0FEaoGF/gtH15gePfWVIoGWQ=; b=EenXq1HfnODkzlIkcu3ea0pvgruo0yGj85e+Ip0P/GTTx/VcuNjhMMan8bb6iMPZEp 1SvaNmIdScyp2PvzQRW4B/wPFQBxuycGLwkHSrRgD8Qv4QK6Ms7SqCv2C0ccjKdm7Rax hxVTG7tg6l1JKddQeO0NA4QClnWC0Oa7+tCtCdUkrkcOn+eKpsIBzMFTalPZJEDeYrjI 82sUgp/IKzH1Q0RYIxAfuN3enuANHcY1PbF4CQM5zwEvgM28arZrLUI4zk+T8X2ntnqN 7nO1LObSvrma9wI9YyX+7CHDosumO7RgDcgS8/s2BBV6LurMVrRkdk0wIikFlOe6w+44 T0kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=gPs3j28XI4adk7FQ7za0FEaoGF/gtH15gePfWVIoGWQ=; b=T1kCU4BsBHbd+6YbowolssV4lutlZet7wuoMSejg+fRdzZqZ62qE1A90ldi1RDB3iS DxwySg7Cacdf3oEeAdE9wMjHOyqWMLqtL6vR3hoRRxrMpmrmv9l2qd0+mzcXD9UC4RZA WSinEDwxzVoQjzQPZ8YlKxv33j/eDvfRX5aY4vCr4RWgpPl8KHgV/4QvaefNP/cdWEaS YTLOwPbYMUC2/Wi6D4ypiDq4MlrIvowGJEOe4p5LWbPED7QYau+wzAFuZsrSbxENlFMS 07iQyvuv0VeOJsaj3jTl6sJTn1gJzBTAE2rFYv5xb9fE4vtwpR0tFWzPidAwcqLfNJrH IV5w== X-Gm-Message-State: AElRT7GCc/GcqkeGYuil728DjznT/RyuXN/HK9GyCzzPFvKR/Y7gCyOa GElzEO4WxifkfwNeOSwKf60GRw== X-Received: by 2002:a17:902:b10c:: with SMTP id q12-v6mr17787821plr.197.1521565907198; Tue, 20 Mar 2018 10:11:47 -0700 (PDT) Received: from localhost ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id x137sm5627874pfd.162.2018.03.20.10.11.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Mar 2018 10:11:46 -0700 (PDT) Date: Tue, 20 Mar 2018 10:11:46 -0700 (PDT) X-Google-Original-Date: Tue, 20 Mar 2018 09:34:31 PDT (-0700) Subject: Re: [PATCH v2 00/11] RISC-V: Resolve the issue of loadable module on 64-bit In-Reply-To: CC: albert@sifive.com, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, zong@andestech.com, zongbox@gmail.com, greentime@andestech.com From: Palmer Dabbelt To: zong@andestech.com Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 15 Mar 2018 01:50:40 PDT (-0700), zong@andestech.com wrote: > 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 > > 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 > > Signed-off-by: Zong Li > --- > Change in v2: > - Add compile option 'mno-relax' for build kernel module > - Just fail on ALIGN type, this is unexpected type with mno-relax. > > 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 | 5 + > arch/riscv/configs/defconfig | 2 + > arch/riscv/include/asm/module.h | 113 +++++++++++++++++++++++ > arch/riscv/include/uapi/asm/elf.h | 7 ++ > arch/riscv/kernel/Makefile | 1 + > arch/riscv/kernel/module-sections.c | 156 +++++++++++++++++++++++++++++++ > arch/riscv/kernel/module.c | 179 ++++++++++++++++++++++++++++++++++-- > arch/riscv/kernel/module.lds | 8 ++ > 9 files changed, 470 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 Thanks! I've added this to our for-next branch, so it should start to get a bit more testing soon. I've had a bit of the flu and am therefor a bit out of it, so I'll try to look closer before the next merge window.