Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NKsck-0006hx-J1 for qemu-devel@nongnu.org; Wed, 16 Dec 2009 07:04:58 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NKscf-0006fZ-PR for qemu-devel@nongnu.org; Wed, 16 Dec 2009 07:04:57 -0500 Received: from [199.232.76.173] (port=49843 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NKscf-0006fU-F3 for qemu-devel@nongnu.org; Wed, 16 Dec 2009 07:04:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:11836) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NKscf-0008WL-4I for qemu-devel@nongnu.org; Wed, 16 Dec 2009 07:04:53 -0500 From: Markus Armbruster Subject: Re: [Qemu-devel] [FOR 0.12][PATCH] Fix loading of ELF multiboot kernels References: <1259943565-10528-1-git-send-email-kwolf@redhat.com> <4B28B256.2020605@redhat.com> Date: Wed, 16 Dec 2009 13:04:49 +0100 In-Reply-To: <4B28B256.2020605@redhat.com> (Kevin Wolf's message of "Wed, 16 Dec 2009 11:11:34 +0100") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-devel@nongnu.org, agraf@suse.de Kevin Wolf writes: > Am 16.12.2009 10:51, schrieb Markus Armbruster: >> Kevin Wolf writes: >> >>> The multiboot implementation assumed that there is only one program header >>> (which contains the entry point) and that the entry point is at the start of >>> the code. This doesn't hold true generally and caused too little data to be >>> loaded. >> >> Out of curiosity: does this affect images people actually use? >> Examples? > > It hit me, so yes. Probably no widespread kernels as Alex' tests looked > fine (not sure what he tests, probably Xen and his OS X bootloader?). In > my case it was a simple test kernel. I'd expect the sum of unknown > research or hobby kernels to be a major use case for Multiboot support, > though. Thanks. >>> Fix the loading code to pass the whole loaded data to the Multiboot Option ROM. >>> >>> Signed-off-by: Kevin Wolf >>> --- >>> hw/loader.c | 2 -- >>> hw/pc.c | 10 ++++++---- >>> 2 files changed, 6 insertions(+), 6 deletions(-) >>> >>> diff --git a/hw/loader.c b/hw/loader.c >>> index 2d7a2c4..4c6981f 100644 >>> --- a/hw/loader.c >>> +++ b/hw/loader.c >>> @@ -718,8 +718,6 @@ int rom_copy(uint8_t *dest, target_phys_addr_t addr, size_t size) >>> QTAILQ_FOREACH(rom, &roms, next) { >>> if (rom->max) >>> continue; >>> - if (rom->min > addr) >>> - continue; >>> if (rom->min + rom->romsize < addr) >>> continue; >>> if (rom->min > end) >> >> I don't understand this hunk. > > The original code assumes that there is only one ROM that contains the > entry point. In fact, each program header of an ELF file becomes it own > ROM, though. So if you have a first PH which contains the entry point > (or now the lowest loaded address) and a second PH at a higher address, > this test would fail for the second one even though we need to load it. > > What we really need to test is if [addr, end] and [rom->min, rom->min + > rom->romsize] have an intersection. This is what the following two ifs > already check. So rom_copy() is supposed to copy all fixed-address ROMs in the range addr..addr+size? Makes sense then.