From patchwork Tue Oct 24 09:22:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 10023807 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 EBE7960245 for ; Tue, 24 Oct 2017 09:23:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF99C289CE for ; Tue, 24 Oct 2017 09:23:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D419A289D2; Tue, 24 Oct 2017 09:23:11 +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,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 62D79289CE for ; Tue, 24 Oct 2017 09:23:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=MR5YKSnwL8Iev4WyL5jg8cEtcnxat8gPaCqv1R3hB84=; b=I/QdSVli8Kh/yq GI2HTCuViDGdgsNOZmpZjQWgWmWA/YqjaUnwv5WZUH4x0z494aXtYv24wtyy4Evt6aZQuKnG3TYBV OWVB1NBvfWnxERtHBB1wQ6Q6gfmAWphJ9c5lomLaqGjt+jTXbvYNlmAv2DFSI0eE97Uv3pKcsqtR5 ebRC6QxE6RWingpbR12X2os9kue2PDYqAL9SYsp+Pu0/X4w5FapWkwhbLAJ7qkbWP/1VgyFmoBWb1 7SXGN8alcCb+U3C0ubZPBlETiYeQ6uW22qxWuRhZiscPiUrBYQHv1GxJV8tDjnl+Wbzrhjw21OgWt AOlMAa7S51IJcxBGP7xg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e6vQU-0007Ev-TE; Tue, 24 Oct 2017 09:23:10 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:3201:214:fdff:fe10:1be6]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e6vQQ-0007Au-JV for linux-arm-kernel@lists.infradead.org; Tue, 24 Oct 2017 09:23:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2014; h=Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=syhW2CjMD48p/6U4AX0ia8T9Dl2TGjYFOmLR4hthruM=; b=VhgkHNDGs9xHU3iWv+YIWtR3D+c4/p3onHGfduxk1gBlWteedr3pFyiFSW+2qxHDZTMWc6gWTWdQT+oUBffv5B9od7QqYZ0RcZOQ2NbFLoAsHH5cd7Et4QEmAvreC86bygIvlyAHDp1ek0wwCpLhUkR6rBPAh68vBXxM4okJBbU=; Received: from n2100.armlinux.org.uk ([2002:4e20:1eda:1:214:fdff:fe10:4f86]:53710) by pandora.armlinux.org.uk with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1e6vPu-00048s-4e; Tue, 24 Oct 2017 10:22:34 +0100 Received: from linux by n2100.armlinux.org.uk with local (Exim 4.76) (envelope-from ) id 1e6vPp-0005L4-Ui; Tue, 24 Oct 2017 10:22:30 +0100 Date: Tue, 24 Oct 2017 10:22:29 +0100 From: Russell King - ARM Linux To: Ard Biesheuvel Subject: Re: [PATCH] ARM: Fix zImage file size not aligned with CONFIG_EFI_STUB enabled Message-ID: <20171024092229.GA20805@n2100.armlinux.org.uk> References: <20171022124757.GL20805@n2100.armlinux.org.uk> <59ED6179.5020301@rock-chips.com> <20171023085006.GM20805@n2100.armlinux.org.uk> <59EDC34C.40109@rock-chips.com> <20171023105046.GT20805@n2100.armlinux.org.uk> <20171023114549.GU20805@n2100.armlinux.org.uk> <20171024090953.GZ20805@n2100.armlinux.org.uk> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171024_022306_947705_78981BF5 X-CRM114-Status: GOOD ( 15.91 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ingo Molnar , jeffy , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , Chris Zhong 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 On Tue, Oct 24, 2017 at 10:13:09AM +0100, Ard Biesheuvel wrote: > On 24 October 2017 at 10:09, Russell King - ARM Linux > wrote: > > The question is: do we want to know when additional sections get > > emitted into the binary? > > Well, we need to know whether the size of zImage is a multiple of 512 > bytes. We could check that separately by adding the following as well > > #ifdef CONFIG_EFI_STUB > ASSERT((_edata % 512 == 0), "zImage file size is not a multiple of 512 bytes") ASSERT((_edata - _text) % 512 == 0, "EFI zImage file size is not a multiple of 512 bytes") This would only catch them when EFI is enabled, which doesn't give very good build coverage. I still prefer my solution over adding the assert and a section for _edata - my solution catches it with EFI disabled as well. A variant on that would be this, which should catch additional sections for EFI and non-EFI: Tested-by: Ard Biesheuvel diff --git a/arch/arm/boot/compressed/vmlinux.lds.S b/arch/arm/boot/compressed/vmlinux.lds.S index b38dcef90756..9d0c5d80979a 100644 --- a/arch/arm/boot/compressed/vmlinux.lds.S +++ b/arch/arm/boot/compressed/vmlinux.lds.S @@ -95,6 +95,10 @@ SECTIONS _edata = .; + .image_end (NOLOAD) : { + _image_end = .; + } + _magic_sig = ZIMAGE_MAGIC(0x016f2818); _magic_start = ZIMAGE_MAGIC(_start); _magic_end = ZIMAGE_MAGIC(_edata); @@ -119,3 +123,5 @@ SECTIONS .stab.indexstr 0 : { *(.stab.indexstr) } .comment 0 : { *(.comment) } } + +ASSERT(image_end == end, "zImage file size is incorrect")