From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=42371 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Om4lH-0007EB-LK for qemu-devel@nongnu.org; Thu, 19 Aug 2010 09:02:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Om4lG-0006Ts-9K for qemu-devel@nongnu.org; Thu, 19 Aug 2010 09:02:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:24482) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Om4lG-0006Tl-0h for qemu-devel@nongnu.org; Thu, 19 Aug 2010 09:02:26 -0400 Message-ID: <4C6D2B5F.40805@redhat.com> Date: Thu, 19 Aug 2010 16:02:23 +0300 From: Avi Kivity MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] multiboot: Prevent loading of x86_64 images References: <20100819112414.GH22245@os.inf.tu-dresden.de> In-Reply-To: <20100819112414.GH22245@os.inf.tu-dresden.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Adam Lackorzynski Cc: qemu-devel@nongnu.org On 08/19/2010 02:24 PM, Adam Lackorzynski wrote: > A via -kernel supplied x86_64 ELF image is being started in 32bit mode. > Detect and exit if a 64bit image has been supplied. > > > > 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) { We rely on the existing behaviour in kvm-unit-tests.git. Tests (.flat files) are 64-bit elf binaries that are loaded in 32-bit more and switch immediately to 64-bit. We can easily wrap them in a 32-bit elf, but that's a needless complication. -- error compiling committee.c: too many arguments to function