Received: by 10.213.65.68 with SMTP id h4csp1284367imn; Sat, 24 Mar 2018 08:23:05 -0700 (PDT) X-Google-Smtp-Source: AG47ELs1XkKDZbloOmmo7zCcJ3S01Qv9pZWF91AD8BgBW7eKM0gtgjnGTfrbi8whlcrt/99ibr0B X-Received: by 2002:a17:902:407:: with SMTP id 7-v6mr33504505ple.47.1521904985121; Sat, 24 Mar 2018 08:23:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521904985; cv=none; d=google.com; s=arc-20160816; b=S2Gs3/WMVf8ScrtCqQyuJ7qThFHfPgxDqCpT8PmjHGXvAP3lkXhVTiaLBXjDhthCFg B6laj/GIQxRPaLf/4xfHEJk03ArL3MTuDvXv7j87DObZFr7gZByjiC6VEpOzToUR9k9/ oQnFFpEA05NYdOt5pefMCXTPi6EGB5r/T04EageTnwJ/yDayPzhzZ/x7lXbimVfYkGHe Tt9dkcDmyhOu7gwi6VZwx5I59uVZ6rsrD64kgCTSjW3LrL3u4VA4Xqlx8U1H9Kb0OVd3 16Fs6Jno+vN2FpArXdp5D9gQT+1vq8H7iQ4EQDA02nnvN9if5X8rJkNaEPje9B2W2PXo 4siQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=4e9n+zS7Nf79oQnHRuhO8QXbklmg7BplgzRDoZVKsiU=; b=1IU0MRCaEj7WuAE967NhnssVtiQCIrPNFlEswhzMFsbe6cW9veTGjPMwQ0mRhTFoAn RUJP8OeZHY0b6J+hUixBpcDPD2+kGdf24J1E+1sDbLZj/zi81/hWJaMD2AgROHsP1xI4 0z79g9edF7eCZJykQwmmAkeZEwfnrS+BcXC1wl9b9WHPq16if0e32awJ/cCFHNiaPuB5 96PDlLDPrVlnBJnJyouOQgLaqVijaozsS+qIo8/Vr8m463b6CMjl0H+zzoce6FS+0aaw 7o6rvLydjASO8kDrg/Uz+1M69QEHnc/8gEYDhPuOZOJ76Q1xPtivpAhNbsgwuVM65Clh hS4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=E/ydsDET; 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 n29si5452980pgd.778.2018.03.24.08.22.50; Sat, 24 Mar 2018 08:23:05 -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=E/ydsDET; 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 S1752479AbeCXPVr (ORCPT + 99 others); Sat, 24 Mar 2018 11:21:47 -0400 Received: from mail-io0-f194.google.com ([209.85.223.194]:40382 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752331AbeCXPVq (ORCPT ); Sat, 24 Mar 2018 11:21:46 -0400 Received: by mail-io0-f194.google.com with SMTP id e79so18440249ioi.7 for ; Sat, 24 Mar 2018 08:21:45 -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 :cc; bh=4e9n+zS7Nf79oQnHRuhO8QXbklmg7BplgzRDoZVKsiU=; b=E/ydsDETs8td9/V/2/fEN9dZe0m2BTLQKqXFROfODqlSIusekJ3xXT/QpzsDQ0gIFu xHAvr2gCkW0yMyOz7EwiHBIZ2VCrwqAoMptBJJGE+yY8hL4y1m8/KZShZjeqimO1BQCE Lnae54FBY29HnAzRl3tRUttIA01qBrCT40MaL+tPMhYy8+MLYWz4XEo6e32yWuQQD3/S 3z1nmkjkyU31IU4t2swGh8UlYIZcRthtN/GqR8DBuonI7vgcUjoVKgOblJdWeCddweFV qODnTi3je5YfbQSCj5oKFoI9dIz2pypqSxekP/yjCXgVWSeW/rV4rADKlu2VWHw8f7aH /AnA== 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:cc; bh=4e9n+zS7Nf79oQnHRuhO8QXbklmg7BplgzRDoZVKsiU=; b=jLUJkvXRgglDycg/0g5XomOU68anJlGklTWyjxU+ziR8qbmXUpXkGxRwFi/IIfDC6/ xWcc83Pm8/bfVkrQDU8XwrwQS/ZdRQu1Vj5tI4Y14FclsbiR9s9oY56O12x9i/5F0aI/ WTJsDRow4yLWDgbQU8hevrZ6jvX7pK2Yy91F9iBWeyuROLuh7UOu0eW7kpZJLwn6Q7yl codSat5udjFo1sxzh5/UXEcG0usvFEqpi9fAiOGmq9PcL0k4eap1uX9RqXciWjMfW6G/ nEGcjq3HWaak1mwmewDN3AI3RHYGrZf8m33FbXeJ78OPTbFnBWhtqrA3ysLjuwBfNCKA FzBg== X-Gm-Message-State: AElRT7HfpBerbS2NE5VwgxLpvFRIFIe9hEPJlf0hvyXQtlg/IlJssLto EHBhDdrwhi+xoyumNwKmr/xvq0KIKzHwGb2k5Qw= X-Received: by 10.107.12.202 with SMTP id 71mr200820iom.63.1521904905070; Sat, 24 Mar 2018 08:21:45 -0700 (PDT) MIME-Version: 1.0 Received: by 10.2.69.149 with HTTP; Sat, 24 Mar 2018 08:21:44 -0700 (PDT) In-Reply-To: <87370pvdcm.fsf@xps13.shealevy.com> References: <87370pvdcm.fsf@xps13.shealevy.com> From: Zong Li Date: Sat, 24 Mar 2018 23:21:44 +0800 Message-ID: Subject: Re: [PATCH v2 00/11] RISC-V: Resolve the issue of loadable module on 64-bit To: Shea Levy Cc: Palmer Dabbelt , Zong Li , greentime@andestech.com, Linux Kernel Mailing List , albert@sifive.com, linux-riscv@lists.infradead.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-24 20:59 GMT+08:00 Shea Levy : > Hi Palmer, Zong, > > Palmer Dabbelt writes: > >> 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. >> > > I've updated my kernel to point to riscv-all, and now I'm getting: > > scsi_mod: target ffffffe000029a80 can not be addressed by the 32-bit offset from PC = 00000000fe3be867 > > Any idea why this might be? My patchset had a patch [1] to ensure > modules were loaded within a 32 bit offset of the kernel text, do we > need to include that? > > Thanks, > Shea > > [1] http://lists.infradead.org/pipermail/linux-riscv/2018-February/000083.html > >> _______________________________________________ >> linux-riscv mailing list >> linux-riscv@lists.infradead.org >> http://lists.infradead.org/mailman/listinfo/linux-riscv Hi Shea, I'm not sure what is the relocation type or program behavior on your situation. For the code generation, the following relocation types only allow the target offset in the 32 bit range: - RISCV_PCREL_HI20 - RISCV_HI20 - RISCV_CALL - RISCV_CALL_PLT without enabling MODULES_SECTIONS In my view, we cannot limit the start address of kernel text is always adjacent to the module region.