Received: from eggs.gnu.org ([140.186.70.92]:46312) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RtjZX-0005Si-Pu for qemu-devel@nongnu.org; Sat, 04 Feb 2012 12:38:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RtjZW-0006Pa-MZ for qemu-devel@nongnu.org; Sat, 04 Feb 2012 12:38:47 -0500 Received: from fmmailgate02.web.de ([217.72.192.227]:34805) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RtjZW-0006PM-Hp for qemu-devel@nongnu.org; Sat, 04 Feb 2012 12:38:46 -0500 Received: from moweb001.kundenserver.de (moweb001.kundenserver.de [172.19.20.114]) by fmmailgate02.web.de (Postfix) with ESMTP id F331D1C0A05BB for ; Sat, 4 Feb 2012 18:38:44 +0100 (CET) Message-Id: From: Goswin von Brederlow Date: Sat, 04 Feb 2012 18:38:43 +0100 Subject: [Qemu-devel] Support for multiboot images in elf64 (EM_X86_64) format List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: goswin-v-b@web.de 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 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,