From patchwork Wed Nov 9 16:35:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: william.helsby@stfc.ac.uk X-Patchwork-Id: 9419773 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 2569E6048E for ; Wed, 9 Nov 2016 16:38:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 195692925A for ; Wed, 9 Nov 2016 16:38:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0E5702927D; Wed, 9 Nov 2016 16:38:38 +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 99FBE29264 for ; Wed, 9 Nov 2016 16:38:35 +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 1c4Vr3-0001XH-Pe; Wed, 09 Nov 2016 16:36:05 +0000 Received: from smtp-out4.electric.net ([192.162.216.182]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c4Vqz-0001Vx-NT for linux-arm-kernel@lists.infradead.org; Wed, 09 Nov 2016 16:36:02 +0000 Received: from 1c4Vqc-0006Pk-VI by out4d.electric.net with emc1-ok (Exim 4.87) (envelope-from ) id 1c4Vqd-0006RZ-U2 for linux-arm-kernel@lists.infradead.org; Wed, 09 Nov 2016 08:35:39 -0800 Received: by emcmailer; Wed, 09 Nov 2016 08:35:39 -0800 Received: from [130.246.236.11] (helo=exchsmtp.stfc.ac.uk) by out4d.electric.net with esmtps (TLSv1:ECDHE-RSA-AES256-SHA:256) (Exim 4.87) (envelope-from ) id 1c4Vqc-0006Pk-VI for linux-arm-kernel@lists.infradead.org; Wed, 09 Nov 2016 08:35:38 -0800 Received: from EXCHMBX03.fed.cclrc.ac.uk ([130.246.236.15]) by EXCHHUB03.fed.cclrc.ac.uk ([130.246.236.11]) with mapi id 14.03.0266.001; Wed, 9 Nov 2016 16:35:38 +0000 From: To: Subject: [PATCH] Replacement for Arm initrd memblock reserve and free inconsistency. Thread-Topic: [PATCH] Replacement for Arm initrd memblock reserve and free inconsistency. Thread-Index: AdI5FgO6uttPSgLxTeabqxL+lilMcgAAUHuQACS+QiAAPzh0IA== Date: Wed, 9 Nov 2016 16:35:37 +0000 Message-ID: <592F4D3D062D79449F140027567F70E8FE080A79@exchmbx03> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [148.79.215.152] x-esetresult: clean, is OK x-esetid: 37303A29411E5567667063 MIME-Version: 1.0 X-Outbound-IP: 130.246.236.11 X-Env-From: william.helsby@stfc.ac.uk X-Proto: esmtps X-Revdns: exchhub03.rl.ac.uk X-HELO: exchsmtp.stfc.ac.uk X-TLS: TLSv1:ECDHE-RSA-AES256-SHA:256 X-Authenticated_ID: X-PolicySMART: 3590380 X-Virus-Status: Scanned by VirusSMART (c) X-Virus-Status: Scanned by VirusSMART (s) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161109_083602_035951_EE0E1C8B X-CRM114-Status: GOOD ( 11.31 ) 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: , 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 A boot time system crash was noticed with a segmentation fault just after the initrd image had been used to initialise the ramdisk. This occurred when the U-Boot loaded the ramdisk image from a FAT partition, but not when loaded by TFTPBOOT. This is not understood? However the problem was caused by free_initrd_mem freeing and "poisoning" memory that had been allocted to init/main.c to store the saved_command_line This patch reverses "ARM: 8167/1: extend the reserved memory for initrd to be page aligned" because it is safer to leave a partial head or tail page reserved (wasted) than to free a page which is partially still in use. If this is not acceptable (particularly if wanting large contiguous physical areas for DMA) then a better solution is required. This would extend the region reserved to page boundaries, if possible without overlapping other regions. My previous attempt to fix this coded this scheme, to grow the are reserved. However, this  again is not safe if in growing the area it then overlaps a region that is in use. Note this path is against the 4.6 kernel, but as far as I can tell applies equally to 4.8. Signed-off-by: William Helsby --- arch/arm/mm/init.c | 6 ------ 1 file changed, 6 deletions(-) -- 1.8.3.1 Science and Technology Facilities Council SciTech Daresbury Keckwick Lane Daresbury Warrington WA4 4AD Tel +44(0)1925 603250 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 370581a..ff3e9c3 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -770,12 +770,6 @@ static int keep_initrd; void free_initrd_mem(unsigned long start, unsigned long end) {         if (!keep_initrd) { -               if (start == initrd_start) -                       start = round_down(start, PAGE_SIZE); -               if (end == initrd_end) -                       end = round_up(end, PAGE_SIZE); - -               poison_init_mem((void *)start, PAGE_ALIGN(end) - start);                 free_reserved_area((void *)start, (void *)end, -1, "initrd");         } }