From patchwork Thu Aug 3 10:04:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 109314 Delivered-To: patch@linaro.org Received: by 10.182.45.195 with SMTP id p3csp682073obm; Thu, 3 Aug 2017 03:14:47 -0700 (PDT) X-Received: by 10.55.46.5 with SMTP id u5mr1522341qkh.217.1501755287755; Thu, 03 Aug 2017 03:14:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501755287; cv=none; d=google.com; s=arc-20160816; b=lkXvhBDkoacg6KLWmnOFJ8TMfPGLNCx7xDwtqR7d89mEXoyyLjYVFpU1T4pXp6ER2c oF6PR7MPLsBqZBuNAFc8MvvLK6iaXtY+lDnMLX0zvrpEOmzBJ1gvOzKVYSJFqdiTOXcW ADL7i85D9X9trHvfk+OJydemIrcHPmrRPzufOnmiPA/P3yUmQACF4RRvNS8xyUBU6Hxj MkF7X6stsvBBo/kDBHVzz+4yiKiZ3dJ2UujMj2qN7DDEJ65hVXzhqgzd1lxMXSH+EHVu AbkC7RiQqCBEaebl8LcjVrjjP6KZ0Q3Mr9Q/aVSbyRv1QJ9bwzE5B5ZrgakNObizkIUT J7BQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:dkim-signature:arc-authentication-results; bh=a8njvOoipjMcVTrzOjIENBsQ4PoLHeuGMMxGLH5xW3k=; b=ojHNkR3xJmDsuvtDz1oJMuh9erfUNlB29MNHUwfpja/vZNMkOe3WGbX7YlrfK1uPds D3vH4nBP9bjv2d1Wi6L5GjesWuJN2ufBpbTp58c8rZUxEZBPXjvlDm1ZPDsOeNRyJMW4 5Q6sH19isph5Feqq+PsCLZWc41YPoj0IQHa3u/pK8Dk0EtCxB9FuK0SMUXGAZQNqhumZ iHGCjucYvQ+3yBbtc4KncyUtR+bDTopqVwA2doM9F1kIQeUeVCn8CDvi/9pDB8RYrDAa DicnNDtkwWjad3CIeYiCmaHeq8rs3taJlPYnFAvkPJgzls/O1X3gARz9nmE1IqB9YVG1 XWsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=UWM0/k5Q; spf=pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=grub-devel-bounces+patch=linaro.org@gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id v66si33524532qkg.412.2017.08.03.03.14.47 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 03 Aug 2017 03:14:47 -0700 (PDT) Received-SPF: pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=UWM0/k5Q; spf=pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=grub-devel-bounces+patch=linaro.org@gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:53690 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddD9R-0006ik-4D for patch@linaro.org; Thu, 03 Aug 2017 06:14:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45798) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddD1i-0000JE-2N for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ddD1g-0004Df-UL for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:46 -0400 Received: from mail-wr0-x22d.google.com ([2a00:1450:400c:c0c::22d]:33452) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ddD1g-0004Cj-P3 for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:44 -0400 Received: by mail-wr0-x22d.google.com with SMTP id v105so3749582wrb.0 for ; Thu, 03 Aug 2017 03:06:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fXpxaReeT5087QhzCzQlNSj+V2+B1ARzUqTjd/rxd6o=; b=UWM0/k5QF0Zq46FaVKpXRttsEkCvHBc82uHiwoM8XIrgLDarlOVDOtzNLCXZCLCphD 9ewxdXzkl+NAyhEKNmWZdf7FbzAMXvE1DwISdmTgYo3hiEZS3uBgHKWtWi7TVD3EM43Q 1mtSaCeo2P8b3zD+PFBL7C9Ui88QxMRFfgrz0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fXpxaReeT5087QhzCzQlNSj+V2+B1ARzUqTjd/rxd6o=; b=NDB5Tteb0AZS0koL5rekQs3XK+Fw9lpVpcbGUGGZoD1RB9O9ChmAC6JWF9b/MIim4q pQWvbyAcSbXeyxkOJQrWoUGkFmEN9G5nTOWDpuxJUPXP+Cuih2byAUIzOdu45zlETe2X V9hz5tuLP0rdtEEeO83n+cEqw9eSlFtzeL3Bc6MfdJdiWZlGHRGHnDqwivFMJJxLFL0a E2gYi0yf6pPRNKhp2zzWv2mqr0NdVIGRWHt8R0hgI3gSVDM1x7H7RwyLSsWvMBiCyMpu Ma8wG1gaiW5KstgNYYHN7zdJynwIBD9nZnsnCiC0IQtZLETIXe/9t7JdKMDp+EsUNPc6 1lRQ== X-Gm-Message-State: AHYfb5g0+QNs6YHhYbovrZ4gg9ymZrXbCneBQNBB0bbWkQby9sZVlzDO GuD1YOZDg/8VE1VlZYCWSw== X-Received: by 10.223.148.162 with SMTP id 31mr914018wrr.28.1501754803495; Thu, 03 Aug 2017 03:06:43 -0700 (PDT) Received: from vanye.hemma.eciton.net (cpc92316-cmbg19-2-0-cust118.5-4.cable.virginm.net. [82.12.0.119]) by smtp.gmail.com with ESMTPSA id e5sm2274543wre.24.2017.08.03.03.06.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Aug 2017 03:06:42 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH v2 10/14] loader: switch arm/linux to grub_linux_kernel_header struct Date: Thu, 3 Aug 2017 11:04:28 +0100 Message-Id: <20170803100432.29913-11-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170803100432.29913-1-leif.lindholm@linaro.org> References: <20170803100432.29913-1-leif.lindholm@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22d X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The development of GNU GRUB Cc: Daniel Kiper MIME-Version: 1.0 Errors-To: grub-devel-bounces+patch=linaro.org@gnu.org Sender: "Grub-devel" Use kernel header struct and generic magic definition to align with arm64/linux loader. Signed-off-by: Leif Lindholm --- grub-core/loader/arm/linux.c | 11 +++++------ include/grub/arm/linux.h | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 9 deletions(-) -- 2.11.0 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel diff --git a/grub-core/loader/arm/linux.c b/grub-core/loader/arm/linux.c index e64c79a95..067f69894 100644 --- a/grub-core/loader/arm/linux.c +++ b/grub-core/loader/arm/linux.c @@ -46,9 +46,6 @@ static const void *current_fdt; typedef void (*kernel_entry_t) (int, unsigned long, void *); -#define LINUX_ZIMAGE_OFFSET 0x24 -#define LINUX_ZIMAGE_MAGIC 0x016f2818 - #define LINUX_PHYS_OFFSET (0x00008000) #define LINUX_INITRD_PHYS_OFFSET (LINUX_PHYS_OFFSET + 0x02000000) #define LINUX_FDT_PHYS_OFFSET (LINUX_INITRD_PHYS_OFFSET - 0x10000) @@ -315,6 +312,7 @@ linux_boot (void) static grub_err_t linux_load (const char *filename, grub_file_t file) { + struct grub_linux_kernel_header *lh; int size; size = grub_file_size (file); @@ -337,9 +335,10 @@ linux_load (const char *filename, grub_file_t file) return grub_errno; } - if (size > LINUX_ZIMAGE_OFFSET + 4 - && *(grub_uint32_t *) (linux_addr + LINUX_ZIMAGE_OFFSET) - == LINUX_ZIMAGE_MAGIC) + lh = (void *) linux_addr; + + if ((grub_size_t) size > sizeof (*lh) && + lh->magic == GRUB_LINUX_MAGIC_SIGNATURE) ; else if (size > 0x8000 && *(grub_uint32_t *) (linux_addr) == 0xea000006 && machine_type == GRUB_ARM_MACHINE_TYPE_RASPBERRY_PI) diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h index f217f8281..802090239 100644 --- a/include/grub/arm/linux.h +++ b/include/grub/arm/linux.h @@ -20,11 +20,20 @@ #ifndef GRUB_LINUX_CPU_HEADER #define GRUB_LINUX_CPU_HEADER 1 -#define LINUX_ZIMAGE_OFFSET 0x24 -#define LINUX_ZIMAGE_MAGIC 0x016f2818 - #include "system.h" +#define GRUB_LINUX_MAGIC_SIGNATURE 0x016f2818 + +struct grub_linux_kernel_header { + grub_uint32_t code0; + grub_uint32_t reserved1[8]; + grub_uint32_t magic; + grub_uint32_t start; /* _start */ + grub_uint32_t end; /* _edata */ + grub_uint32_t reserved2[4]; + grub_uint32_t hdr_offset; +}; + #if defined GRUB_MACHINE_UBOOT # include # define LINUX_ADDRESS (start_of_ram + 0x8000)