Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp955474lqh; Sun, 5 May 2024 09:08:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVaFTDl9DdrC/pCyGBYuq/Y1J0jMh0YvDO0dlJoxba4/sap8YJTPqsnTH5l2f+rJAWnmvjhesNGTH/IbjbcuuQ3wBCLIhGNn4FVEsYTQg== X-Google-Smtp-Source: AGHT+IE6q2UJR2PoeYwzTXqQBWe3C259pZeFxXzGuu9pW10zboyXukzRAiUcv6yGjmNk5m53uvxf X-Received: by 2002:a05:6359:a3a0:b0:186:c06f:437a with SMTP id ky32-20020a056359a3a000b00186c06f437amr8884114rwc.28.1714925293318; Sun, 05 May 2024 09:08:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714925293; cv=pass; d=google.com; s=arc-20160816; b=VcWKHC8TDpxC3sIB5VQq08oeMNkDgPoD5nqlZTvPF/z6lblCDMHENNbq5/LQIP5Q1X GHMN/kTqy8me0Dv4THA4LBDzap5BBH76ezsEW94ksgsU66y5uiBck4bG04mmCGuBxg1c 4HULMdLMNXCEuydUA2WdzJgYVzvQsp9BC6v9jZdZZA9FFdSviUZ2Rz23b/N7oGN+0+Qc SZvp8jdlWwcjWTzKGlOlY/iBn3itzHmP9Zg422AdDuQWoLcsszHfJp2lUz52g5Z4dP+M FfFjahAsWWY68y/jxzYB4q6gTtvM4pygg7ezvedGwvc0lqwMrjEpqAOPe1+IK0rRjpjh WFIQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=2feFkw2/DNFlbT2CLv51WDiwJyrr0iuGHxvu/fZCE9Y=; fh=Hur1Ox4UVY8CJ+UkFvS1tjjuIJbfjIxUd04pOdDk42c=; b=kkSnxRZmablyvsIy3oIBPpCgPqxi0uGzlJXO/1M57Crx1FGXh0eo0nzyrkxfx+CZE9 BC7OvKEgF/AhTcRx6VBFtHkSh3C2O6TRWXTL3xpS5oYp/gE6iCqViP+HuczcJ4tLE394 r40URPVK/va/8uo3e1L4eq+alhafq3ZJn35nDh8HCsH4zNgKsxMdbfB5AX8wobY86tkh LLqG4GkO2zAncr0cEvcOgI+Lnn+kylqt/pOkNDFLeeb48G4xczYd4Hkwv3vgd2+iLbwL 57ErjJvHda4e/QZReJRAAkmmxXne6MDS7+Ke08W5BhkHfw7Q93FMEXemtFPCa+6mTDCE oWCw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=P4CuvetV; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-169039-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169039-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id t1-20020a632d01000000b005fbd1a4d058si6618862pgt.372.2024.05.05.09.08.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 May 2024 09:08:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-169039-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=P4CuvetV; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-169039-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169039-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id E4A52281AD6 for ; Sun, 5 May 2024 16:08:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 419115FB9A; Sun, 5 May 2024 16:07:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="P4CuvetV" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 437B05CDD0; Sun, 5 May 2024 16:07:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714925244; cv=none; b=RF/pc0GW3Sxwe1GKLD6dbdwpcw3vkhisFPfHXR3XsRe0crXTdWl+dNAsvOLN2TSer9Nm334jBCkNfjxFIDX4SCvp6jnyTwYAMVh5KaxLOadd7ELI/cjq9XuN37nGrUHEr7noxkqwBikotnbirtQ8THtMKPs7HhNqg/5sJeDcaSE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714925244; c=relaxed/simple; bh=Q5aCDGAMhe9LWjmBOe0KfqvsLthVcLCeaQ3ItO7ykso=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=k4ssgBeCRZqm1/whMFkhwwy/iOe4jRHW2ulUBcMUVyp6aIovWMlb3kiAodqtSFY4rwY0L7V5O9jTi0I5fgLkre4EjUOO0twjIJXYZ/gStF8yK8QodwBAvmy6akQ7ozMclwgkvf4I5yyLr0KCNQhk/ATurv+swSCun3ztrQfc9uM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=P4CuvetV; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88E70C113CC; Sun, 5 May 2024 16:07:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714925243; bh=Q5aCDGAMhe9LWjmBOe0KfqvsLthVcLCeaQ3ItO7ykso=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P4CuvetVGByVCBaaVxVGGOtA74RDHwFQjjwfPUauzLmoD3wdUW1jd7WI/FNUi9YXr ecSyHliyfMJi2cUpp51ECWceN7DeyR/FktquNEV76UWeLDSX8u5ntplCqdrTZGIyar D+P1a3P3j90UWgY0yEm1lcThQZQ68xgGlJ5P9pQsu+MdqtVgnD2sIkvJCtbHuzGhJY LIv/xEQp3DYvT0pZyyVNtIOhtztKpIuOB81GgZH8ewWLqk/Czr7GNGIJ8tGHZNrj1W kaDVaYV4Oj0AIJ4U/WkvPQlCnuijDIIbENO5+lgHxoBaL30p+JcIdJmJV59oRMq0WW 1ZePgAmim3Bkg== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Alexandre Ghiti , Andrew Morton , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Catalin Marinas , Christophe Leroy , "David S. Miller" , Dinh Nguyen , Donald Dutile , Eric Chanudet , Heiko Carstens , Helge Deller , Huacai Chen , Kent Overstreet , Liviu Dudau , Luis Chamberlain , Mark Rutland , Masami Hiramatsu , Michael Ellerman , Mike Rapoport , Nadav Amit , Palmer Dabbelt , Peter Zijlstra , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Rick Edgecombe , Russell King , Sam Ravnborg , Song Liu , Steven Rostedt , Thomas Bogendoerfer , Thomas Gleixner , Will Deacon , bpf@vger.kernel.org, linux-arch@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 RESEND v8 03/16] nios2: define virtual address space for modules Date: Sun, 5 May 2024 19:06:15 +0300 Message-ID: <20240505160628.2323363-4-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240505160628.2323363-1-rppt@kernel.org> References: <20240505160628.2323363-1-rppt@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 d052dfcbe8d3..eab87c6beacb 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.43.0