From patchwork Thu Feb 1 18:18:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 126573 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp1954225ljc; Thu, 1 Feb 2018 10:24:55 -0800 (PST) X-Google-Smtp-Source: AH8x227O1u9qlh1TzLBGcpQCCQe4nj43lMe+RiGGOvus9VzxWB5dXzw/raZwMy7BlHj3OKGxZUJI X-Received: by 10.37.210.14 with SMTP id j14mr14098950ybg.229.1517509495736; Thu, 01 Feb 2018 10:24:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517509495; cv=none; d=google.com; s=arc-20160816; b=wI5eJGpbzPNHb6vDgaE5Fp3AgKEiJYhkV2d3AAxTctfT1ngttXM285qn1kiVocKv8s r1iAHSKhmoP4MVSsqRnwetQcUHV2gCmJjfVVWPhtE72++P3T+10rDwbo+xuhIJed12tl yuSUy7/102fxGpVj7B9cVnPOcUI4ZajXBas43GqFP0rlL6xmZTpkC4s36ERd3yGsC0Fs 9fWnad0DPSEbCMBLW3VGwJoYThNDlPna91yIs174bQkDMHKY+bxvSXqTlGpKQxX6ubJ7 iL1AuEBQMNJEa1O2E5Ew37dEWj2vkFTV6YDBOZ77XB7BLdlnzgiPSx1BfVKJ4iGTC+1L yKNQ== 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=A2c6NnoUN+NevYdxE5zYa/h/qasqmi+I2bjG2y2mjtg=; b=Mt4j9yE/Qp968yaZbE8rh2ccln8uwDpiw3J1bMEhhlHXWPI08/8jFzuvyfbKojTjQd atLyoU5RO2wp8vlzDHojSNnZq8toCh6bthe7/+EbB57sErbC2WwvuCj5yLIGlw8WMqsz 7WVjGKY1tHjrDVY14GTFZ0IGDhTb+lO3vnLff8dmKsEIPlXypUvCqnswC0l92fupnTlQ WKVV2htRGvqIq1abJVCmChLmDL09poeuB5RMfcEpilSuIPvFhVXaMEbmA00C2WeH01H5 yuKL/wZKy+Kmbxd9SMNsUoLrzAggzzWCLp7XCej8lfxZwTFEuaogtuIofJtuOIqbkWW/ yGYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=aTxNQl3y; 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 x124si29874ybx.578.2018.02.01.10.24.55 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 01 Feb 2018 10:24:55 -0800 (PST) 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.s=google header.b=aTxNQl3y; 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]:52888 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehJXb-0007Q9-38 for patch@linaro.org; Thu, 01 Feb 2018 13:24:55 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55504) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehJS9-0003tI-Tz for grub-devel@gnu.org; Thu, 01 Feb 2018 13:19:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ehJS5-0003b6-A0 for grub-devel@gnu.org; Thu, 01 Feb 2018 13:19:17 -0500 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:39904) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ehJS5-0003Yd-3a for grub-devel@gnu.org; Thu, 01 Feb 2018 13:19:13 -0500 Received: by mail-wm0-x244.google.com with SMTP id b21so7523712wme.4 for ; Thu, 01 Feb 2018 10:19:13 -0800 (PST) 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=Do/O/HDi4YkZchAgjSaFM2IIHKEKTA0bEqj9o6HoBeE=; b=aTxNQl3yM0CCvITDnWB9HXmjT4UAoJ7OS5XJDWltkWQRzbtakdt0aHOJqUqddP0SGp h98hEwtN8lTGq2ylMJMKY6VNVeGRK+8cQpNUTIOwa1lW/PbUog/gKTCcJpQV/I1vDtYj cfw16H2pBT3LI57yC3hMsUoz3N1DzY1CeDwyM= 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=Do/O/HDi4YkZchAgjSaFM2IIHKEKTA0bEqj9o6HoBeE=; b=VH6qF/B++jBYSovXT1Cg2vkXHqjnx/R0f0iq96HOjty8X5yi9TPiFs2LLA2Byxd4Z7 OufQVvIPgfWqPYlspNo93MFTwkP5OupSPXBZ9NfdG01O3IBd8D9+/EFPeKcjKQNVjEGc tkxuzNIX5CiYdRYTvo9uWBI+h3X0HNkiogZJp0NSWTtka3fbE/byooC8A4kI02e6tUGe HyxUs9JMFCVIzeA/+ZNJbqEgSfQsefgac1BVVFgEj6ZZxQ2uUNytSYR0UngmCVGVm2Od KRnexyoiRWQPpzzOadPTdhtB6KPT9Ozk4WiWan3K7sdA/utfkLZX5jj7raIA3hcQthjo PFbA== X-Gm-Message-State: AKwxyte+izLUjunSnwuL4g31pVv+p+gbPbo/1MH4c7r9ycIj3uEH3yTA AwC/z0UFTLNdhKRM5ew/0wk+0ch7BKM= X-Received: by 10.28.247.25 with SMTP id v25mr29619903wmh.10.1517509151658; Thu, 01 Feb 2018 10:19:11 -0800 (PST) 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 b11sm163911wrf.23.2018.02.01.10.19.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Feb 2018 10:19:10 -0800 (PST) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH 07/10] arm: switch linux loader to linux_arm_kernel_header struct Date: Thu, 1 Feb 2018 18:18:55 +0000 Message-Id: <20180201181858.1472-8-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180201181858.1472-1-leif.lindholm@linaro.org> References: <20180201181858.1472-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:c09::244 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 magic definition to align (and coexist) with i386/arm64 ports. 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 Reviewed-by: Daniel Kiper diff --git a/grub-core/loader/arm/linux.c b/grub-core/loader/arm/linux.c index e64c79a95..9f43e41bb 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 linux_arm_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_ARM_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 3706c46c6..64dd3173c 100644 --- a/include/grub/arm/linux.h +++ b/include/grub/arm/linux.h @@ -20,11 +20,20 @@ #ifndef GRUB_ARM_LINUX_HEADER #define GRUB_ARM_LINUX_HEADER 1 -#define LINUX_ZIMAGE_OFFSET 0x24 -#define LINUX_ZIMAGE_MAGIC 0x016f2818 - #include "system.h" +#define GRUB_LINUX_ARM_MAGIC_SIGNATURE 0x016f2818 + +struct linux_arm_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)