qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Support for multiboot images in elf64 (EM_X86_64) format


From: Goswin von Brederlow
Subject: [Qemu-devel] Support for multiboot images in elf64 (EM_X86_64) format
Date: Sat, 04 Feb 2012 18:38:43 +0100

Hi,

starting your own toy kernel is a fun thing to do and there are many
tutorials out there on how to do it. Unfortunately when one wants to
write a kernel in 64bit it becomes much harder because one can't    
compile 64bit code as elf32 image and converting a elf64 image to
elf32 format is a major hassle and looses debug information and symbols.

So I looked into why kvm does not load an multiboot image in elf64 format
and what would be neccessary to support this. And the answere is that
all it needs is to remove the error message. Kvm alredy supports loading
a multiboot image in elf64 format perfectly. There is no need to force the
user to convert their toy kernel from elf64 to elf32 format at all.

MfG
        Goswin
--
Description: Allow 64bit elf binaries in multiboot format
 This patch allows 64bit elf files with multiboot header to be loaded.
 The entry point will still be called in 32bit mode and the kernel
 must switch to 64bit mode on its own. The image and all modules must
 also be located in the lower 2GB of ram. All the restrictions of a
 32bit image still apply.
Author: Goswin von Brederlow <address@hidden>
Last-Updated: 2011-04-08
---

--- qemu-kvm-0.14.0+dfsg.orig/hw/multiboot.c
+++ qemu-kvm-0.14.0+dfsg/hw/multiboot.c
@@ -173,8 +173,7 @@ int load_multiboot(void *fw_cfg,
         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);
+           mb_debug("qemu: 64bit elf, I hope you know what you are doing\n");
         }
 
         kernel_size = load_elf(kernel_filename, NULL, NULL, &elf_entry,



reply via email to

[Prev in Thread] Current Thread [Next in Thread]