]> git.proxmox.com Git - grub2.git/commitdiff
commands/file: Use definitions from arm/linux.h
authorLeif Lindholm <leif.lindholm@linaro.org>
Mon, 25 Jun 2018 17:01:28 +0000 (18:01 +0100)
committerSteve McIntyre <93sam@debian.org>
Tue, 25 Jun 2019 09:11:12 +0000 (10:11 +0100)
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>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Origin: upstream, https://git.savannah.gnu.org/cgit/grub.git/commit/?id=40dc61ed75e08e7dc2951bdae5c59fecb15bbb72
Bug-Debian: https://bugs.debian.org/907596
Bug-Debian: https://bugs.debian.org/909420
Last-Update: 2018-12-06

Patch-Name: file-definitions-from-arm-linux-h.patch

Gbp-Pq: Name file-definitions-from-arm-linux-h.patch

grub-core/commands/file.c

index 63c84499babcdeb051380a24d1d0ed71015d6640..ab0c9fb96946fe6078d7e518a93804143ec66d66 100644 (file)
@@ -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,19 @@ 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))
+       /* Short forward branch in A32 state (for Raspberry pi kernels). */
+       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;