Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp913459lqh; Sun, 5 May 2024 07:27:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXKeBRC/bpu3ZmrkMFmuc7ZYphZZo5TJyIN5zPnd0V6mAjVgzNCoSjH9GQiqSM3iDSWwSV/LMIbstXTrlq4FuedXDaEDcaZ0lQ3JI5GoQ== X-Google-Smtp-Source: AGHT+IEb0Rf+fTHRr/npRNTSNfK15OKZ2JSuKBQTVWVfhwVmePaCa6OZcKA0QMQLbthhfrYKutH3 X-Received: by 2002:a50:8d5a:0:b0:572:67d9:3400 with SMTP id t26-20020a508d5a000000b0057267d93400mr5148587edt.39.1714919269958; Sun, 05 May 2024 07:27:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714919269; cv=pass; d=google.com; s=arc-20160816; b=PZY8SgKQ58EYhe7i/MMiFHHg1tMA4nnnRCRHJ88a0MMk1GIbYdioviFtavEZjBsaFU 0YyF9vvHLjMuMltsBUYenklLaRZ+QUr6PxsEnHrUPT3yzUVfCDJCgVINdoD17ZFmT8Jr azpnt+PDIYy35YjXdEHen7mYsrWwWVEq4/yo8lHUFXKV+ih5dR7P0sbrGZsZ0OxwHE9f pRNs74GT3eLxs6XYylPFo5+bNO6cVThLrqhto8pIzsqexo8kbcStYD1H7DCwpTt01vCa +W9dXi+UV0g2aemfrh53kufYv2M8hmuE75TlmmxBn0j9CL8fxwLRGwnZ+gA3Wcxyqa+g 5tCA== 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=kY4ym72O+v0Zn2JJIAunv5xdt/43+EV4vLh0HZhe8txjRViA7V34EnAPwie1IwLGOE fKAT+OtnPJVpPs0er3FRwnPP66IsMntfAa2Gqru6WzAdIQzi/FJxSqlN+2uz0Z2YrmrX USMzGWDsWQDcycTBd5OZAry2xaxnUFTaRH8GWLk0IqNKaL+DExpO8l9g42YWMdVknlp1 OSw7Rn3id5VvO5rltl0EQCmq4BGzXWAXZlODYw0n33U2dwhn3i7H46vGSHEI05pVce6j vejC7AY7646+zJ1NuVxTKEI32wgEuqzPB/UCo5MPk44ainBVFSVn3fIY0Tl9k2a9318l bftw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=D+AEXZ1+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-169003-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169003-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id bo5-20020a0564020b2500b00572c28cc74esi2475122edb.410.2024.05.05.07.27.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 May 2024 07:27:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-169003-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=D+AEXZ1+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-169003-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169003-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 am.mirrors.kernel.org (Postfix) with ESMTPS id AAE4D1F218C1 for ; Sun, 5 May 2024 14:27:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1D53B38398; Sun, 5 May 2024 14:26:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="D+AEXZ1+" 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 0C29038384; Sun, 5 May 2024 14:26:58 +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=1714919218; cv=none; b=L9+pjKJ4XBhAwcVZEyWGmzBrSvKs0PFHz8J8UnpErQa9BSsqwvtX3JYYGkn+nxvJPBX9QMUYbfbK3TlHQx29oMQB2CZJdVLdkXHgPKx1nONZCeyiRMpmMBwJJSDaBbaFyT0o08IVpSPzaP0yovWNVZJOvUQw4KWa4o5Flg2JxQA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714919218; c=relaxed/simple; bh=Q5aCDGAMhe9LWjmBOe0KfqvsLthVcLCeaQ3ItO7ykso=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lCzozA4p4rHVDV0wVH6odhQFn6MxNySsGxOl9EDdXUAWbfwaEIl8EDto75pHP+B+8FMxjbmZjESNb8SDy0+PBmOkCvppoLgWQx1H4ArGASDRU1AL5Q1oqUyYmuxGB8kkzxnvyQsLmYLLlhOirCqDjVYuoZq9p77Kg8EV+h9WmBM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=D+AEXZ1+; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69A43C4AF68; Sun, 5 May 2024 14:26:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714919217; bh=Q5aCDGAMhe9LWjmBOe0KfqvsLthVcLCeaQ3ItO7ykso=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D+AEXZ1+edd26N9/8UI+5vqfzt0PI5uovgiDDR64glu60eQHUh9U/r9l1mLMgqbPy PSx7coEJARMFuqXTSz1qGggiwFJcsOaot+79bhH6NFAnozJPE/ZYNspdkDMHfDme7v KywFHtNx8EO37PSDv5nmAjzmWLCXrY7AK03iUjfJxfB0sYFQg43ypiUbsQZowMQcCm XW8+qGaq/gQE0FWV4qySrCFhucVOkKaE1eHGjW9Y7QcVIbjFVJjqFHMEVdoVxMp3y0 HDELXGNAVg7ov0da1Q8zWoQkFhiXLX2Og1s9FXRTGDBBnsZqJ2jnuoilS8B1kr7ICI FLfPc0Yl7YI2Q== 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 v8 03/17] nios2: define virtual address space for modules Date: Sun, 5 May 2024 17:25:46 +0300 Message-ID: <20240505142600.2322517-4-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240505142600.2322517-1-rppt@kernel.org> References: <20240505142600.2322517-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