Received: by 10.213.65.68 with SMTP id h4csp519640imn; Tue, 13 Mar 2018 11:37:44 -0700 (PDT) X-Google-Smtp-Source: AG47ELu4MdblHhj/imEDz0mQzPs+tdUZipyCSjQmLABmsjiyruhbcNALz/OBZoZwyL/+yx1GqYmT X-Received: by 10.98.20.22 with SMTP id 22mr1512629pfu.141.1520966264677; Tue, 13 Mar 2018 11:37:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520966264; cv=none; d=google.com; s=arc-20160816; b=JjRBBL4A9hCtSZbyD5C1Bjhp8YLDPdsgZasvF2hW8IkV5aKKkdL8Z8glvWtqMFQHze b2hZPjliqF9Ib3v2+iyvPPBnwtWDiKcgum/Dg5lVFdtlD/n5WZPeFIoT0vTZdUesj1eK uXrj4NYq19wQfhb8piF0A9N1CmxwreUPAlVHhtBvCxPKKYFIB4DFNjdnhOyuCT7d0Jg7 ayYBAfO9ojM47QVLTUCterObmzw84wwIiRnrj8cMiTUjqmNJfyBjqLsxW9iQrKjsxzhE 4Pz3gj8oe7AV5vkfxOi2IPUHLJD/SrUd9qPlCaMSiKOjkomU2cr+g7RAUTjebkhhS7ze oJpg== 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=rMdDjsBsA/go97SEKKiBmGUMoYBN6UpCrUB49dJEyBM=; b=nU4aZFhbsEtP5JvB8Ma/ZT7hVn4kSUHxa9Zw0cEV6kPMaHlKBeYQn/GdEIQ+izeM1N LK9ZtnOCXI8XTviQmnIrNfqgjGgA9LVkhb4KEC4iSCXkAgf8G8Hvs9ny5WN7UNlu1x// 8vVTOV98QxBMC9lILpFQrTmRnQGziO9D9wuhWg8OodZuqo2w2t9knveBFZReufo58vC/ cmG22HGxkDBBluCd/oLOAbsxQ1hr/PxDWCE7eYqAewsOnvviyQX5KVqFhpmgsq8SjX2F qv6+o+TEJrsnBpeNAi1cB35mvPPwd8/744G8Rddh29YC7XlxQ1oLqtI7z5ayT+T2Fs4X YgeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=QbXDcE2B; 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 v12-v6si535099plk.615.2018.03.13.11.37.28; Tue, 13 Mar 2018 11:37:44 -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=QbXDcE2B; 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 S1752854AbeCMSgC (ORCPT + 99 others); Tue, 13 Mar 2018 14:36:02 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:46425 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751996AbeCMSgA (ORCPT ); Tue, 13 Mar 2018 14:36:00 -0400 Received: by mail-pl0-f68.google.com with SMTP id f5-v6so291888plj.13 for ; Tue, 13 Mar 2018 11:36:00 -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=rMdDjsBsA/go97SEKKiBmGUMoYBN6UpCrUB49dJEyBM=; b=QbXDcE2BbZ4+VQuVwzLP6Ou8aaqO3sRl9RBjXsKTLzkV6lT7uQoI3lCS4SVwVlzpiS vEQttkX9nOxFe3OLeQxhgGosqWGDBF6C4BqgBplVeqRaOT9rv/8JpCoVbMhZBjGbKppX iUKT81k0eMphyrNey9UwPyGlmKD8Ew77uxz3dJ83AK9I5mNhhg5MDgWxvm9LWRFRjwGT RbzDg7gY8GTAKK2Q+Klz/uAK7HHEBvGJ1tjHMDqRJ049/guPRjCyzWOXv2gSRFbzbBw2 AD26SDU+H74owm9D+jJ+8Pp9U+KGLp2F/lxi1pBggiemin5Gj634+9rullwwSQViJh2r 22MQ== 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=rMdDjsBsA/go97SEKKiBmGUMoYBN6UpCrUB49dJEyBM=; b=XitkGJ6ZVieVzOMsSbGM5byXNK7Z3kqZtF/qBnMwj5QJIU5+RAVjVrZkhFzf8alaNj RqcevHlZ5733fik45qWKeQhVJT/gdNHaTxJnkP1Jsbtec5qZFFaqGvvwsQmxUcDtKUuj gtTUGUK8DPLGcz81wiyezvbD5QtXstHSm62SkdmzH5sKXXBU2paBJ170r94yXxtlWcnc ICJSq+hxNWenU6vUzWEkcfscJXdnlaSkVB1sDsLCyGZhbhA5fpCHv75UBPwXntZNeENe 6mIybYKYs0SmTREHuyJYdum8c8PKgVy4U4bVKwPerfdNDzGXDXjPTxqGixl0/iDs3Q1K R5Mg== X-Gm-Message-State: AElRT7H4+gszjGHSgTCTJdPpl+51hhc2EjsCuUlE9ylqDDWq3q2OQTAm GZrNDxPT9TtBi9/VUJqKVF1rcwSOVlA= X-Received: by 2002:a17:902:3183:: with SMTP id x3-v6mr1420149plb.383.1520966159545; Tue, 13 Mar 2018 11:35:59 -0700 (PDT) Received: from localhost ([65.153.83.185]) by smtp.gmail.com with ESMTPSA id f23sm1434800pfn.132.2018.03.13.11.35.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Mar 2018 11:35:54 -0700 (PDT) Date: Tue, 13 Mar 2018 11:35:54 -0700 (PDT) X-Google-Original-Date: Tue, 13 Mar 2018 11:35:27 PDT (-0700) Subject: Re: [PATCH 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, shea@shealevy.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 Tue, 13 Mar 2018 01:35:05 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 > > 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 This is the second set of patches that turn on modules, and it has the same R_RISCV_ALIGN problem as the other one http://lists.infradead.org/pipermail/linux-riscv/2018-February/000081.html It looks like this one uses shared libraries for modules instead of static objects. I think using shared objects is the right thing to do, as it'll allow us to place modules anywhere in the address space by having multiple GOTs and PLTs. That's kind of complicated, though, so we can start with something simpler like this.