From patchwork Thu Sep 2 20:28:57 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Lackorzynski X-Patchwork-Id: 63544 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 56E7BB717C for ; Fri, 3 Sep 2010 06:45:49 +1000 (EST) Received: from localhost ([127.0.0.1]:49682 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OrGfJ-0006IG-VH for incoming@patchwork.ozlabs.org; Thu, 02 Sep 2010 16:45:46 -0400 Received: from [140.186.70.92] (port=56821 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OrGP7-00075b-Tw for qemu-devel@nongnu.org; Thu, 02 Sep 2010 16:29:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OrGP6-00087z-JN for qemu-devel@nongnu.org; Thu, 02 Sep 2010 16:29:01 -0400 Received: from os.inf.tu-dresden.de ([141.76.48.99]:54315) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OrGP6-00087u-EO for qemu-devel@nongnu.org; Thu, 02 Sep 2010 16:29:00 -0400 Received: from erwin.inf.tu-dresden.de ([141.76.48.80] helo=os.inf.tu-dresden.de) by os.inf.tu-dresden.de with esmtps (TLSv1:AES128-SHA:128) (Exim 4.72) id 1OrGP5-0004p9-JW for qemu-devel@nongnu.org; Thu, 02 Sep 2010 22:28:59 +0200 Date: Thu, 2 Sep 2010 22:28:57 +0200 From: Adam Lackorzynski To: qemu-devel@nongnu.org Message-ID: <20100902202857.GB23301@os.inf.tu-dresden.de> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Subject: [Qemu-devel] [PATCH] multiboot: Prevent loading of x86_64 images X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Acked-by: Alexander Graf --- hw/multiboot.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/hw/multiboot.c b/hw/multiboot.c index dc980e6..e9dcbc9 100644 --- a/hw/multiboot.c +++ b/hw/multiboot.c @@ -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) {