]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
xen: Look for Xen notes in section headers too
authorMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Thu, 14 Mar 2019 01:57:08 +0000 (02:57 +0100)
committerDaniel Kiper <daniel.kiper@oracle.com>
Tue, 19 Mar 2019 10:38:29 +0000 (11:38 +0100)
Mirror behaviour of ELF loader in libxc: first look for Xen notes in
PT_NOTE segment, then in SHT_NOTE section and only then fallback to
a section with __xen_guest name. This fixes loading PV kernels that
Xen note have outside of PT_NOTE. While this may be result of a buggy
linker script, loading such kernel directly works fine, so make it work
with GRUB too. Specifically, this applies to binaries built from Unikraft.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/loader/i386/xen_fileXX.c

index fb66e66fe960db0da24a86e6c248e1f213078091..6329ec01038cd6baafa32bcc8d6ad4c4915d8f9a 100644 (file)
@@ -344,6 +344,23 @@ grub_xen_get_infoXX (grub_elf_t elf, struct grub_xen_file_info *xi)
   s = (Elf_Shdr *) ((char *) s0 + elf->ehdr.ehdrXX.e_shstrndx * shentsize);
   stroff = s->sh_offset;
 
+  for (s = s0; s < (Elf_Shdr *) ((char *) s0 + shnum * shentsize);
+       s = (Elf_Shdr *) ((char *) s + shentsize))
+    {
+      if (s->sh_type == SHT_NOTE)
+       {
+         err = parse_note (elf, xi, s->sh_offset, s->sh_size);
+         if (err)
+           goto cleanup;
+       }
+    }
+
+  if (xi->has_note)
+    {
+      err = GRUB_ERR_NONE;
+      goto cleanup;
+    }
+
   for (s = s0; s < (Elf_Shdr *) ((char *) s0 + shnum * shentsize);
        s = (Elf_Shdr *) ((char *) s + shentsize))
     {