From patchwork Tue Dec 6 08:29:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maninder Singh X-Patchwork-Id: 9462179 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A40976022E for ; Tue, 6 Dec 2016 08:37:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 943FB26D17 for ; Tue, 6 Dec 2016 08:37:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 870F12832B; Tue, 6 Dec 2016 08:37:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0D6B926D17 for ; Tue, 6 Dec 2016 08:37:04 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cEBDV-0000TQ-QH; Tue, 06 Dec 2016 08:35:13 +0000 Received: from mailout1.samsung.com ([203.254.224.24]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cEBDR-0008Ok-Aa for linux-arm-kernel@lists.infradead.org; Tue, 06 Dec 2016 08:35:10 +0000 Received: from epcpsbgm1new.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OHR0294695UAKC0@mailout1.samsung.com> for linux-arm-kernel@lists.infradead.org; Tue, 06 Dec 2016 17:34:45 +0900 (KST) X-AuditID: cbfee61a-f79916d0000062de-e3-584678253274 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id 00.75.25310.52876485; Tue, 6 Dec 2016 17:34:45 +0900 (KST) Received: from localhost.localdomain ([107.108.92.210]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OHR00KFG95LIJ60@mmp1.samsung.com>; Tue, 06 Dec 2016 17:34:45 +0900 (KST) From: Maninder Singh To: linux@armlinux.org.uk, nicolas.pitre@linaro.org, ssantosh@kernel.org, panand@redhat.com, arnd@arndb.de, chris.brandt@renesas.com Subject: [PATCH 1/1] arm/module: maximum utilization of module area. Date: Tue, 06 Dec 2016 13:59:35 +0530 Message-id: <1481012975-44478-1-git-send-email-maninder1.s@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpmkeLIzCtJLcpLzFFi42I5/e+xgK5qhVuEwbz3ohYvXk1gsfg76Ri7 xfzpvSwWmx5fY7W4vGsOm8WhqXsZLQ7Pb2Ox+PTsH7vFnNUvGC3uvdnKZHFn82ZWi0Mn5zI6 8HhcvnaR2eP3r0mMHptWdbJ53Lm2h81j85J6j/f7rrJ5fDszkcWjb8sqRo/Pm+QCOKPcbDJS E1NSixRS85LzUzLz0m2VQkPcdC2UFPISc1NtlSJ0fUOClBTKEnNKgTwjAzTg4BzgHqykb5fg lrFu5haWgsXCFf3vDzM2MD7n72Lk5JAQMJFonNXJCGGLSVy4t56ti5GLQ0hgKaPEhCv7WCGc n4wSj7+0sIJUsQnoSazatYcFJCEi0MYoceD9D3YQh1ngKFDLm0ssIFXCAi4Sb2c8ZAOxWQRU JT4uPsIOYvMKuEs8+byFDWKfnMTJY5NZJzByL2BkWMUokVqQXFCclJ5rmJdarlecmFtcmpeu l5yfu4kRHAHPpHYwHtzlfohRgINRiYf3Q4NrhBBrYllxZe4hRgkOZiURXoZstwgh3pTEyqrU ovz4otKc1OJDjKZAB0xklhJNzgdGZ15JvKGJuYm5sYGFuaWliZGSOG/j7GfhQgLpiSWp2amp BalFMH1MHJxSDYzzQ2TO7JlzfW/+W7uvl+JlymYxXK3O33two/OazJnOxcxnIv+3WVzhvL8j olS3XLjgw1/Gn4szP2j3KcdXnMjwsZNii3RdMVU7y/SnRV7ow9eSlyTn/Ts++9q1JbtFE2bz f7d+WiOZsNXi+hPOlPwNoS2prPc7GvY8Yf2i/nmG7k6PpZE9sQVKLMUZiYZazEXFiQDuGMWS lgIAAA== X-MTR: 20000000000000000@CPGS X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161206_003509_549501_402566C1 X-CRM114-Status: GOOD ( 11.36 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vaneet Narang , linux-kernel@vger.kernel.org, ajeet.y@samsung.com, Maninder Singh , linux-arm-kernel@lists.infradead.org, pankaj.m@samsung.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch defines new macro MODULE_START to ensure kernel text and module remains within 32 MB of address range. Tried this patch by inserting 20 MB size module on 4.1 kernel:- Earlier:- ========== sh# insmod size.ko .... insmod: ERROR: could not insert module size.ko: Cannot allocate memory sh# With this patch =============== sh# insmod size.ko ... sh# lsmod Module Size Used by size 20972425 0 Signed-off-by: Vaneet Narang Signed-off-by: Maninder Singh Reviewed-by: Ajeet Yadav --- arch/arm/include/asm/memory.h | 4 ++-- arch/arm/kernel/module.c | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h index 76cbd9c..1a0a6e5 100644 --- a/arch/arm/include/asm/memory.h +++ b/arch/arm/include/asm/memory.h @@ -37,7 +37,7 @@ * TASK_SIZE - the maximum size of a user space task. * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area */ -#define TASK_SIZE (UL(CONFIG_PAGE_OFFSET) - UL(SZ_16M)) +#define TASK_SIZE (UL(CONFIG_PAGE_OFFSET) - UL(SZ_32M)) #define TASK_UNMAPPED_BASE ALIGN(TASK_SIZE / 3, SZ_16M) /* @@ -50,7 +50,7 @@ * and PAGE_OFFSET - it must be within 32MB of the kernel text. */ #ifndef CONFIG_THUMB2_KERNEL -#define MODULES_VADDR (PAGE_OFFSET - SZ_16M) +#define MODULES_VADDR (PAGE_OFFSET - SZ_32M) #else /* smaller range for Thumb-2 symbols relocation (2^24)*/ #define MODULES_VADDR (PAGE_OFFSET - SZ_8M) diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c index 4f14b5c..b8e1f9c 100644 --- a/arch/arm/kernel/module.c +++ b/arch/arm/kernel/module.c @@ -35,12 +35,19 @@ */ #undef MODULES_VADDR #define MODULES_VADDR (((unsigned long)_exiprom + ~PMD_MASK) & PMD_MASK) +#define MODULES_START MODULES_VADDR +#else +#ifndef CONFIG_THUMB2_KERNEL +#define MODULES_START ALIGN((unsigned long)_etext - SZ_32M, PAGE_SIZE) +#else +#define MODULES_START MODULES_VADDR +#endif #endif #ifdef CONFIG_MMU void *module_alloc(unsigned long size) { - void *p = __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END, + void *p = __vmalloc_node_range(size, 1, MODULES_START, MODULES_END, GFP_KERNEL, PAGE_KERNEL_EXEC, 0, NUMA_NO_NODE, __builtin_return_address(0)); if (!IS_ENABLED(CONFIG_ARM_MODULE_PLTS) || p)