From patchwork Tue Jun 21 09:08:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dirk Behme X-Patchwork-Id: 9189991 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 6088060756 for ; Tue, 21 Jun 2016 09:11:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4DC9527FB7 for ; Tue, 21 Jun 2016 09:11:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4240127FC0; Tue, 21 Jun 2016 09:11:29 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0981327FB7 for ; Tue, 21 Jun 2016 09:11:27 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bFHgO-0006Pb-MH; Tue, 21 Jun 2016 09:09:20 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bFHgN-0006PU-Ar for xen-devel@lists.xenproject.org; Tue, 21 Jun 2016 09:09:19 +0000 Received: from [85.158.139.211] by server-11.bemta-5.messagelabs.com id C1/D4-04210-E3409675; Tue, 21 Jun 2016 09:09:18 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrOIsWRWlGSWpSXmKPExsXSzf+WW9eOJTP c4NY5NovvWyYzOTB6HP5whSWAMYo1My8pvyKBNePl2a2sBbukKqafXsfcwDhTpIuRi0NI4Cyj xMLf7SwgDovAWyaJjmOH2CEyzxkl5jZvZ4Rw1jBKtHQvBirjBHJWMkpsWqoHYrMJaEnsnNDBD mKLCJRLrNr3iLWLkYODWUBDYsM2sLCwgInE3ImbwGwWAVWJ058usYOU8Aq4SVycZwISlhCQk1 g3+TtYCa+AoMTJmU/ANjELSEgcfPGCGaJGRGLi3/dsELalxK5FHWB3SgjsY5ZY9q2BcQKj4Cw k/bOQ9C9gZFrFqF6cWlSWWqRroZdUlJmeUZKbmJmja2hgqpebWlycmJ6ak5hUrJecn7uJERig DECwg/Fgs/MhRkkOJiVRXmbljHAhvqT8lMqMxOKM+KLSnNTiQ4wyHBxKErw+jJnhQoJFqempF WmZOcBYgUlLcPAoifAKgqR5iwsSc4sz0yFSpxgVpcR5HUESAiCJjNI8uDZYfF5ilJUS5mUEOk SIpyC1KDezBFX+FaM4B6OSMK8YyBSezLwSuOmvgBYzAS1e1p8OsrgkESEl1cBoO+VnTgTnNI3 CFwkt9+zlzB7nfk3QTphxK7ou8vyyYIba3fU7A77GfXzTxOzY7y31SiPpmcsL/XyblX89wjYw BKkLXF68IMdnn5e9t7SvckyW/tvkB9nbmmKenJUNXfpowp3jDFaPe5efsnz8lvuXDIOb4+XmB J0bTz/9KjgeuFBfM42rr0OJpTgj0VCLuag4EQA/zvYJygIAAA== X-Env-Sender: Dirk.Behme@de.bosch.com X-Msg-Ref: server-8.tower-206.messagelabs.com!1466500157!45719074!1 X-Originating-IP: [139.15.237.11] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTM5LjE1LjIzNy4xMSA9PiAxNTMwMzA=\n X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 37183 invoked from network); 21 Jun 2016 09:09:18 -0000 Received: from smtp6-v.fe.bosch.de (HELO smtp6-v.fe.bosch.de) (139.15.237.11) by server-8.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 21 Jun 2016 09:09:18 -0000 Received: from vsmta13.fe.internet.bosch.com (unknown [10.4.98.53]) by imta23.fe.bosch.de (Postfix) with ESMTP id 8B1371580216 for ; Tue, 21 Jun 2016 11:09:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=de.bosch.com; s=2015-01-21; t=1466500157; bh=Fkztw+w29n/RtCYHbEXsFbnY3M0zIvbb7k+ZGSlsatU=; l=10; h=From:From:Reply-To:Sender; b=cM6inSqclL4+2Z1neTTfyGdDN3indFMVx/j5AqAV+1MiXgZNLbwWz9UO6eaGdVWV4 Fl7oW1ca6WWubLo1G7m11Hsc3+81fbamU1zvCDYeERjTdgWMQkBcAOIy7LFbsjLr+f rtYVN36fUk1B7hdKFsmXC7vRP61tKl5cBkg9su18= Received: from FE-HUB1001.de.bosch.com (vsgw23.fe.internet.bosch.com [10.4.98.23]) by vsmta13.fe.internet.bosch.com (Postfix) with ESMTP id 3DA572E4022D for ; Tue, 21 Jun 2016 11:09:17 +0200 (CEST) Received: from hi-z08if.hi.de.bosch.com (10.34.209.31) by FE-HUB1001.de.bosch.com (10.4.103.109) with Microsoft SMTP Server id 14.3.195.1; Tue, 21 Jun 2016 11:09:15 +0200 Received: from hi-z08if.hi.de.bosch.com (localhost [127.0.0.1]) by hi-z08if.hi.de.bosch.com (Postfix) with ESMTP id 6C4B0625F14; Tue, 21 Jun 2016 11:08:32 +0200 (CEST) From: Dirk Behme To: , Julien Grall , Stefano Stabellini Date: Tue, 21 Jun 2016 11:08:28 +0200 Message-ID: <1466500108-8216-1-git-send-email-dirk.behme@de.bosch.com> X-Mailer: git-send-email 2.8.0 MIME-Version: 1.0 X-TM-AS-MML: disable X-TM-AS-Product-Ver: IMSS-7.1.0.1679-8.0.0.1202-22402.006 X-TMASE-MatchedRID: pMhejqV9KQQryFHbNnBLG7U+IyHhkXf1FuNF4lJG6xsL/50zj0KL7BHx rRblSw8b9Pkiah4SuH4MfgmZ55C/YfF4Lj+zpFjfVnhTcytb5dIwl5uLW9ec01pbYq2f4jz+sCL 2uKJULhPKwJG6rXlLlAMCC5iRZIS0f3vqpuJAqb8VglQa/gMvfCnGh6cFQ6sh31GU/N5W5BDejM lFftvg2e1aiEKskT0pqhVinVPTWKa4YWhbJElg6khwlOfYeSqxy+DowCmARBrFpA1uJFd1mhU3w dcgT5TyroZyd7iDH9CfT/nFtBcklq2IX6n70FjpngIgpj8eDcAZ1CdBJOsoY8RB0bsfrpPIfiAq rjYtFiRSyP2ERKn7kF3lkUObxqYAvZ6cD5njHfRX7P7orH8Xzn7cGd19dSFd Cc: Dirk Behme Subject: [Xen-devel] [PATCH] xen: arm: Update arm64 image header X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP With the Linux kernel commits https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/Documentation/arm64/booting.txt?id=4370eec05a887b0cd4392cd5dc5b2713174745c0 https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/Documentation/arm64/booting.txt?id=a2c1d73b94ed49f5fac12e95052d7b140783f800 the arm64 image header changed. While the size of the header isn't changed, some members have changed their usage. Update Xen to this updated image header. The main changes are that the first magic is gone and that there is an image size, now. In case we read a size != 0, let's use this image size, now. This does allow us to warn if the kernel Image is larger than the size given in the device tree, too. Signed-off-by: Dirk Behme --- xen/arch/arm/kernel.c | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c index 3f6cce3..1cfaf02 100644 --- a/xen/arch/arm/kernel.c +++ b/xen/arch/arm/kernel.c @@ -28,8 +28,7 @@ #define ZIMAGE32_MAGIC 0x016f2818 -#define ZIMAGE64_MAGIC_V0 0x14000008 -#define ZIMAGE64_MAGIC_V1 0x644d5241 /* "ARM\x64" */ +#define ZIMAGE64_MAGIC 0x644d5241 /* "ARM\x64" */ struct minimal_dtb_header { uint32_t magic; @@ -335,17 +334,17 @@ static int kernel_zimage64_probe(struct kernel_info *info, { /* linux/Documentation/arm64/booting.txt */ struct { - uint32_t magic0; - uint32_t res0; - uint64_t text_offset; /* Image load offset */ - uint64_t res1; - uint64_t res2; + uint32_t code0; + uint32_t code1; + uint64_t text_offset; /* Image load offset, little endian */ + uint64_t image_size; /* Effective Image size, little endian */ + uint64_t flags; /* zImage V1 only from here */ + uint64_t res2; uint64_t res3; uint64_t res4; - uint64_t res5; - uint32_t magic1; - uint32_t res6; + uint32_t magic; /* Magic number, little endian, "ARM\x64" */ + uint32_t res5; } zimage; uint64_t start, end; @@ -354,20 +353,28 @@ static int kernel_zimage64_probe(struct kernel_info *info, copy_from_paddr(&zimage, addr, sizeof(zimage)); - if ( zimage.magic0 != ZIMAGE64_MAGIC_V0 && - zimage.magic1 != ZIMAGE64_MAGIC_V1 ) + if ( zimage.magic != ZIMAGE64_MAGIC ) return -EINVAL; - /* Currently there is no length in the header, so just use the size */ start = 0; - end = size; /* - * Given the above this check is a bit pointless, but leave it - * here in case someone adds a length field in the future. + * Where image_size is non-zero image_size is little-endian + * and must be respected. */ - if ( (end - start) > size ) + if ( zimage.image_size ) + end = zimage.image_size; + else + end = size; + + if ( (end - start) > size ) { + if ( zimage.image_size ) { + printk(XENLOG_ERR "Error: Kernel Image size: %lu bytes > bootmodule size: %lu bytes\n", + zimage.image_size, (uint64_t)size); + printk(XENLOG_ERR "Check the device tree configuration!\n"); + } return -EINVAL; + } info->zimage.kernel_addr = addr; info->zimage.len = end - start;