Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp6020212rdb; Mon, 18 Sep 2023 01:09:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHEGlSNgBwJK5IIpUcVh7+xKroX4Pc33i+J0yvL9E4ZSBYvDCAmvbv4LTnPp0TkqHqUFu6I X-Received: by 2002:a17:902:ab5d:b0:1c3:f023:9823 with SMTP id ij29-20020a170902ab5d00b001c3f0239823mr7213701plb.6.1695024556562; Mon, 18 Sep 2023 01:09:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695024556; cv=none; d=google.com; s=arc-20160816; b=Mrz03lOMlmEGQWrJhtJ+dDBeWWIpY/0MP9jLxT4sK40nuyZsKzbPpqQvJcd79sbt28 LCG4rbfXnxzQGBVdJOXarwZk27xaFbwxUO+K3cc6xh8j5xe4LsOu44QrFjWi9uvjdtg6 5qIcuiz55QtA8HW+9UYw0GynpHunCI9QeHdjZLr3fGnDXzawk2VwbVOISdYXrYeQIcBh qksM1L7ZS1QM9WxQ6JHHKhv1kB8arjuNCPhC+9azD07mbP28Ziq/pw8/T1ZiWx4w/8o+ gbxd3IQU61zZgc9m2iNRE8kRRwidyCRXueoU7XPpiQq4FG5BSykyX+BhD7M6ikzKUz/V N11A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IkPztNd7bnD91GoOX9u3X5sY7LI8HpPP33/j7zBq9yU=; fh=mYytDhFxh0BOqNSa1Iv610hxG4sclAxBmwUIWE9B5gw=; b=UIwi/GAg4qgNQesB3+O3le3xHdZMQTm7iUeckOQbzxe66V6GM8uh7R7mrpuI5bxWk8 46EFQfhoQQ6aOlT0KQx+k2DMdwx5JLETt6NTaPXA4fmKjFKrXTPWeY7ybxQ9cOGYhyIC 83MGU5Sni9sFSTmLW+spyia98C0el50VIWUFW74OyZUVJUJXo6TMGXnnq75YoDf/7CVd 6oMfr1IXM/rVmv0Oty9gBBjtWDqf3hbcnPOCn9aQiXlHS8N9OTGB0yqDhT5FDoNTmpQp HVt5VXI/1RQq3jv5AUk0zuC4YoezmneEKvgwYrVJb9GJxc/MB9fUAaoe0Q8lGdXYjW3X AbHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=n1BsBmpf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id b12-20020a170902650c00b001c3e8a6748asi7368231plk.644.2023.09.18.01.09.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 01:09:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=n1BsBmpf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 2FEE880C6DCC; Mon, 18 Sep 2023 00:52:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240273AbjIRHav (ORCPT + 99 others); Mon, 18 Sep 2023 03:30:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240329AbjIRHak (ORCPT ); Mon, 18 Sep 2023 03:30:40 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA38C19A; Mon, 18 Sep 2023 00:30:24 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55C0EC43397; Mon, 18 Sep 2023 07:30:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695022224; bh=KSPIxmcvM6pw+gN3UxNfSb/hLNccmDr75av1M8zdRQI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n1BsBmpfW3QKK3NJROVE3ZzVUFsmFfDjPKEBn27xuClR0kSquHorXzHaU80koKHjq oZZubDbrJshf2OzAsSW/lYZeiCxCVkNHUyRKf0J25B3oyQqT68RZdj7eYC/N0Cta3F s7s8WnXGl08TzUW7RJcoZTxms2v0q/MjRq68IGaI1IRBqPpLAZ6vaNChPkgshwIF5h 3KnstVmy4jP0LDvFd3KogmLI2XFZUpl0AY5gcnG4Aq2Zy+SxUhV393i/W7f5/3shGG k9UrFYiH9x7//wdEvOIFolwWa2pPRCHkauyGN/FXYwMai04Ht7kCMou6e5Iw71dZtp HuRwsr2VE4kwA== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Andrew Morton , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Catalin Marinas , Christophe Leroy , "David S. Miller" , Dinh Nguyen , Heiko Carstens , Helge Deller , Huacai Chen , Kent Overstreet , Luis Chamberlain , Mark Rutland , Michael Ellerman , Mike Rapoport , Nadav Amit , "Naveen N. Rao" , Palmer Dabbelt , Puranjay Mohan , Rick Edgecombe , Russell King , Song Liu , Steven Rostedt , Thomas Bogendoerfer , Thomas Gleixner , Will Deacon , bpf@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-modules@vger.kernel.org, linux-parisc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, netdev@vger.kernel.org, sparclinux@vger.kernel.org, x86@kernel.org Subject: [PATCH v3 01/13] nios2: define virtual address space for modules Date: Mon, 18 Sep 2023 10:29:43 +0300 Message-Id: <20230918072955.2507221-2-rppt@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230918072955.2507221-1-rppt@kernel.org> References: <20230918072955.2507221-1-rppt@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 18 Sep 2023 00:52:35 -0700 (PDT) From: "Mike Rapoport (IBM)" nios2 uses kmalloc() to implement module_alloc() because CALL26/PCREL26 cannot reach all of vmalloc address space. Define module space as 32MiB below the kernel base and switch nios2 to use vmalloc for module allocations. Suggested-by: Thomas Gleixner Acked-by: Dinh Nguyen Acked-by: Song Liu Signed-off-by: Mike Rapoport (IBM) --- arch/nios2/include/asm/pgtable.h | 5 ++++- arch/nios2/kernel/module.c | 19 ++++--------------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/arch/nios2/include/asm/pgtable.h b/arch/nios2/include/asm/pgtable.h index 5144506dfa69..d2fb42fb6db8 100644 --- a/arch/nios2/include/asm/pgtable.h +++ b/arch/nios2/include/asm/pgtable.h @@ -25,7 +25,10 @@ #include #define VMALLOC_START CONFIG_NIOS2_KERNEL_MMU_REGION_BASE -#define VMALLOC_END (CONFIG_NIOS2_KERNEL_REGION_BASE - 1) +#define VMALLOC_END (CONFIG_NIOS2_KERNEL_REGION_BASE - SZ_32M - 1) + +#define MODULES_VADDR (CONFIG_NIOS2_KERNEL_REGION_BASE - SZ_32M) +#define MODULES_END (CONFIG_NIOS2_KERNEL_REGION_BASE - 1) struct mm_struct; diff --git a/arch/nios2/kernel/module.c b/arch/nios2/kernel/module.c index 76e0a42d6e36..9c97b7513853 100644 --- a/arch/nios2/kernel/module.c +++ b/arch/nios2/kernel/module.c @@ -21,23 +21,12 @@ #include -/* - * Modules should NOT be allocated with kmalloc for (obvious) reasons. - * But we do it for now to avoid relocation issues. CALL26/PCREL26 cannot reach - * from 0x80000000 (vmalloc area) to 0xc00000000 (kernel) (kmalloc returns - * addresses in 0xc0000000) - */ void *module_alloc(unsigned long size) { - if (size == 0) - return NULL; - return kmalloc(size, GFP_KERNEL); -} - -/* Free memory returned from module_alloc */ -void module_memfree(void *module_region) -{ - kfree(module_region); + return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END, + GFP_KERNEL, PAGE_KERNEL_EXEC, + VM_FLUSH_RESET_PERMS, NUMA_NO_NODE, + __builtin_return_address(0)); } int apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab, -- 2.39.2