From patchwork Sat Feb 4 17:38:43 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Goswin von Brederlow X-Patchwork-Id: 139595 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id EA96FB7243 for ; Sun, 5 Feb 2012 09:10:20 +1100 (EST) Received: from localhost ([::1]:55245 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RtnoD-0008Rr-EF for incoming@patchwork.ozlabs.org; Sat, 04 Feb 2012 17:10:13 -0500 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) Received: from frosties.localnet ([95.208.118.96]) by smtp.web.de (mrweb002) with ESMTPA (Nemesis) id 0M1Wxd-1Si7Ej2iLJ-00tGJl; Sat, 04 Feb 2012 18:38:44 +0100 Received: from mrvn by frosties.localnet with local (Exim 4.77) (envelope-from ) id 1RtjZT-0007R7-Tw; Sat, 04 Feb 2012 18:38:44 +0100 To: qemu-devel@nongnu.org Message-Id: From: Goswin von Brederlow Date: Sat, 04 Feb 2012 18:38:43 +0100 X-Provags-ID: V02:K0:nk4HL+SpsoT81o2hUfu9FdPBojTRI4WDbCNdbAv8WzG eZeGlQ8T6s0dz0n2e60Od7uiRkpNFIDBCY6fb50rx2vsUycPQS 33EadKrtJ9QSNGwRc8uOQ0M86STJ/phIQ7yMB0sTL3MVSlwd2T enWBy2W/a6ekYNV+goj/GJFTI6I7mmkD86yyoL10Doyg+X9AdP isT5nQqDa0BOh1I7MQcdA== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 217.72.192.227 X-Mailman-Approved-At: Sat, 04 Feb 2012 17:09:57 -0500 Cc: goswin-v-b@web.de Subject: [Qemu-devel] Support for multiboot images in elf64 (EM_X86_64) format X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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,