]> git.proxmox.com Git - mirror_qemu.git/commitdiff
multiboot: Prevent loading of x86_64 images
authorAdam Lackorzynski <adam@os.inf.tu-dresden.de>
Thu, 4 Nov 2010 22:22:15 +0000 (23:22 +0100)
committerAnthony Liguori <aliguori@us.ibm.com>
Tue, 16 Nov 2010 15:31:18 +0000 (09:31 -0600)
A via -kernel supplied x86_64 ELF image is being started in 32bit mode.
Detect and exit if a 64bit image has been supplied.

Signed-off-by: Adam Lackorzynski <adam@os.inf.tu-dresden.de>
Acked-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
hw/multiboot.c

index f9097a2f60c9b9c99eb167eaef6fb015824d1fa6..e710bbb9482bbde47a8c8a2aac9269402949d0eb 100644 (file)
@@ -171,6 +171,12 @@ int load_multiboot(void *fw_cfg,
         uint64_t elf_low, elf_high;
         int kernel_size;
         fclose(f);
+
+        if (((struct elf64_hdr*)header)->e_machine == EM_X86_64) {
+            fprintf(stderr, "Cannot load x86-64 image, give a 32bit one.\n");
+            exit(1);
+        }
+
         kernel_size = load_elf(kernel_filename, NULL, NULL, &elf_entry,
                                &elf_low, &elf_high, 0, ELF_MACHINE, 0);
         if (kernel_size < 0) {