All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/10] various cleanup
@ 2018-02-01 18:18 Leif Lindholm
  2018-02-01 18:18 ` [PATCH 01/10] arm64/efi: move EFI_PAGE definitions to efi/memory.h Leif Lindholm
                   ` (10 more replies)
  0 siblings, 11 replies; 29+ messages in thread
From: Leif Lindholm @ 2018-02-01 18:18 UTC (permalink / raw)
  To: grub-devel; +Cc: Daniel Kiper

So, sorry I dropped the ball on this last year.

This series contains what I would hope to be non-contentious
cleanup in preparation for the functional changes (/fixes) for
the arm64 linux loader and its reuse in the arm-efi port.

   1/10 Simply moves the EFI_PAGE definition to <grub/efi/memory.h>.
 2-7/10 Cleans up and aligns the macro and struct naming for 
        <grub/cpu/linux.h>.
   8/10 Makes it possible to include <grub/arm/linux.h> in a non-native
        command or utility.
9-10/10 Switches to use the arm/arm64 kernel header structs in the
        "file" command".

Leif Lindholm (10):
  arm64/efi: move EFI_PAGE definitions to efi/memory.h
  Make arch-specific linux.h include guards architecture unique
  make GRUB_LINUX_MAGIC_SIGNATURE architecture-specific
  i386: make struct linux_kernel_header architecture specific
  arm64: align linux kernel header struct naming with i386
  arm64: align linux kernel magic macro naming with i386
  arm: switch linux loader to linux_arm_kernel_header struct
  arm: make linux.h safe to include for non-native builds
  commands/file: use definitions from arm/linux.h
  commands/file: use definitions from arm64/linux.h

 grub-core/commands/file.c         | 31 +++++++++++++++----------------
 grub-core/loader/arm/linux.c      | 11 +++++------
 grub-core/loader/arm64/linux.c    |  7 ++++---
 grub-core/loader/arm64/xen_boot.c |  5 +++--
 grub-core/loader/efi/fdt.c        |  1 +
 grub-core/loader/i386/linux.c     |  4 ++--
 grub-core/loader/i386/pc/linux.c  | 12 ++++++------
 grub-core/loader/i386/xen_file.c  |  4 ++--
 include/grub/arm/linux.h          | 25 +++++++++++++++++--------
 include/grub/arm64/linux.h        | 13 ++++++-------
 include/grub/efi/fdtload.h        |  3 ---
 include/grub/efi/memory.h         |  7 +++++++
 include/grub/i386/linux.h         | 10 +++++-----
 13 files changed, 73 insertions(+), 60 deletions(-)

-- 
2.11.0



^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 01/10] arm64/efi: move EFI_PAGE definitions to efi/memory.h
  2018-02-01 18:18 [PATCH 00/10] various cleanup Leif Lindholm
@ 2018-02-01 18:18 ` Leif Lindholm
  2018-02-15  9:57   ` Daniel Kiper
  2018-02-01 18:18 ` [PATCH 02/10] Make arch-specific linux.h include guards architecture unique Leif Lindholm
                   ` (9 subsequent siblings)
  10 siblings, 1 reply; 29+ messages in thread
From: Leif Lindholm @ 2018-02-01 18:18 UTC (permalink / raw)
  To: grub-devel; +Cc: Daniel Kiper

The EFI page definitions and macros are generic and should not be confined
to arm64 headers - so move to efi/memory.h.
Also add EFI_PAGE_SIZE macro.

Update loader sources to reflect new header location.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
---
 grub-core/loader/arm64/linux.c    | 1 +
 grub-core/loader/arm64/xen_boot.c | 1 +
 grub-core/loader/efi/fdt.c        | 1 +
 include/grub/efi/fdtload.h        | 3 ---
 include/grub/efi/memory.h         | 7 +++++++
 5 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c
index 746edd104..ca01a2349 100644
--- a/grub-core/loader/arm64/linux.c
+++ b/grub-core/loader/arm64/linux.c
@@ -28,6 +28,7 @@
 #include <grub/cpu/linux.h>
 #include <grub/efi/efi.h>
 #include <grub/efi/fdtload.h>
+#include <grub/efi/memory.h>
 #include <grub/efi/pe32.h>
 #include <grub/i18n.h>
 #include <grub/lib/cmdline.h>
diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c
index 6780b1f0c..0a40e16be 100644
--- a/grub-core/loader/arm64/xen_boot.c
+++ b/grub-core/loader/arm64/xen_boot.c
@@ -30,6 +30,7 @@
 #include <grub/cpu/linux.h>
 #include <grub/efi/efi.h>
 #include <grub/efi/fdtload.h>
+#include <grub/efi/memory.h>
 #include <grub/efi/pe32.h>	/* required by struct xen_hypervisor_header */
 #include <grub/i18n.h>
 #include <grub/lib/cmdline.h>
diff --git a/grub-core/loader/efi/fdt.c b/grub-core/loader/efi/fdt.c
index 17212c38d..c0c6800f7 100644
--- a/grub-core/loader/efi/fdt.c
+++ b/grub-core/loader/efi/fdt.c
@@ -24,6 +24,7 @@
 #include <grub/file.h>
 #include <grub/efi/efi.h>
 #include <grub/efi/fdtload.h>
+#include <grub/efi/memory.h>
 
 static void *loaded_fdt;
 static void *fdt;
diff --git a/include/grub/efi/fdtload.h b/include/grub/efi/fdtload.h
index 7b9ddba91..713c9424d 100644
--- a/include/grub/efi/fdtload.h
+++ b/include/grub/efi/fdtload.h
@@ -29,7 +29,4 @@ grub_fdt_unload (void);
 grub_err_t
 grub_fdt_install (void);
 
-#define GRUB_EFI_PAGE_SHIFT	12
-#define GRUB_EFI_BYTES_TO_PAGES(bytes)   (((bytes) + 0xfff) >> GRUB_EFI_PAGE_SHIFT)
-
 #endif
diff --git a/include/grub/efi/memory.h b/include/grub/efi/memory.h
index 20526b146..08fe62277 100644
--- a/include/grub/efi/memory.h
+++ b/include/grub/efi/memory.h
@@ -22,6 +22,13 @@
 #include <grub/err.h>
 #include <grub/types.h>
 
+/* The term "page" in UEFI refers only to a 4 KiB-aligned 4 KiB size region of
+   memory. It is not concerned with underlying translation management concepts,
+   but only used as the granule for memory allocations. */
+#define GRUB_EFI_PAGE_SHIFT             12
+#define GRUB_EFI_PAGE_SIZE              (1 << GRUB_EFI_PAGE_SHIFT)
+#define GRUB_EFI_BYTES_TO_PAGES(bytes)  (((bytes) + 0xfff) >> GRUB_EFI_PAGE_SHIFT)
+
 #define GRUB_MMAP_REGISTER_BY_FIRMWARE  1
 
 grub_err_t grub_machine_mmap_register (grub_uint64_t start, grub_uint64_t size,
-- 
2.11.0



^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 02/10] Make arch-specific linux.h include guards architecture unique
  2018-02-01 18:18 [PATCH 00/10] various cleanup Leif Lindholm
  2018-02-01 18:18 ` [PATCH 01/10] arm64/efi: move EFI_PAGE definitions to efi/memory.h Leif Lindholm
@ 2018-02-01 18:18 ` Leif Lindholm
  2018-02-15 10:00   ` Daniel Kiper
  2018-02-01 18:18 ` [PATCH 03/10] make GRUB_LINUX_MAGIC_SIGNATURE architecture-specific Leif Lindholm
                   ` (8 subsequent siblings)
  10 siblings, 1 reply; 29+ messages in thread
From: Leif Lindholm @ 2018-02-01 18:18 UTC (permalink / raw)
  To: grub-devel; +Cc: Daniel Kiper

Replace uses of GRUB_LINUX_MACHINE_HEADER and GRUB_LINUX_CPU_HEADER
with GRUB_<arch>_LINUX_HEADER include guards to prevent issues when
including more than one of them.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
---
 include/grub/arm/linux.h   | 6 +++---
 include/grub/arm64/linux.h | 6 +++---
 include/grub/i386/linux.h  | 6 +++---
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h
index f217f8281..3706c46c6 100644
--- a/include/grub/arm/linux.h
+++ b/include/grub/arm/linux.h
@@ -17,8 +17,8 @@
  *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef GRUB_LINUX_CPU_HEADER
-#define GRUB_LINUX_CPU_HEADER 1
+#ifndef GRUB_ARM_LINUX_HEADER
+#define GRUB_ARM_LINUX_HEADER 1
 
 #define LINUX_ZIMAGE_OFFSET 0x24
 #define LINUX_ZIMAGE_MAGIC  0x016f2818
@@ -66,4 +66,4 @@ grub_arm_firmware_get_machine_type (void)
 
 #define FDT_ADDITIONAL_ENTRIES_SIZE	0x300
 
-#endif /* ! GRUB_LINUX_CPU_HEADER */
+#endif /* ! GRUB_ARM_LINUX_HEADER */
diff --git a/include/grub/arm64/linux.h b/include/grub/arm64/linux.h
index a981df5d1..a8edf50dc 100644
--- a/include/grub/arm64/linux.h
+++ b/include/grub/arm64/linux.h
@@ -16,8 +16,8 @@
  *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef GRUB_LINUX_CPU_HEADER
-#define GRUB_LINUX_CPU_HEADER 1
+#ifndef GRUB_ARM64_LINUX_HEADER
+#define GRUB_ARM64_LINUX_HEADER 1
 
 #include <grub/efi/efi.h>
 
@@ -43,4 +43,4 @@ grub_err_t grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header
 grub_err_t grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size,
                                        char *args);
 
-#endif /* ! GRUB_LINUX_CPU_HEADER */
+#endif /* ! GRUB_ARM64_LINUX_HEADER */
diff --git a/include/grub/i386/linux.h b/include/grub/i386/linux.h
index da0ca3b83..2ff1621a4 100644
--- a/include/grub/i386/linux.h
+++ b/include/grub/i386/linux.h
@@ -16,8 +16,8 @@
  *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef GRUB_LINUX_MACHINE_HEADER
-#define GRUB_LINUX_MACHINE_HEADER	1
+#ifndef GRUB_I386_LINUX_HEADER
+#define GRUB_I386_LINUX_HEADER	1
 
 #define GRUB_LINUX_MAGIC_SIGNATURE	0x53726448      /* "HdrS" */
 #define GRUB_LINUX_DEFAULT_SETUP_SECTS	4
@@ -312,4 +312,4 @@ struct linux_kernel_params
 } GRUB_PACKED;
 #endif /* ! ASM_FILE */
 
-#endif /* ! GRUB_LINUX_MACHINE_HEADER */
+#endif /* ! GRUB_I386_LINUX_HEADER */
-- 
2.11.0



^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 03/10] make GRUB_LINUX_MAGIC_SIGNATURE architecture-specific
  2018-02-01 18:18 [PATCH 00/10] various cleanup Leif Lindholm
  2018-02-01 18:18 ` [PATCH 01/10] arm64/efi: move EFI_PAGE definitions to efi/memory.h Leif Lindholm
  2018-02-01 18:18 ` [PATCH 02/10] Make arch-specific linux.h include guards architecture unique Leif Lindholm
@ 2018-02-01 18:18 ` Leif Lindholm
  2018-02-15 10:05   ` Daniel Kiper
  2018-02-01 18:18 ` [PATCH 04/10] i386: make struct linux_kernel_header architecture specific Leif Lindholm
                   ` (7 subsequent siblings)
  10 siblings, 1 reply; 29+ messages in thread
From: Leif Lindholm @ 2018-02-01 18:18 UTC (permalink / raw)
  To: grub-devel; +Cc: Daniel Kiper

Rename GRUB_LINUX_MAGIC_SIGNATURE GRUB_LINUX_I386_MAGIC_SIGNATURE,
to be usable in code that supports more than one image type.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
---
 grub-core/commands/file.c        | 4 ++--
 grub-core/loader/i386/linux.c    | 2 +-
 grub-core/loader/i386/pc/linux.c | 6 +++---
 grub-core/loader/i386/xen_file.c | 2 +-
 include/grub/i386/linux.h        | 2 +-
 5 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/grub-core/commands/file.c b/grub-core/commands/file.c
index 12fba99e0..474666d3a 100644
--- a/grub-core/commands/file.c
+++ b/grub-core/commands/file.c
@@ -508,7 +508,7 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
 
 	/* FIXME: some really old kernels (< 1.3.73) will fail this.  */
 	if (lh.header !=
-	    grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE)
+	    grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE)
 	    || grub_le_to_cpu16 (lh.version) < 0x0200)
 	  break;
 
@@ -521,7 +521,7 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
 	/* FIXME: 2.03 is not always good enough (Linux 2.4 can be 2.03 and
 	   still not support 32-bit boot.  */
 	if (lh.header !=
-	    grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE)
+	    grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE)
 	    || grub_le_to_cpu16 (lh.version) < 0x0203)
 	  break;
 
diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c
index 083f9417c..9bd5afb65 100644
--- a/grub-core/loader/i386/linux.c
+++ b/grub-core/loader/i386/linux.c
@@ -721,7 +721,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
 
   /* FIXME: 2.03 is not always good enough (Linux 2.4 can be 2.03 and
      still not support 32-bit boot.  */
-  if (lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE)
+  if (lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE)
       || grub_le_to_cpu16 (lh.version) < 0x0203)
     {
       grub_error (GRUB_ERR_BAD_OS, "version too old for 32-bit boot"
diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c
index a293b17aa..31a687644 100644
--- a/grub-core/loader/i386/pc/linux.c
+++ b/grub-core/loader/i386/pc/linux.c
@@ -169,7 +169,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
 
   maximal_cmdline_size = 256;
 
-  if (lh.header == grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE)
+  if (lh.header == grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE)
       && grub_le_to_cpu16 (lh.version) >= 0x0200)
     {
       grub_linux_is_bzimage = (lh.loadflags & GRUB_LINUX_FLAG_BIG_KERNEL);
@@ -322,7 +322,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
       goto fail;
     }
 
-  if (lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE)
+  if (lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE)
       || grub_le_to_cpu16 (lh.version) < 0x0200)
     /* Clear the heap space.  */
     grub_memset (grub_linux_real_chunk
@@ -407,7 +407,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
 
   lh = (struct linux_kernel_header *) grub_linux_real_chunk;
 
-  if (!(lh->header == grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE)
+  if (!(lh->header == grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE)
 	&& grub_le_to_cpu16 (lh->version) >= 0x0200))
     {
       grub_error (GRUB_ERR_BAD_OS, "the kernel is too old for initrd");
diff --git a/grub-core/loader/i386/xen_file.c b/grub-core/loader/i386/xen_file.c
index 99fad4cad..6e76e16aa 100644
--- a/grub-core/loader/i386/xen_file.c
+++ b/grub-core/loader/i386/xen_file.c
@@ -43,7 +43,7 @@ grub_xen_file (grub_file_t file)
     goto fail;
 
   if (lh.boot_flag != grub_cpu_to_le16_compile_time (0xaa55)
-      || lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE)
+      || lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE)
       || grub_le_to_cpu16 (lh.version) < 0x0208)
     {
       grub_error (GRUB_ERR_BAD_OS, "version too old for xen boot");
diff --git a/include/grub/i386/linux.h b/include/grub/i386/linux.h
index 2ff1621a4..3ff432be9 100644
--- a/include/grub/i386/linux.h
+++ b/include/grub/i386/linux.h
@@ -19,7 +19,7 @@
 #ifndef GRUB_I386_LINUX_HEADER
 #define GRUB_I386_LINUX_HEADER	1
 
-#define GRUB_LINUX_MAGIC_SIGNATURE	0x53726448      /* "HdrS" */
+#define GRUB_LINUX_I386_MAGIC_SIGNATURE	0x53726448      /* "HdrS" */
 #define GRUB_LINUX_DEFAULT_SETUP_SECTS	4
 #define GRUB_LINUX_INITRD_MAX_ADDRESS	0x37FFFFFF
 #define GRUB_LINUX_MAX_SETUP_SECTS	64
-- 
2.11.0



^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 04/10] i386: make struct linux_kernel_header architecture specific
  2018-02-01 18:18 [PATCH 00/10] various cleanup Leif Lindholm
                   ` (2 preceding siblings ...)
  2018-02-01 18:18 ` [PATCH 03/10] make GRUB_LINUX_MAGIC_SIGNATURE architecture-specific Leif Lindholm
@ 2018-02-01 18:18 ` Leif Lindholm
  2018-02-15 10:06   ` Daniel Kiper
  2018-02-01 18:18 ` [PATCH 05/10] arm64: align linux kernel header struct naming with i386 Leif Lindholm
                   ` (6 subsequent siblings)
  10 siblings, 1 reply; 29+ messages in thread
From: Leif Lindholm @ 2018-02-01 18:18 UTC (permalink / raw)
  To: grub-devel; +Cc: Daniel Kiper

struct linux_kernel_header -> struct linux_i386_kernel_header

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
---
 grub-core/commands/file.c        | 2 +-
 grub-core/loader/i386/linux.c    | 2 +-
 grub-core/loader/i386/pc/linux.c | 6 +++---
 grub-core/loader/i386/xen_file.c | 2 +-
 include/grub/i386/linux.h        | 2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/grub-core/commands/file.c b/grub-core/commands/file.c
index 474666d3a..63c84499b 100644
--- a/grub-core/commands/file.c
+++ b/grub-core/commands/file.c
@@ -497,7 +497,7 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
     case IS_X86_LINUX32:
     case IS_X86_LINUX:
       {
-	struct linux_kernel_header lh;
+	struct linux_i386_kernel_header lh;
 	if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh))
 	  break;
 	if (lh.boot_flag != grub_cpu_to_le16_compile_time (0xaa55))
diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c
index 9bd5afb65..44301e126 100644
--- a/grub-core/loader/i386/linux.c
+++ b/grub-core/loader/i386/linux.c
@@ -678,7 +678,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
 		int argc, char *argv[])
 {
   grub_file_t file = 0;
-  struct linux_kernel_header lh;
+  struct linux_i386_kernel_header lh;
   grub_uint8_t setup_sects;
   grub_size_t real_size, prot_size, prot_file_size;
   grub_ssize_t len;
diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c
index 31a687644..b69cb7a3a 100644
--- a/grub-core/loader/i386/pc/linux.c
+++ b/grub-core/loader/i386/pc/linux.c
@@ -121,7 +121,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
 		int argc, char *argv[])
 {
   grub_file_t file = 0;
-  struct linux_kernel_header lh;
+  struct linux_i386_kernel_header lh;
   grub_uint8_t setup_sects;
   grub_size_t real_size;
   grub_ssize_t len;
@@ -387,7 +387,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
 {
   grub_size_t size = 0;
   grub_addr_t addr_max, addr_min;
-  struct linux_kernel_header *lh;
+  struct linux_i386_kernel_header *lh;
   grub_uint8_t *initrd_chunk;
   grub_addr_t initrd_addr;
   grub_err_t err;
@@ -405,7 +405,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
       goto fail;
     }
 
-  lh = (struct linux_kernel_header *) grub_linux_real_chunk;
+  lh = (struct linux_i386_kernel_header *) grub_linux_real_chunk;
 
   if (!(lh->header == grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE)
 	&& grub_le_to_cpu16 (lh->version) >= 0x0200))
diff --git a/grub-core/loader/i386/xen_file.c b/grub-core/loader/i386/xen_file.c
index 6e76e16aa..77a93e7b2 100644
--- a/grub-core/loader/i386/xen_file.c
+++ b/grub-core/loader/i386/xen_file.c
@@ -26,7 +26,7 @@ grub_elf_t
 grub_xen_file (grub_file_t file)
 {
   grub_elf_t elf;
-  struct linux_kernel_header lh;
+  struct linux_i386_kernel_header lh;
   grub_file_t off_file;
   grub_uint32_t payload_offset, payload_length;
   grub_uint8_t magic[6];
diff --git a/include/grub/i386/linux.h b/include/grub/i386/linux.h
index 3ff432be9..0bd758817 100644
--- a/include/grub/i386/linux.h
+++ b/include/grub/i386/linux.h
@@ -85,7 +85,7 @@ enum
   };
 
 /* For the Linux/i386 boot protocol version 2.10.  */
-struct linux_kernel_header
+struct linux_i386_kernel_header
 {
   grub_uint8_t code1[0x0020];
   grub_uint16_t cl_magic;		/* Magic number 0xA33F */
-- 
2.11.0



^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 05/10] arm64: align linux kernel header struct naming with i386
  2018-02-01 18:18 [PATCH 00/10] various cleanup Leif Lindholm
                   ` (3 preceding siblings ...)
  2018-02-01 18:18 ` [PATCH 04/10] i386: make struct linux_kernel_header architecture specific Leif Lindholm
@ 2018-02-01 18:18 ` Leif Lindholm
  2018-02-15 10:09   ` Daniel Kiper
  2018-02-01 18:18 ` [PATCH 06/10] arm64: align linux kernel magic macro " Leif Lindholm
                   ` (5 subsequent siblings)
  10 siblings, 1 reply; 29+ messages in thread
From: Leif Lindholm @ 2018-02-01 18:18 UTC (permalink / raw)
  To: grub-devel; +Cc: Daniel Kiper

Rename struct grub_arm64_linux_kernel_header -> linux_arm64_kernel_header.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
---
 grub-core/loader/arm64/linux.c    | 4 ++--
 grub-core/loader/arm64/xen_boot.c | 4 ++--
 include/grub/arm64/linux.h        | 5 ++---
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c
index ca01a2349..79f25a711 100644
--- a/grub-core/loader/arm64/linux.c
+++ b/grub-core/loader/arm64/linux.c
@@ -48,7 +48,7 @@ static grub_addr_t initrd_start;
 static grub_addr_t initrd_end;
 
 grub_err_t
-grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header * lh)
+grub_arm64_uefi_check_image (struct linux_arm64_kernel_header * lh)
 {
   if (lh->magic != GRUB_ARM64_LINUX_MAGIC)
     return grub_error(GRUB_ERR_BAD_OS, "invalid magic number");
@@ -249,7 +249,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
 		int argc, char *argv[])
 {
   grub_file_t file = 0;
-  struct grub_arm64_linux_kernel_header lh;
+  struct linux_arm64_kernel_header lh;
 
   grub_dl_ref (my_mod);
 
diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c
index 0a40e16be..258264c79 100644
--- a/grub-core/loader/arm64/xen_boot.c
+++ b/grub-core/loader/arm64/xen_boot.c
@@ -67,7 +67,7 @@ typedef enum module_type module_type_t;
 
 struct xen_hypervisor_header
 {
-  struct grub_arm64_linux_kernel_header efi_head;
+  struct linux_arm64_kernel_header efi_head;
 
   /* This is always PE\0\0.  */
   grub_uint8_t signature[GRUB_PE32_SIGNATURE_SIZE];
@@ -469,7 +469,7 @@ grub_cmd_xen_hypervisor (grub_command_t cmd __attribute__ ((unused)),
   if (grub_file_read (file, &sh, sizeof (sh)) != (long) sizeof (sh))
     goto fail;
   if (grub_arm64_uefi_check_image
-      ((struct grub_arm64_linux_kernel_header *) &sh) != GRUB_ERR_NONE)
+      ((struct linux_arm64_kernel_header *) &sh) != GRUB_ERR_NONE)
     goto fail;
   grub_file_seek (file, 0);
 
diff --git a/include/grub/arm64/linux.h b/include/grub/arm64/linux.h
index a8edf50dc..abe7e9cc3 100644
--- a/include/grub/arm64/linux.h
+++ b/include/grub/arm64/linux.h
@@ -24,7 +24,7 @@
 #define GRUB_ARM64_LINUX_MAGIC 0x644d5241 /* 'ARM\x64' */
 
 /* From linux/Documentation/arm64/booting.txt */
-struct grub_arm64_linux_kernel_header
+struct linux_arm64_kernel_header
 {
   grub_uint32_t code0;		/* Executable code */
   grub_uint32_t code1;		/* Executable code */
@@ -38,8 +38,7 @@ struct grub_arm64_linux_kernel_header
   grub_uint32_t hdr_offset;	/* Offset of PE/COFF header */
 };
 
-grub_err_t grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header
-                                        *lh);
+grub_err_t grub_arm64_uefi_check_image (struct linux_arm64_kernel_header *lh);
 grub_err_t grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size,
                                        char *args);
 
-- 
2.11.0



^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 06/10] arm64: align linux kernel magic macro naming with i386
  2018-02-01 18:18 [PATCH 00/10] various cleanup Leif Lindholm
                   ` (4 preceding siblings ...)
  2018-02-01 18:18 ` [PATCH 05/10] arm64: align linux kernel header struct naming with i386 Leif Lindholm
@ 2018-02-01 18:18 ` Leif Lindholm
  2018-02-15 10:12   ` Daniel Kiper
  2018-02-01 18:18 ` [PATCH 07/10] arm: switch linux loader to linux_arm_kernel_header struct Leif Lindholm
                   ` (4 subsequent siblings)
  10 siblings, 1 reply; 29+ messages in thread
From: Leif Lindholm @ 2018-02-01 18:18 UTC (permalink / raw)
  To: grub-devel; +Cc: Daniel Kiper

Change GRUB_ARM64_LINUX_MAGIC to GRUB_LINUX_ARM64_MAGIC_SIGNATURE.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
---
 grub-core/loader/arm64/linux.c | 2 +-
 include/grub/arm64/linux.h     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c
index 79f25a711..ebe1e730d 100644
--- a/grub-core/loader/arm64/linux.c
+++ b/grub-core/loader/arm64/linux.c
@@ -50,7 +50,7 @@ static grub_addr_t initrd_end;
 grub_err_t
 grub_arm64_uefi_check_image (struct linux_arm64_kernel_header * lh)
 {
-  if (lh->magic != GRUB_ARM64_LINUX_MAGIC)
+  if (lh->magic != GRUB_LINUX_ARM64_MAGIC_SIGNATURE)
     return grub_error(GRUB_ERR_BAD_OS, "invalid magic number");
 
   if ((lh->code0 & 0xffff) != GRUB_PE32_MAGIC)
diff --git a/include/grub/arm64/linux.h b/include/grub/arm64/linux.h
index abe7e9cc3..b06347624 100644
--- a/include/grub/arm64/linux.h
+++ b/include/grub/arm64/linux.h
@@ -21,7 +21,7 @@
 
 #include <grub/efi/efi.h>
 
-#define GRUB_ARM64_LINUX_MAGIC 0x644d5241 /* 'ARM\x64' */
+#define GRUB_LINUX_ARM64_MAGIC_SIGNATURE 0x644d5241 /* 'ARM\x64' */
 
 /* From linux/Documentation/arm64/booting.txt */
 struct linux_arm64_kernel_header
-- 
2.11.0



^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 07/10] arm: switch linux loader to linux_arm_kernel_header struct
  2018-02-01 18:18 [PATCH 00/10] various cleanup Leif Lindholm
                   ` (5 preceding siblings ...)
  2018-02-01 18:18 ` [PATCH 06/10] arm64: align linux kernel magic macro " Leif Lindholm
@ 2018-02-01 18:18 ` Leif Lindholm
  2018-02-15 10:21   ` Daniel Kiper
  2018-02-01 18:18 ` [PATCH 08/10] arm: make linux.h safe to include for non-native builds Leif Lindholm
                   ` (3 subsequent siblings)
  10 siblings, 1 reply; 29+ messages in thread
From: Leif Lindholm @ 2018-02-01 18:18 UTC (permalink / raw)
  To: grub-devel; +Cc: Daniel Kiper

Use kernel header struct and magic definition to align (and coexist) with
i386/arm64 ports.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
---
 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..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 <grub/uboot/uboot.h>
 # define LINUX_ADDRESS        (start_of_ram + 0x8000)
-- 
2.11.0



^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 08/10] arm: make linux.h safe to include for non-native builds
  2018-02-01 18:18 [PATCH 00/10] various cleanup Leif Lindholm
                   ` (6 preceding siblings ...)
  2018-02-01 18:18 ` [PATCH 07/10] arm: switch linux loader to linux_arm_kernel_header struct Leif Lindholm
@ 2018-02-01 18:18 ` Leif Lindholm
  2018-02-15 10:25   ` Daniel Kiper
  2018-02-01 18:18 ` [PATCH 09/10] commands/file: use definitions from arm/linux.h Leif Lindholm
                   ` (2 subsequent siblings)
  10 siblings, 1 reply; 29+ messages in thread
From: Leif Lindholm @ 2018-02-01 18:18 UTC (permalink / raw)
  To: grub-devel; +Cc: Daniel Kiper

<grub/machine/loader.h> (for machine arm/efi) and
<grub/machine/kernel.h> (for machine arm/coreboot) will not always
resolve (and will likely not be valid to) if pulled in when building
non-native commands, such as host tools or the "file" command.
So explicitly include them with their expanded pathnames.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
---
 include/grub/arm/linux.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h
index 64dd3173c..cceb9c4a9 100644
--- a/include/grub/arm/linux.h
+++ b/include/grub/arm/linux.h
@@ -43,7 +43,7 @@ struct linux_arm_kernel_header {
 # define grub_arm_firmware_get_machine_type grub_uboot_get_machine_type
 #elif defined GRUB_MACHINE_EFI
 # include <grub/efi/efi.h>
-# include <grub/machine/loader.h>
+# include <grub/arm/efi/loader.h>
 /* On UEFI platforms - load the images at the lowest available address not
    less than *_PHYS_OFFSET from the first available memory location. */
 # define LINUX_PHYS_OFFSET        (0x00008000)
@@ -57,7 +57,7 @@ grub_arm_firmware_get_machine_type (void)
 }
 #elif defined (GRUB_MACHINE_COREBOOT)
 #include <grub/fdtbus.h>
-#include <grub/machine/kernel.h>
+#include <grub/arm/coreboot/kernel.h>
 # define LINUX_ADDRESS        (start_of_ram + 0x8000)
 # define LINUX_INITRD_ADDRESS (start_of_ram + 0x02000000)
 # define LINUX_FDT_ADDRESS    (LINUX_INITRD_ADDRESS - 0x10000)
-- 
2.11.0



^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 09/10] commands/file: use definitions from arm/linux.h
  2018-02-01 18:18 [PATCH 00/10] various cleanup Leif Lindholm
                   ` (7 preceding siblings ...)
  2018-02-01 18:18 ` [PATCH 08/10] arm: make linux.h safe to include for non-native builds Leif Lindholm
@ 2018-02-01 18:18 ` Leif Lindholm
  2018-02-15 10:30   ` Daniel Kiper
  2018-02-01 18:18 ` [PATCH 10/10] commands/file: use definitions from arm64/linux.h Leif Lindholm
  2018-02-15 10:34 ` [PATCH 00/10] various cleanup Daniel Kiper
  10 siblings, 1 reply; 29+ messages in thread
From: Leif Lindholm @ 2018-02-01 18:18 UTC (permalink / raw)
  To: grub-devel; +Cc: Daniel Kiper

Clean up code for matching IS_ARM slightly by making use of struct
linux_arm_kernel_header and GRUB_LINUX_ARM_MAGIC_SIGNATURE.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
---
 grub-core/commands/file.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/grub-core/commands/file.c b/grub-core/commands/file.c
index 63c84499b..fad191202 100644
--- a/grub-core/commands/file.c
+++ b/grub-core/commands/file.c
@@ -27,6 +27,7 @@
 #include <grub/elf.h>
 #include <grub/xen_file.h>
 #include <grub/efi/pe32.h>
+#include <grub/arm/linux.h>
 #include <grub/i386/linux.h>
 #include <grub/xnu.h>
 #include <grub/machoload.h>
@@ -383,21 +384,18 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
       }
     case IS_ARM_LINUX:
       {
-	grub_uint32_t sig, sig_pi;
-	if (grub_file_read (file, &sig_pi, 4) != 4)
+	struct linux_arm_kernel_header lh;
+	if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh))
 	  break;
 	/* Raspberry pi.  */
-	if (sig_pi == grub_cpu_to_le32_compile_time (0xea000006))
+	if (lh.code0 == grub_cpu_to_le32_compile_time (0xea000006))
 	  {
 	    ret = 1;
 	    break;
 	  }
 
-	if (grub_file_seek (file, 0x24) == (grub_size_t) -1)
-	  break;
-	if (grub_file_read (file, &sig, 4) != 4)
-	  break;
-	if (sig == grub_cpu_to_le32_compile_time (0x016f2818))
+	if (lh.magic ==
+	    grub_cpu_to_le32_compile_time (GRUB_LINUX_ARM_MAGIC_SIGNATURE))
 	  {
 	    ret = 1;
 	    break;
-- 
2.11.0



^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 10/10] commands/file: use definitions from arm64/linux.h
  2018-02-01 18:18 [PATCH 00/10] various cleanup Leif Lindholm
                   ` (8 preceding siblings ...)
  2018-02-01 18:18 ` [PATCH 09/10] commands/file: use definitions from arm/linux.h Leif Lindholm
@ 2018-02-01 18:18 ` Leif Lindholm
  2018-02-15 10:31   ` Daniel Kiper
  2018-02-15 10:34 ` [PATCH 00/10] various cleanup Daniel Kiper
  10 siblings, 1 reply; 29+ messages in thread
From: Leif Lindholm @ 2018-02-01 18:18 UTC (permalink / raw)
  To: grub-devel; +Cc: Daniel Kiper

Clean up code for matching IS_ARM64 slightly by making use of struct
linux_arm_kernel_header and GRUB_LINUX_ARM64_MAGIC_SIGNATURE.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
---
 grub-core/commands/file.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/grub-core/commands/file.c b/grub-core/commands/file.c
index fad191202..dd729a8a8 100644
--- a/grub-core/commands/file.c
+++ b/grub-core/commands/file.c
@@ -28,6 +28,7 @@
 #include <grub/xen_file.h>
 #include <grub/efi/pe32.h>
 #include <grub/arm/linux.h>
+#include <grub/arm64/linux.h>
 #include <grub/i386/linux.h>
 #include <grub/xnu.h>
 #include <grub/machoload.h>
@@ -404,13 +405,13 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
       }
     case IS_ARM64_LINUX:
       {
-	grub_uint32_t sig;
+	struct linux_arm64_kernel_header lh;
 
-	if (grub_file_seek (file, 0x38) == (grub_size_t) -1)
-	  break;
-	if (grub_file_read (file, &sig, 4) != 4)
+	if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh))
 	  break;
-	if (sig == grub_cpu_to_le32_compile_time (0x644d5241))
+
+	if (lh.magic ==
+	    grub_cpu_to_le32_compile_time (GRUB_LINUX_ARM64_MAGIC_SIGNATURE))
 	  {
 	    ret = 1;
 	    break;
-- 
2.11.0



^ permalink raw reply related	[flat|nested] 29+ messages in thread

* Re: [PATCH 01/10] arm64/efi: move EFI_PAGE definitions to efi/memory.h
  2018-02-01 18:18 ` [PATCH 01/10] arm64/efi: move EFI_PAGE definitions to efi/memory.h Leif Lindholm
@ 2018-02-15  9:57   ` Daniel Kiper
  0 siblings, 0 replies; 29+ messages in thread
From: Daniel Kiper @ 2018-02-15  9:57 UTC (permalink / raw)
  To: Leif Lindholm; +Cc: grub-devel

On Thu, Feb 01, 2018 at 06:18:49PM +0000, Leif Lindholm wrote:
> The EFI page definitions and macros are generic and should not be confined
> to arm64 headers - so move to efi/memory.h.
> Also add EFI_PAGE_SIZE macro.
>
> Update loader sources to reflect new header location.
>
> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>

Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>

Daniel


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 02/10] Make arch-specific linux.h include guards architecture unique
  2018-02-01 18:18 ` [PATCH 02/10] Make arch-specific linux.h include guards architecture unique Leif Lindholm
@ 2018-02-15 10:00   ` Daniel Kiper
  0 siblings, 0 replies; 29+ messages in thread
From: Daniel Kiper @ 2018-02-15 10:00 UTC (permalink / raw)
  To: Leif Lindholm; +Cc: grub-devel

On Thu, Feb 01, 2018 at 06:18:50PM +0000, Leif Lindholm wrote:
> Replace uses of GRUB_LINUX_MACHINE_HEADER and GRUB_LINUX_CPU_HEADER
> with GRUB_<arch>_LINUX_HEADER include guards to prevent issues when
> including more than one of them.
>
> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>

Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>

Daniel


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 03/10] make GRUB_LINUX_MAGIC_SIGNATURE architecture-specific
  2018-02-01 18:18 ` [PATCH 03/10] make GRUB_LINUX_MAGIC_SIGNATURE architecture-specific Leif Lindholm
@ 2018-02-15 10:05   ` Daniel Kiper
  2018-02-15 10:39     ` Leif Lindholm
  0 siblings, 1 reply; 29+ messages in thread
From: Daniel Kiper @ 2018-02-15 10:05 UTC (permalink / raw)
  To: Leif Lindholm; +Cc: grub-devel

On Thu, Feb 01, 2018 at 06:18:51PM +0000, Leif Lindholm wrote:
> Rename GRUB_LINUX_MAGIC_SIGNATURE GRUB_LINUX_I386_MAGIC_SIGNATURE,

Missing "to" between GRUB_LINUX_MAGIC_SIGNATURE and GRUB_LINUX_I386_MAGIC_SIGNATURE.
I will fix it during commit.

> to be usable in code that supports more than one image type.
>
> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>

Otherwise Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>

Daniel


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 04/10] i386: make struct linux_kernel_header architecture specific
  2018-02-01 18:18 ` [PATCH 04/10] i386: make struct linux_kernel_header architecture specific Leif Lindholm
@ 2018-02-15 10:06   ` Daniel Kiper
  0 siblings, 0 replies; 29+ messages in thread
From: Daniel Kiper @ 2018-02-15 10:06 UTC (permalink / raw)
  To: Leif Lindholm; +Cc: grub-devel

On Thu, Feb 01, 2018 at 06:18:52PM +0000, Leif Lindholm wrote:
> struct linux_kernel_header -> struct linux_i386_kernel_header
>
> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>

Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>

Daniel


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 05/10] arm64: align linux kernel header struct naming with i386
  2018-02-01 18:18 ` [PATCH 05/10] arm64: align linux kernel header struct naming with i386 Leif Lindholm
@ 2018-02-15 10:09   ` Daniel Kiper
  0 siblings, 0 replies; 29+ messages in thread
From: Daniel Kiper @ 2018-02-15 10:09 UTC (permalink / raw)
  To: Leif Lindholm; +Cc: grub-devel

On Thu, Feb 01, 2018 at 06:18:53PM +0000, Leif Lindholm wrote:
> Rename struct grub_arm64_linux_kernel_header -> linux_arm64_kernel_header.
>
> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>

Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>

Daniel


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 06/10] arm64: align linux kernel magic macro naming with i386
  2018-02-01 18:18 ` [PATCH 06/10] arm64: align linux kernel magic macro " Leif Lindholm
@ 2018-02-15 10:12   ` Daniel Kiper
  0 siblings, 0 replies; 29+ messages in thread
From: Daniel Kiper @ 2018-02-15 10:12 UTC (permalink / raw)
  To: Leif Lindholm; +Cc: grub-devel

On Thu, Feb 01, 2018 at 06:18:54PM +0000, Leif Lindholm wrote:
> Change GRUB_ARM64_LINUX_MAGIC to GRUB_LINUX_ARM64_MAGIC_SIGNATURE.
>
> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>

Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>

Daniel


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 07/10] arm: switch linux loader to linux_arm_kernel_header struct
  2018-02-01 18:18 ` [PATCH 07/10] arm: switch linux loader to linux_arm_kernel_header struct Leif Lindholm
@ 2018-02-15 10:21   ` Daniel Kiper
  0 siblings, 0 replies; 29+ messages in thread
From: Daniel Kiper @ 2018-02-15 10:21 UTC (permalink / raw)
  To: Leif Lindholm; +Cc: grub-devel

On Thu, Feb 01, 2018 at 06:18:55PM +0000, Leif Lindholm wrote:
> Use kernel header struct and magic definition to align (and coexist) with
> i386/arm64 ports.
>
> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>

Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>

Daniel


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 08/10] arm: make linux.h safe to include for non-native builds
  2018-02-01 18:18 ` [PATCH 08/10] arm: make linux.h safe to include for non-native builds Leif Lindholm
@ 2018-02-15 10:25   ` Daniel Kiper
  0 siblings, 0 replies; 29+ messages in thread
From: Daniel Kiper @ 2018-02-15 10:25 UTC (permalink / raw)
  To: Leif Lindholm; +Cc: grub-devel

On Thu, Feb 01, 2018 at 06:18:56PM +0000, Leif Lindholm wrote:
> <grub/machine/loader.h> (for machine arm/efi) and
> <grub/machine/kernel.h> (for machine arm/coreboot) will not always
> resolve (and will likely not be valid to) if pulled in when building
> non-native commands, such as host tools or the "file" command.
> So explicitly include them with their expanded pathnames.
>
> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>

Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>

Daniel


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 09/10] commands/file: use definitions from arm/linux.h
  2018-02-01 18:18 ` [PATCH 09/10] commands/file: use definitions from arm/linux.h Leif Lindholm
@ 2018-02-15 10:30   ` Daniel Kiper
  2018-02-27 12:36     ` Leif Lindholm
  0 siblings, 1 reply; 29+ messages in thread
From: Daniel Kiper @ 2018-02-15 10:30 UTC (permalink / raw)
  To: Leif Lindholm; +Cc: grub-devel

On Thu, Feb 01, 2018 at 06:18:57PM +0000, Leif Lindholm wrote:
> Clean up code for matching IS_ARM slightly by making use of struct
> linux_arm_kernel_header and GRUB_LINUX_ARM_MAGIC_SIGNATURE.
>
> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> ---
>  grub-core/commands/file.c | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/grub-core/commands/file.c b/grub-core/commands/file.c
> index 63c84499b..fad191202 100644
> --- a/grub-core/commands/file.c
> +++ b/grub-core/commands/file.c
> @@ -27,6 +27,7 @@
>  #include <grub/elf.h>
>  #include <grub/xen_file.h>
>  #include <grub/efi/pe32.h>
> +#include <grub/arm/linux.h>
>  #include <grub/i386/linux.h>
>  #include <grub/xnu.h>
>  #include <grub/machoload.h>
> @@ -383,21 +384,18 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
>        }
>      case IS_ARM_LINUX:
>        {
> -	grub_uint32_t sig, sig_pi;
> -	if (grub_file_read (file, &sig_pi, 4) != 4)
> +	struct linux_arm_kernel_header lh;
> +	if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh))
>  	  break;
>  	/* Raspberry pi.  */
> -	if (sig_pi == grub_cpu_to_le32_compile_time (0xea000006))
> +	if (lh.code0 == grub_cpu_to_le32_compile_time (0xea000006))

Could you define 0xea000006 as a constant? If you add the comment
what does it mean that will be perfect.

Daniel


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 10/10] commands/file: use definitions from arm64/linux.h
  2018-02-01 18:18 ` [PATCH 10/10] commands/file: use definitions from arm64/linux.h Leif Lindholm
@ 2018-02-15 10:31   ` Daniel Kiper
  0 siblings, 0 replies; 29+ messages in thread
From: Daniel Kiper @ 2018-02-15 10:31 UTC (permalink / raw)
  To: Leif Lindholm; +Cc: grub-devel

On Thu, Feb 01, 2018 at 06:18:58PM +0000, Leif Lindholm wrote:
> Clean up code for matching IS_ARM64 slightly by making use of struct
> linux_arm_kernel_header and GRUB_LINUX_ARM64_MAGIC_SIGNATURE.
>
> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>

Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>

Daniel


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 00/10] various cleanup
  2018-02-01 18:18 [PATCH 00/10] various cleanup Leif Lindholm
                   ` (9 preceding siblings ...)
  2018-02-01 18:18 ` [PATCH 10/10] commands/file: use definitions from arm64/linux.h Leif Lindholm
@ 2018-02-15 10:34 ` Daniel Kiper
  2018-02-23 22:11   ` Daniel Kiper
  10 siblings, 1 reply; 29+ messages in thread
From: Daniel Kiper @ 2018-02-15 10:34 UTC (permalink / raw)
  To: Leif Lindholm; +Cc: grub-devel

Sorry for delay.

On Thu, Feb 01, 2018 at 06:18:48PM +0000, Leif Lindholm wrote:
> So, sorry I dropped the ball on this last year.
>
> This series contains what I would hope to be non-contentious
> cleanup in preparation for the functional changes (/fixes) for
> the arm64 linux loader and its reuse in the arm-efi port.
>
>    1/10 Simply moves the EFI_PAGE definition to <grub/efi/memory.h>.
>  2-7/10 Cleans up and aligns the macro and struct naming for
>         <grub/cpu/linux.h>.
>    8/10 Makes it possible to include <grub/arm/linux.h> in a non-native
>         command or utility.
> 9-10/10 Switches to use the arm/arm64 kernel header structs in the
>         "file" command".

I am OK, excluding patch 9, with this patch series. If there are no
objections I will apply patches 1-8 and 10 next week.

Daniel


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 03/10] make GRUB_LINUX_MAGIC_SIGNATURE architecture-specific
  2018-02-15 10:05   ` Daniel Kiper
@ 2018-02-15 10:39     ` Leif Lindholm
  2018-02-15 10:42       ` Daniel Kiper
  0 siblings, 1 reply; 29+ messages in thread
From: Leif Lindholm @ 2018-02-15 10:39 UTC (permalink / raw)
  To: Daniel Kiper; +Cc: grub-devel

On Thu, Feb 15, 2018 at 11:05:16AM +0100, Daniel Kiper wrote:
> On Thu, Feb 01, 2018 at 06:18:51PM +0000, Leif Lindholm wrote:
> > Rename GRUB_LINUX_MAGIC_SIGNATURE GRUB_LINUX_I386_MAGIC_SIGNATURE,
> 
> Missing "to" between GRUB_LINUX_MAGIC_SIGNATURE and
> GRUB_LINUX_I386_MAGIC_SIGNATURE.

Both forms are valid (it wasn't a typo).

> I will fix it during commit.

But I don't mind if you change it :)

> > to be usable in code that supports more than one image type.
> >
> > Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> 
> Otherwise Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>

Thanks!

/
    Leif


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 03/10] make GRUB_LINUX_MAGIC_SIGNATURE architecture-specific
  2018-02-15 10:39     ` Leif Lindholm
@ 2018-02-15 10:42       ` Daniel Kiper
  0 siblings, 0 replies; 29+ messages in thread
From: Daniel Kiper @ 2018-02-15 10:42 UTC (permalink / raw)
  To: Leif Lindholm; +Cc: grub-devel

On Thu, Feb 15, 2018 at 10:39:38AM +0000, Leif Lindholm wrote:
> On Thu, Feb 15, 2018 at 11:05:16AM +0100, Daniel Kiper wrote:
> > On Thu, Feb 01, 2018 at 06:18:51PM +0000, Leif Lindholm wrote:
> > > Rename GRUB_LINUX_MAGIC_SIGNATURE GRUB_LINUX_I386_MAGIC_SIGNATURE,
> >
> > Missing "to" between GRUB_LINUX_MAGIC_SIGNATURE and
> > GRUB_LINUX_I386_MAGIC_SIGNATURE.
>
> Both forms are valid (it wasn't a typo).

OK, thanks.

> > I will fix it during commit.
>
> But I don't mind if you change it :)

I will leave it then.

Daniel


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 00/10] various cleanup
  2018-02-15 10:34 ` [PATCH 00/10] various cleanup Daniel Kiper
@ 2018-02-23 22:11   ` Daniel Kiper
  2018-02-26 13:15     ` Leif Lindholm
  0 siblings, 1 reply; 29+ messages in thread
From: Daniel Kiper @ 2018-02-23 22:11 UTC (permalink / raw)
  To: Leif Lindholm; +Cc: grub-devel

On Thu, Feb 15, 2018 at 11:34:18AM +0100, Daniel Kiper wrote:
> Sorry for delay.
>
> On Thu, Feb 01, 2018 at 06:18:48PM +0000, Leif Lindholm wrote:
> > So, sorry I dropped the ball on this last year.
> >
> > This series contains what I would hope to be non-contentious
> > cleanup in preparation for the functional changes (/fixes) for
> > the arm64 linux loader and its reuse in the arm-efi port.
> >
> >    1/10 Simply moves the EFI_PAGE definition to <grub/efi/memory.h>.
> >  2-7/10 Cleans up and aligns the macro and struct naming for
> >         <grub/cpu/linux.h>.
> >    8/10 Makes it possible to include <grub/arm/linux.h> in a non-native
> >         command or utility.
> > 9-10/10 Switches to use the arm/arm64 kernel header structs in the
> >         "file" command".
>
> I am OK, excluding patch 9, with this patch series. If there are no
> objections I will apply patches 1-8 and 10 next week.

Due to conflicts in patch 10 I have just applied patches 1-8.
Please repost patches 9 and 10.

FYI, this is last time when I sent commit confirmation.
If I send one in the future then this will be rather
exception than rule. So, if you receive my reviewed-by
and patch is not committed in a week or two then it means
that it fallen into abyss and you have to ping me.

Have a nice weekend,

Daniel


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 00/10] various cleanup
  2018-02-23 22:11   ` Daniel Kiper
@ 2018-02-26 13:15     ` Leif Lindholm
  2018-02-27 12:11       ` Daniel Kiper
  0 siblings, 1 reply; 29+ messages in thread
From: Leif Lindholm @ 2018-02-26 13:15 UTC (permalink / raw)
  To: Daniel Kiper; +Cc: grub-devel

On Fri, Feb 23, 2018 at 11:11:08PM +0100, Daniel Kiper wrote:
> > > 9-10/10 Switches to use the arm/arm64 kernel header structs in the
> > >         "file" command".
> >
> > I am OK, excluding patch 9, with this patch series. If there are no
> > objections I will apply patches 1-8 and 10 next week.
> 
> Due to conflicts in patch 10 I have just applied patches 1-8.
> Please repost patches 9 and 10.

I could re-post them, but they would look identical.
I'm a bit confused as to what the conflict is, since I can rebase the
two commits onto current master without issues, and cherry-pick them
cleanly.

Could you try cherry-picking them from
https://git.linaro.org/people/leif.lindholm/grub.git/log/?h=linux-cleanup
?

If you still have issues, can you show me the conflict?

Best Regards,

Leif


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 00/10] various cleanup
  2018-02-26 13:15     ` Leif Lindholm
@ 2018-02-27 12:11       ` Daniel Kiper
  0 siblings, 0 replies; 29+ messages in thread
From: Daniel Kiper @ 2018-02-27 12:11 UTC (permalink / raw)
  To: Leif Lindholm; +Cc: grub-devel

On Mon, Feb 26, 2018 at 01:15:49PM +0000, Leif Lindholm wrote:
> On Fri, Feb 23, 2018 at 11:11:08PM +0100, Daniel Kiper wrote:
> > > > 9-10/10 Switches to use the arm/arm64 kernel header structs in the
> > > >         "file" command".
> > >
> > > I am OK, excluding patch 9, with this patch series. If there are no
> > > objections I will apply patches 1-8 and 10 next week.
> >
> > Due to conflicts in patch 10 I have just applied patches 1-8.
> > Please repost patches 9 and 10.
>
> I could re-post them, but they would look identical.
> I'm a bit confused as to what the conflict is, since I can rebase the
> two commits onto current master without issues, and cherry-pick them
> cleanly.
>
> Could you try cherry-picking them from
> https://git.linaro.org/people/leif.lindholm/grub.git/log/?h=linux-cleanup
> ?
>
> If you still have issues, can you show me the conflict?

It looks that I was not clear enough. Sorry about that. I had some comments for
patch 9. So, I decided to skip it and apply patch 10 after 8. Sadly it looks that
patch 10 depends on some changes in patch 9, so, I was not able to apply it. Hence,
please fix patch 9, as I ask for, and repost both patch 9 and 10.

I hope that helps.

Daniel


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 09/10] commands/file: use definitions from arm/linux.h
  2018-02-15 10:30   ` Daniel Kiper
@ 2018-02-27 12:36     ` Leif Lindholm
  2018-03-05 15:13       ` Daniel Kiper
  0 siblings, 1 reply; 29+ messages in thread
From: Leif Lindholm @ 2018-02-27 12:36 UTC (permalink / raw)
  To: Daniel Kiper
  Cc: grub-devel, Vladimir 'φ-coder/phcoder' Serbinenko

On Thu, Feb 15, 2018 at 11:30:32AM +0100, Daniel Kiper wrote:
> On Thu, Feb 01, 2018 at 06:18:57PM +0000, Leif Lindholm wrote:
> > Clean up code for matching IS_ARM slightly by making use of struct
> > linux_arm_kernel_header and GRUB_LINUX_ARM_MAGIC_SIGNATURE.
> >
> > Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> > ---
> >  grub-core/commands/file.c | 14 ++++++--------
> >  1 file changed, 6 insertions(+), 8 deletions(-)
> >
> > diff --git a/grub-core/commands/file.c b/grub-core/commands/file.c
> > index 63c84499b..fad191202 100644
> > --- a/grub-core/commands/file.c
> > +++ b/grub-core/commands/file.c
> > @@ -27,6 +27,7 @@
> >  #include <grub/elf.h>
> >  #include <grub/xen_file.h>
> >  #include <grub/efi/pe32.h>
> > +#include <grub/arm/linux.h>
> >  #include <grub/i386/linux.h>
> >  #include <grub/xnu.h>
> >  #include <grub/machoload.h>
> > @@ -383,21 +384,18 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
> >        }
> >      case IS_ARM_LINUX:
> >        {
> > -	grub_uint32_t sig, sig_pi;
> > -	if (grub_file_read (file, &sig_pi, 4) != 4)
> > +	struct linux_arm_kernel_header lh;
> > +	if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh))
> >  	  break;
> >  	/* Raspberry pi.  */
> > -	if (sig_pi == grub_cpu_to_le32_compile_time (0xea000006))
> > +	if (lh.code0 == grub_cpu_to_le32_compile_time (0xea000006))
> 
> Could you define 0xea000006 as a constant? If you add the comment
> what does it mean that will be perfect.

I'll be completely honest here and say "I don't have a clue".

Well, that's not true, I'm broken enough to see that that is a short
forward branch in the A32 ("ARM") instruction set. What I don't
understand is what significance that has for Raspberry Pi.
I just kept the logic for compatibility.

Vladimir?

/
    Leif


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 09/10] commands/file: use definitions from arm/linux.h
  2018-02-27 12:36     ` Leif Lindholm
@ 2018-03-05 15:13       ` Daniel Kiper
  0 siblings, 0 replies; 29+ messages in thread
From: Daniel Kiper @ 2018-03-05 15:13 UTC (permalink / raw)
  To: Leif Lindholm
  Cc: grub-devel, Vladimir 'φ-coder/phcoder' Serbinenko

On Tue, Feb 27, 2018 at 12:36:37PM +0000, Leif Lindholm wrote:
> On Thu, Feb 15, 2018 at 11:30:32AM +0100, Daniel Kiper wrote:
> > On Thu, Feb 01, 2018 at 06:18:57PM +0000, Leif Lindholm wrote:
> > > Clean up code for matching IS_ARM slightly by making use of struct
> > > linux_arm_kernel_header and GRUB_LINUX_ARM_MAGIC_SIGNATURE.
> > >
> > > Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> > > ---
> > >  grub-core/commands/file.c | 14 ++++++--------
> > >  1 file changed, 6 insertions(+), 8 deletions(-)
> > >
> > > diff --git a/grub-core/commands/file.c b/grub-core/commands/file.c
> > > index 63c84499b..fad191202 100644
> > > --- a/grub-core/commands/file.c
> > > +++ b/grub-core/commands/file.c
> > > @@ -27,6 +27,7 @@
> > >  #include <grub/elf.h>
> > >  #include <grub/xen_file.h>
> > >  #include <grub/efi/pe32.h>
> > > +#include <grub/arm/linux.h>
> > >  #include <grub/i386/linux.h>
> > >  #include <grub/xnu.h>
> > >  #include <grub/machoload.h>
> > > @@ -383,21 +384,18 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
> > >        }
> > >      case IS_ARM_LINUX:
> > >        {
> > > -	grub_uint32_t sig, sig_pi;
> > > -	if (grub_file_read (file, &sig_pi, 4) != 4)
> > > +	struct linux_arm_kernel_header lh;
> > > +	if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh))
> > >  	  break;
> > >  	/* Raspberry pi.  */
> > > -	if (sig_pi == grub_cpu_to_le32_compile_time (0xea000006))
> > > +	if (lh.code0 == grub_cpu_to_le32_compile_time (0xea000006))
> >
> > Could you define 0xea000006 as a constant? If you add the comment
> > what does it mean that will be perfect.
>
> I'll be completely honest here and say "I don't have a clue".
>
> Well, that's not true, I'm broken enough to see that that is a short
> forward branch in the A32 ("ARM") instruction set. What I don't
> understand is what significance that has for Raspberry Pi.
> I just kept the logic for compatibility.
>
> Vladimir?

If Vladimir or anybody else is not able to say then I would not like to
hold on you any longer. I am happy with your guess in the comment if you
say that it is a guess.

Daniel


^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2018-03-05 15:13 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-01 18:18 [PATCH 00/10] various cleanup Leif Lindholm
2018-02-01 18:18 ` [PATCH 01/10] arm64/efi: move EFI_PAGE definitions to efi/memory.h Leif Lindholm
2018-02-15  9:57   ` Daniel Kiper
2018-02-01 18:18 ` [PATCH 02/10] Make arch-specific linux.h include guards architecture unique Leif Lindholm
2018-02-15 10:00   ` Daniel Kiper
2018-02-01 18:18 ` [PATCH 03/10] make GRUB_LINUX_MAGIC_SIGNATURE architecture-specific Leif Lindholm
2018-02-15 10:05   ` Daniel Kiper
2018-02-15 10:39     ` Leif Lindholm
2018-02-15 10:42       ` Daniel Kiper
2018-02-01 18:18 ` [PATCH 04/10] i386: make struct linux_kernel_header architecture specific Leif Lindholm
2018-02-15 10:06   ` Daniel Kiper
2018-02-01 18:18 ` [PATCH 05/10] arm64: align linux kernel header struct naming with i386 Leif Lindholm
2018-02-15 10:09   ` Daniel Kiper
2018-02-01 18:18 ` [PATCH 06/10] arm64: align linux kernel magic macro " Leif Lindholm
2018-02-15 10:12   ` Daniel Kiper
2018-02-01 18:18 ` [PATCH 07/10] arm: switch linux loader to linux_arm_kernel_header struct Leif Lindholm
2018-02-15 10:21   ` Daniel Kiper
2018-02-01 18:18 ` [PATCH 08/10] arm: make linux.h safe to include for non-native builds Leif Lindholm
2018-02-15 10:25   ` Daniel Kiper
2018-02-01 18:18 ` [PATCH 09/10] commands/file: use definitions from arm/linux.h Leif Lindholm
2018-02-15 10:30   ` Daniel Kiper
2018-02-27 12:36     ` Leif Lindholm
2018-03-05 15:13       ` Daniel Kiper
2018-02-01 18:18 ` [PATCH 10/10] commands/file: use definitions from arm64/linux.h Leif Lindholm
2018-02-15 10:31   ` Daniel Kiper
2018-02-15 10:34 ` [PATCH 00/10] various cleanup Daniel Kiper
2018-02-23 22:11   ` Daniel Kiper
2018-02-26 13:15     ` Leif Lindholm
2018-02-27 12:11       ` Daniel Kiper

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.