From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LLJmW-0001IT-VD for qemu-devel@nongnu.org; Fri, 09 Jan 2009 11:00:20 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LLJmU-0001IH-Jl for qemu-devel@nongnu.org; Fri, 09 Jan 2009 11:00:19 -0500 Received: from [199.232.76.173] (port=54605 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LLJmU-0001IE-EU for qemu-devel@nongnu.org; Fri, 09 Jan 2009 11:00:18 -0500 Received: from mail-bw0-f12.google.com ([209.85.218.12]:52312) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LLJmT-0003tt-Q6 for qemu-devel@nongnu.org; Fri, 09 Jan 2009 11:00:18 -0500 Received: by bwz5 with SMTP id 5so18476245bwz.10 for ; Fri, 09 Jan 2009 08:00:15 -0800 (PST) Message-ID: <761ea48b0901090757j7277ecbfo74dd1b6415fbeaa8@mail.gmail.com> Date: Fri, 9 Jan 2009 16:57:36 +0100 From: "Laurent Desnogues" Subject: Re: [Qemu-devel] [PATCH][RFC] elf loader: use the virtual address In-Reply-To: <20090109154756.GA27086@volta.aurel32.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20090109154756.GA27086@volta.aurel32.net> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org On Fri, Jan 9, 2009 at 4:47 PM, Aurelien Jarno wrote: > Most Linux kernels have their physical address corresponding to they > virtual address in the ELF header. This is however not true anymore for > the PowerPC kernels (>= 2.6.25). > > For PowerPC, the kernel needs to be started with address translation > enabled (that's even true for the firmware), and thus the kernel loaded > at the virtual address. > > As all the other kernels/bios I have looked have the same virtual and > physical address, I don't think it will break other targets. This is > what is done in the patch below. Alternatively, we can add a new > argument to the load_elf functions, to select between virtual and > physical load address. > > Any opinon? I wonder if some platforms don't use the address_offset parameter to simulate that behaviour. Anyway wouldn't a parameter be cleaner and allow more flexibility? Laurent > diff --git a/elf_ops.h b/elf_ops.h > index feea12f..19d1a5e 100644 > --- a/elf_ops.h > +++ b/elf_ops.h > @@ -231,7 +231,7 @@ static int glue(load_elf, SZ)(int fd, int64_t address_offset, > } > /* address_offset is hack for kernel images that are > linked at the wrong physical address. */ > - addr = ph->p_paddr + address_offset; > + addr = ph->p_vaddr + address_offset; > > cpu_physical_memory_write_rom(addr, data, mem_size); > > -- > .''`. Aurelien Jarno | GPG: 1024D/F1BCDB73 > : :' : Debian developer | Electrical Engineer > `. `' aurel32@debian.org | aurelien@aurel32.net > `- people.debian.org/~aurel32 | www.aurel32.net > > >