From patchwork Thu Jun 1 10:12:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 101877 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp205258vqr; Thu, 1 Jun 2023 03:38:58 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7jSoyCw9gdZfAT11gj156kKdYL0+Dm4Z9QmbpuBAG18xXPUUKTzaWdpD+8xzY3iMZ/Cs99 X-Received: by 2002:a05:6a20:c18c:b0:110:2593:9ccd with SMTP id bg12-20020a056a20c18c00b0011025939ccdmr8713482pzb.21.1685615938133; Thu, 01 Jun 2023 03:38:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685615938; cv=none; d=google.com; s=arc-20160816; b=0/KFzpgDTbYfZUH/H5pdr8+Xc2mexCLzFoICvq+KeXEUG6Ysk+hZ5STjbsDevVewiv AdyvKXrEhtFPwCCkd+x4GstgkUoOVHlOhksXVhh3eIUQY44AFCPsH8mXZ/sYuTStRCn9 4oULKiSoLiQK6qgJTM1+6Mt6x2ntuWYz7O34QX23J8AHSAt+45QuJI9QQNUYTLS4vv2L 2m9VBxiEJxucLkFzUDKRe6Em9J33lz1WqO1/m+RfwS0rUD3z14jKp9eFtmWjjGfp6zHe 2O/NiN3s1sZz9n5zYzKVi5LbANFz5WR/AsvuYv0ViR5svU8ob8u/GqlPX59sR/YWGBam oAWA== 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=YNx5kZhIq6qw6vfCdfmtxu0gAyA9UBGm9lCUAv2x+dQ=; b=s8ulGgH0YaNXAifpS7SqDEf1psMGYMQaSvT83aeADrBdZJMBjspnWlPO3d5GmkSTAj hAt0TjGZuy04wuaCgTqv+T88RZ9+Fp0fyLv0i3TD0qifRuFTO1ZDZs5Ux2kc1r7bo7QL Trmn261tagcl3Div5mgV/anvZ7iwVC9XiKf19uqJZ7xI8Z7lHtX5HfvnDKULM9T3fgRJ qWnJ0PSSFQSmQ10iH/ZmImue+gb5Sd9Mop7d/SZD7y35cnnDtI95x1zY64oy4WauQR6z Vs8W8Vu1LwbNpUV6bmuyhbG7HwR+X/BYbqFHXaYpqqAxZXKVKcT/58qmcbTfM74m08qI V1bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=F6EpbVfG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n14-20020a170902e54e00b001a691f376e8si1917116plf.415.2023.06.01.03.38.45; Thu, 01 Jun 2023 03:38:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=F6EpbVfG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233431AbjFAKQj (ORCPT + 99 others); Thu, 1 Jun 2023 06:16:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233390AbjFAKQN (ORCPT ); Thu, 1 Jun 2023 06:16:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7DF1269E; Thu, 1 Jun 2023 03:13:34 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E4CBA63EAA; Thu, 1 Jun 2023 10:13:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE72DC433D2; Thu, 1 Jun 2023 10:13:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685614405; bh=5LdCoQSeBVgn7R6MjCYCn6phsa2E0t2qbJ7tK4qa+uI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F6EpbVfGLuXjbFiyYyZc+fUuN02wx1QczJja/uiqdutB8m95JvNFZw7nIytxmrtuT aTdIs1QEsDFvn0SybJwKeGIZVZcQpvm0uOONMDF3szIrx6y8Hx9xgX8lYS/c2uD5kI YoTU1JxtwCM1CoCtBppK1e4spjISdibEmzTo021jHOZNSRooDproCfJ4QHfFqjAjqs Dbeq3rvYfN6/K690GGLQMIS0wcwWM7BpgPoOpnLHwPYHV+Dof7f6MUU6DTr+AIayT3 JuM5Oy3IMM7Kt1YgUoXGAOq1OFOmnqM9HYtRqlMMBSLmIZTCqQmog0rztgkodFXPpc +OolDOUgDfEeQ== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Andrew Morton , Catalin Marinas , Christophe Leroy , "David S. Miller" , Dinh Nguyen , Heiko Carstens , Helge Deller , Huacai Chen , Kent Overstreet , Luis Chamberlain , Michael Ellerman , Mike Rapoport , "Naveen N. Rao" , Palmer Dabbelt , 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 01/13] nios2: define virtual address space for modules Date: Thu, 1 Jun 2023 13:12:45 +0300 Message-Id: <20230601101257.530867-2-rppt@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230601101257.530867-1-rppt@kernel.org> References: <20230601101257.530867-1-rppt@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767496417997420164?= X-GMAIL-MSGID: =?utf-8?q?1767496417997420164?= 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 Signed-off-by: Mike Rapoport (IBM) Acked-by: Dinh Nguyen --- 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 0f5c2564e9f5..0073b289c6a4 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,