From patchwork Sat Sep 25 08:51:23 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Lackorzynski X-Patchwork-Id: 65740 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 C7B84B70DA for ; Sat, 25 Sep 2010 18:52:36 +1000 (EST) Received: from localhost ([127.0.0.1]:37878 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OzQUk-0003As-2Y for incoming@patchwork.ozlabs.org; Sat, 25 Sep 2010 04:52:34 -0400 Received: from [140.186.70.92] (port=58121 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OzQTf-00039g-1C for qemu-devel@nongnu.org; Sat, 25 Sep 2010 04:51:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OzQTd-0004Ma-VN for qemu-devel@nongnu.org; Sat, 25 Sep 2010 04:51:26 -0400 Received: from os.inf.tu-dresden.de ([141.76.48.99]:51021) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OzQTd-0004MW-Qb for qemu-devel@nongnu.org; Sat, 25 Sep 2010 04:51:25 -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 1OzQTc-0004FD-Nt for qemu-devel@nongnu.org; Sat, 25 Sep 2010 10:51:24 +0200 Date: Sat, 25 Sep 2010 10:51:23 +0200 From: Adam Lackorzynski To: qemu-devel@nongnu.org Message-ID: <20100925085123.GB5265@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 f9097a2..e710bbb 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) {