From patchwork Thu Nov 4 22:22:15 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Lackorzynski X-Patchwork-Id: 70176 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 0A7ECB70B8 for ; Fri, 5 Nov 2010 09:24:37 +1100 (EST) Received: from localhost ([127.0.0.1]:51685 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PE8EU-0002jd-2A for incoming@patchwork.ozlabs.org; Thu, 04 Nov 2010 18:24:34 -0400 Received: from [140.186.70.92] (port=38173 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PE8CI-0001ht-Np for qemu-devel@nongnu.org; Thu, 04 Nov 2010 18:22:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PE8CH-0000vb-Jk for qemu-devel@nongnu.org; Thu, 04 Nov 2010 18:22:18 -0400 Received: from os.inf.tu-dresden.de ([141.76.48.99]:58294) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PE8CH-0000vR-D4 for qemu-devel@nongnu.org; Thu, 04 Nov 2010 18:22:17 -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 1PE8CG-0004PF-M9 for qemu-devel@nongnu.org; Thu, 04 Nov 2010 23:22:16 +0100 Date: Thu, 4 Nov 2010 23:22:15 +0100 From: Adam Lackorzynski To: qemu-devel@nongnu.org Message-ID: <20101104222214.GC30050@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) {