From patchwork Wed Oct 9 01:31:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 3006231 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 32ADFBF924 for ; Wed, 9 Oct 2013 01:34:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 59DC8201F9 for ; Wed, 9 Oct 2013 01:34:51 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 472C4201B3 for ; Wed, 9 Oct 2013 01:34:50 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VTieD-0005Xa-N9; Wed, 09 Oct 2013 01:33:10 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VTidn-0003iX-8e; Wed, 09 Oct 2013 01:32:43 +0000 Received: from smtp.codeaurora.org ([198.145.11.231]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VTidP-0003f7-17 for linux-arm-kernel@lists.infradead.org; Wed, 09 Oct 2013 01:32:19 +0000 Received: from smtp.codeaurora.org (localhost [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 9FF2913F29E; Wed, 9 Oct 2013 01:31:46 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 486) id 923BA13F2A2; Wed, 9 Oct 2013 01:31:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from lauraa-linux1.qualcomm.com (i-global252.qualcomm.com [199.106.103.252]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: lauraa@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 3406C13F29E; Wed, 9 Oct 2013 01:31:46 +0000 (UTC) From: Laura Abbott To: linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH 5/5] arm: Don't free init text if CONFIG_STRICT_MEMORY_RWX is enabled Date: Tue, 8 Oct 2013 18:31:32 -0700 Message-Id: <1381282292-25251-6-git-send-email-lauraa@codeaurora.org> X-Mailer: git-send-email 1.7.8.3 In-Reply-To: <1381282292-25251-1-git-send-email-lauraa@codeaurora.org> References: <1381282292-25251-1-git-send-email-lauraa@codeaurora.org> X-Virus-Scanned: ClamAV using ClamSMTP X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131008_213219_172528_0F4D6B58 X-CRM114-Status: GOOD ( 14.54 ) X-Spam-Score: -2.2 (--) Cc: Larry Bassel , Laura Abbott , Kees Cook X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 CONFIG_STRICT_MEMORY_RWX makes the text section be RX only. This is incompatible with freeing the text back to general memory. Skip the text free when freeing initmem. This does result in less memory freed back into the system but we cannot easily change the protections on the text section back to RWNX. Signed-off-by: Laura Abbott Signed-off-by: Larry Bassel --- arch/arm/mm/init.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 15225d8..a23c99c 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -681,6 +681,9 @@ void __init mem_init(void) void free_initmem(void) { +#ifdef CONFIG_STRICT_MEMORY_RWX + unsigned long reclaimed_initmem; +#endif #ifdef CONFIG_HAVE_TCM extern char __tcm_start, __tcm_end; @@ -688,9 +691,18 @@ void free_initmem(void) free_reserved_area(&__tcm_start, &__tcm_end, -1, "TCM link"); #endif +#ifdef CONFIG_STRICT_MEMORY_RWX + poison_init_mem((char *)__arch_info_begin, + __init_end - (char *)__arch_info_begin); + reclaimed_initmem = free_reserved_area(__arch_info_begin, + __init_end, -1, + "init"); + totalram_pages += reclaimed_initmem; +#else poison_init_mem(__init_begin, __init_end - __init_begin); if (!machine_is_integrator() && !machine_is_cintegrator()) free_initmem_default(-1); +#endif } #ifdef CONFIG_BLK_DEV_INITRD