From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1deigz-0005fX-Lg for mharc-grub-devel@gnu.org; Mon, 07 Aug 2017 10:07:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59132) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1deigw-0005do-Qb for grub-devel@gnu.org; Mon, 07 Aug 2017 10:07:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1deigv-0006rr-0h for grub-devel@gnu.org; Mon, 07 Aug 2017 10:07:34 -0400 Received: from mail-yw0-x241.google.com ([2607:f8b0:4002:c05::241]:37698) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1deigu-0006rO-QI for grub-devel@gnu.org; Mon, 07 Aug 2017 10:07:32 -0400 Received: by mail-yw0-x241.google.com with SMTP id s143so337505ywg.4 for ; Mon, 07 Aug 2017 07:07:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=EhHFaSIQrQmxc0q9AJJtqgjwUxz4RXuC9vSlgrJ/nvU=; b=L7YKkF85Xia0iIsnNOBEwpZF+MIhnQnuGcELz40+O7vJsbHehAVIGmn8gRiHXKfIVe AtHI/IkSlNeUbaq4HKKEFwLubP8Z1FNcVr3JbIO1Vq6TljTXIjjIVOFTMwYGZVotJg2q R/5joNsuYQnJwGmB1aMVAat8L/jdUfx3ceQTRgqamO3b2cgOvRe+N1r/+z0lUXm1Uw9g Jr16h07Bjymw/DpfXc5PL++MdigYI9Cxh8XW5s0Nw8UkpFTFs+8lNZ/hnIKMmEzYoAtk 4X85ivL1Rm3X6GcvNmgk2exG/HGqojagMFD5RZv8ql0kDmQs2nnmejIYSazLguh261Ts r1nQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=EhHFaSIQrQmxc0q9AJJtqgjwUxz4RXuC9vSlgrJ/nvU=; b=YqUlmTH2pIm3ey35Swx/pPcjJabyM06DESevH4cinCFhdfP15lhl/3NOXCmtaTKVSF Sn1pxkVyNAHFN2dkmHyRfOiWaiQsnDg2L3ycl6mrUlT0GTFqJHwYYmwrNWcMBDjrdN80 hCRlu/ceKV6v0Fln/wLyziaGRBVtb68WJY1+xKYomM/t7ALQ/PUUbBpMUCGxffc5SaZk u5B0hNA16WzSNgYyfleJNst8j3/FukoQ7qWf/+lJB37SxBmEXNWFqbNdCf/s8fgXBxKr 2ophZHTD754WRiOH1vizfJHXYwczVvczPiZZrJ/lUa6IdqlOAHIK0f7RYEEb9eiEj22T m2nQ== X-Gm-Message-State: AHYfb5g7iXZOhKzQ02xR3y1HhKNyKtA/QwFpVangRIklqH1OpZRXjVmU phe9KF4Gs7ihpqUUtLeQBuksn/Pm/Lh7 X-Received: by 10.129.201.2 with SMTP id o2mr587708ywi.98.1502114850128; Mon, 07 Aug 2017 07:07:30 -0700 (PDT) MIME-Version: 1.0 References: <20170803100432.29913-1-leif.lindholm@linaro.org> <20170803100432.29913-11-leif.lindholm@linaro.org> In-Reply-To: <20170803100432.29913-11-leif.lindholm@linaro.org> From: "Vladimir 'phcoder' Serbinenko" Date: Mon, 07 Aug 2017 14:07:19 +0000 Message-ID: Subject: Re: [PATCH v2 10/14] loader: switch arm/linux to grub_linux_kernel_header struct To: The development of GNU GRUB Cc: Daniel Kiper Content-Type: multipart/alternative; boundary="089e0821ead80de03e05562a5e0f" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4002:c05::241 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: , X-List-Received-Date: Mon, 07 Aug 2017 14:07:36 -0000 --089e0821ead80de03e05562a5e0f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Le Thu, Aug 3, 2017 =C3=A0 12:15 PM, Leif Lindholm a =C3=A9crit : > 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(-) > > 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 =3D 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) > - =3D=3D LINUX_ZIMAGE_MAGIC) > + lh =3D (void *) linux_addr; > + > + if ((grub_size_t) size > sizeof (*lh) && > + lh->magic =3D=3D GRUB_LINUX_MAGIC_SIGNATURE) > ; > else if (size > 0x8000 && *(grub_uint32_t *) (linux_addr) =3D=3D 0xea0= 00006 > && machine_type =3D=3D 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 { > This maz clash with other architectures preventing including several architecture files in the same file. We need it to create tools like grub-file . > + 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) > -- > 2.11.0 > > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/grub-devel > --089e0821ead80de03e05562a5e0f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


Le=C2= =A0Thu, Aug 3, 2017 =C3=A0=C2=A012:15 PM, Leif Lindholm <leif.lindholm@linaro.org> a =C3=A9crit= =C2=A0:
Use kernel header struct an= d generic magic definition to align with
arm64/linux loader.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
---
=C2=A0grub-core/loader/arm/linux.c | 11 +++++------
=C2=A0include/grub/arm/linux.h=C2=A0 =C2=A0 =C2=A0| 15 ++++++++++++---
=C2=A02 files changed, 17 insertions(+), 9 deletions(-)

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;

=C2=A0typedef void (*kernel_entry_t) (int, unsigned long, void *);

-#define LINUX_ZIMAGE_OFFSET=C2=A0 =C2=A0 0x24
-#define LINUX_ZIMAGE_MAGIC=C2=A0 =C2=A0 =C2=A00x016f2818
-
=C2=A0#define LINUX_PHYS_OFFSET=C2=A0 =C2=A0 =C2=A0 =C2=A0 (0x00008000)
=C2=A0#define LINUX_INITRD_PHYS_OFFSET (LINUX_PHYS_OFFSET + 0x02000000)
=C2=A0#define LINUX_FDT_PHYS_OFFSET=C2=A0 =C2=A0 (LINUX_INITRD_PHYS_OFFSET = - 0x10000)
@@ -315,6 +312,7 @@ linux_boot (void)
=C2=A0static grub_err_t
=C2=A0linux_load (const char *filename, grub_file_t file)
=C2=A0{
+=C2=A0 struct grub_linux_kernel_header *lh;
=C2=A0 =C2=A0int size;

=C2=A0 =C2=A0size =3D grub_file_size (file);
@@ -337,9 +335,10 @@ linux_load (const char *filename, grub_file_t file) =C2=A0 =C2=A0 =C2=A0 =C2=A0return grub_errno;
=C2=A0 =C2=A0 =C2=A0}

-=C2=A0 if (size > LINUX_ZIMAGE_OFFSET + 4
-=C2=A0 =C2=A0 =C2=A0 && *(grub_uint32_t *) (linux_addr + LINUX_ZIM= AGE_OFFSET)
-=C2=A0 =C2=A0 =C2=A0 =3D=3D LINUX_ZIMAGE_MAGIC)
+=C2=A0 lh =3D (void *) linux_addr;
+
+=C2=A0 if ((grub_size_t) size > sizeof (*lh) &&
+=C2=A0 =C2=A0 =C2=A0 lh->magic =3D=3D GRUB_LINUX_MAGIC_SIGNATURE)
=C2=A0 =C2=A0 =C2=A0;
=C2=A0 =C2=A0else if (size > 0x8000 && *(grub_uint32_t *) (linux= _addr) =3D=3D 0xea000006
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&& machine_type =3D=3D GRU= B_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 @@
=C2=A0#ifndef GRUB_LINUX_CPU_HEADER
=C2=A0#define GRUB_LINUX_CPU_HEADER 1

-#define LINUX_ZIMAGE_OFFSET 0x24
-#define LINUX_ZIMAGE_MAGIC=C2=A0 0x016f2818
-
=C2=A0#include "system.h"

+#define GRUB_LINUX_MAGIC_SIGNATURE 0x016f2818
+
+struct grub_linux_kernel_header {
This maz clash with= other architectures preventing including several architecture files in the= same file. We need it to create tools like grub-file .
+=C2=A0 grub_uint32_t code0;
+=C2=A0 grub_uint32_t reserved1[8];
+=C2=A0 grub_uint32_t magic;
+=C2=A0 grub_uint32_t start; /* _start */
+=C2=A0 grub_uint32_t end;=C2=A0 =C2=A0/* _edata */
+=C2=A0 grub_uint32_t reserved2[4];
+=C2=A0 grub_uint32_t hdr_offset;
+};
+
=C2=A0#if defined GRUB_MACHINE_UBOOT
=C2=A0# include <grub/uboot/uboot.h>
=C2=A0# define LINUX_ADDRESS=C2=A0 =C2=A0 =C2=A0 =C2=A0 (start_of_ram + 0x8= 000)
--
2.11.0


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org<= /a>
https://lists.gnu.org/mailman/listinfo/grub-devel
--089e0821ead80de03e05562a5e0f--