Received: by 10.192.165.148 with SMTP id m20csp3923856imm; Mon, 23 Apr 2018 15:09:33 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/zoi1Xv9F8cCa5sqv6BCYofkVEX5b/ksaDjvLAPc9SqJKf12atjBZ1aREe74gqRUkH6MXQ X-Received: by 10.99.174.73 with SMTP id e9mr17908694pgp.38.1524521373358; Mon, 23 Apr 2018 15:09:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524521373; cv=none; d=google.com; s=arc-20160816; b=JWGvjG83IFoYaVA3fl7aG2x06pbUqQLClQ438yf65CEk3b3rTj6yjb4LpPERZDGUQh SklpSTxOWITpgx8JXK7VeoiW63L9xYArM0u29FSLJKJ8wPzQZASGzov3FmcVFm8MP9sI K0cyP9jtxtjetERpnu+ny176ltFjyns4ELUa6GQhwjPDFubrPzIpfqvxBP6rxiv7iYs3 qUAhW05WR73jZBD+FYnLli9OUtbviDCXaz1PiA272WcCU4Qmgj0ZiPFNf2LeZCUHs44D oyp4ENEqQCXqz1nRJmrxFMM8cHRZ8dJds654AdNU5oiNCIjurooDkS0XqyybGNFwd0St tP0w== 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=ip9QbMvKHbh04SsqgxtDfH+c8xXo5FcXQMaujWF8N/Y=; b=N4+zfDRXVOtlQOudQjU0AmoGTUpsj6IUvfoWtDi9kXnGmVTh93aGeYYIfYiK20MAVg Joff+n6QMsnmfb2537WhCtn0kE1ocNhXrhZK6WSE0J4Ysmj2sXWuM/PeoIEnPFMZfqaD 5DHvWj1N7994yt3hEKE4a+z6FaLFNlUNFSpbhGjigI/TUIRjMxTgKeTS6jR/sHwtZD44 lt3DuFVUWa41uZS5mdwcjT6SmLD+wHHZIJPW7nRCNsbQWF9nWbvMvoABvD91GBikkWpK 83tLd9H2f+YbaldhbRbKKJyx7Z1pqHC5/Ewvnk1nGWh1r4X7fJZy+DbcGdY72sBxqy9P mNtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=U4B2hkA8; 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 b11-v6si12443909pls.145.2018.04.23.15.09.18; Mon, 23 Apr 2018 15:09:33 -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=U4B2hkA8; 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 S932565AbeDWWIN (ORCPT + 99 others); Mon, 23 Apr 2018 18:08:13 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:44312 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932498AbeDWWIM (ORCPT ); Mon, 23 Apr 2018 18:08:12 -0400 Received: by mail-pg0-f67.google.com with SMTP id l12so9307384pgp.11 for ; Mon, 23 Apr 2018 15:08:12 -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=ip9QbMvKHbh04SsqgxtDfH+c8xXo5FcXQMaujWF8N/Y=; b=U4B2hkA8etdmh+yT+k1ojYinxC+wQBPt6pkX5udgC+6yiRmr5Hwf/6egf+p1XhVGHY IMMPqSQxEnXQLB485biikuEVVH0VfjxUMTQVwPtlCVosrFWwwBEvkHIqnloIX7vV2f2O p6vDxGgp1g/HEzL7+Dl1IEbSZcHrfsgJlRwThRCjdjyb4hiqzVEcEDwyF8+6ZtU6O4D/ Knoso5N74ajMxllBPfQEG9F7aVL3v2/wIvM8peq7qIXiQssFSk9ddwRP1mS0XCDbvpWK wDF5py/oR+DwN0nLszvBIfY9sKA0pIyEQLR2yawjQj2IkZxvupmLw76hPARNszYgoEwU DqYQ== 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=ip9QbMvKHbh04SsqgxtDfH+c8xXo5FcXQMaujWF8N/Y=; b=T74jG++36qnW5Iv+R+sq6dnGj6AP705pQo0WlfUrmuil9RtGZ1Q2lJToA8SUbshkY6 fGwLwpmcNT0iJHr/JpX+0b8xnhP9vwQL0Qm4fTo7qqsJpc6ukZmjEKu9LZ7ep57de5h5 EONf0bon3YNUj4wYS6c6eFl9EdWkTwh6TDSgJn8PVvg6SeU2fZQgHWoTsLMcvgbDJ1ql VjnNkAbQ6NzDBvCZYS2JWrXS//qjXh5DdW6l9mL/6zcUKJmpZsZGovy3um4c/AWcj/a7 H3b8vkoqh9Stb+5ab6rvmPVMoYpC9x49vh/gjBpoj/YMg5IuQyd/lKLBJlq/e057pR6f txBA== X-Gm-Message-State: ALQs6tAJeWyRgLElgEMkBDDyXsQmDE3f1YFpT1j65hcyFuhr2DYF/svu WEc0jHrDdWEaoJURwYTgadFglg== X-Received: by 10.98.106.193 with SMTP id f184mr21712188pfc.201.1524521291648; Mon, 23 Apr 2018 15:08:11 -0700 (PDT) Received: from localhost ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id z8sm20093431pgc.90.2018.04.23.15.08.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Apr 2018 15:08:10 -0700 (PDT) Date: Mon, 23 Apr 2018 15:08:10 -0700 (PDT) X-Google-Original-Date: Mon, 23 Apr 2018 14:47:53 PDT (-0700) Subject: Re: [PATCH] RISC-V: Load modules within relative jump range of the kernel text. In-Reply-To: <87lgdfieqj.fsf@xps13.shealevy.com> CC: linux-riscv@lists.infradead.org, albert@sifive.com, linux-kernel@vger.kernel.org From: Palmer Dabbelt To: 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 Sun, 22 Apr 2018 05:53:56 PDT (-0700), shea@shealevy.com wrote: > Hi Palmer, > > Shea Levy writes: > >> Signed-off-by: Shea Levy >> --- >> >> Note that this patch worked in my old modules patchset and seems to be >> working now, but my kernel boot locks up on top of >> riscv-for-linus-4.17-mw0 and I don't know if it's due to this patch or >> something else that's changed in the mean time. >> >> --- >> arch/riscv/include/asm/pgtable.h | 9 +++++++++ >> arch/riscv/kernel/module.c | 11 +++++++++++ >> 2 files changed, 20 insertions(+) >> >> diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h >> index 16301966d65b..b08ded13364a 100644 >> --- a/arch/riscv/include/asm/pgtable.h >> +++ b/arch/riscv/include/asm/pgtable.h >> @@ -25,6 +25,7 @@ >> #include >> #include >> #include >> +#include >> >> #ifdef CONFIG_64BIT >> #include >> @@ -425,6 +426,14 @@ static inline void pgtable_cache_init(void) >> #define TASK_SIZE VMALLOC_START >> #endif >> >> +/* >> + * The module space lives between the addresses given by TASK_SIZE >> + * and PAGE_OFFSET - it must be within 2G of the kernel text. >> + */ >> +#define MODULES_SIZE (SZ_128M) >> +#define MODULES_VADDR (PAGE_OFFSET - MODULES_SIZE) >> +#define MODULES_END (VMALLOC_END) >> + >> #include >> >> #endif /* !__ASSEMBLY__ */ >> diff --git a/arch/riscv/kernel/module.c b/arch/riscv/kernel/module.c >> index 5dddba301d0a..1b382c7de095 100644 >> --- a/arch/riscv/kernel/module.c >> +++ b/arch/riscv/kernel/module.c >> @@ -16,6 +16,8 @@ >> #include >> #include >> #include >> +#include >> +#include >> >> static int apply_r_riscv_64_rela(struct module *me, u32 *location, Elf_Addr v) >> { >> @@ -382,3 +384,12 @@ int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab, >> >> return 0; >> } >> + >> +void *module_alloc(unsigned long size) >> +{ >> + return __vmalloc_node_range(size, 1, MODULES_VADDR, >> + MODULES_END, GFP_KERNEL, >> + PAGE_KERNEL_EXEC, 0, >> + NUMA_NO_NODE, >> + __builtin_return_address(0)); >> +} >> -- >> 2.16.2 > > Any thoughts on this? The concept looks good, but does this actually keep the modules within 2GiB of the text if PAGE_OFFSET is large?