From owner-svn-src-all@FreeBSD.ORG Sat Mar 9 23:05:20 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id E9B41D32; Sat, 9 Mar 2013 23:05:20 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id B9E02EA5; Sat, 9 Mar 2013 23:05:20 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r29N5KoH045847; Sat, 9 Mar 2013 23:05:20 GMT (envelope-from ian@svn.freebsd.org) Received: (from ian@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r29N5KWW045846; Sat, 9 Mar 2013 23:05:20 GMT (envelope-from ian@svn.freebsd.org) Message-Id: <201303092305.r29N5KWW045846@svn.freebsd.org> From: Ian Lepore Date: Sat, 9 Mar 2013 23:05:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248118 - head/sys/boot/common X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Mar 2013 23:05:21 -0000 Author: ian Date: Sat Mar 9 23:05:19 2013 New Revision: 248118 URL: http://svnweb.freebsd.org/changeset/base/248118 Log: Since ubldr doesn't necessarily load a kernel at the physical address in the elf headers, mask out the high nibble of that address. This effectly makes the entry point the offset from the load address, and it gets adjusted for the actual load address before jumping to it. Masking the high nibble makes assumptions about memory layout that are true for all the arm platforms we support right now, but it makes me uneasy. This needs to be revisited. Modified: head/sys/boot/common/load_elf.c Modified: head/sys/boot/common/load_elf.c ============================================================================== --- head/sys/boot/common/load_elf.c Sat Mar 9 21:32:24 2013 (r248117) +++ head/sys/boot/common/load_elf.c Sat Mar 9 23:05:19 2013 (r248118) @@ -297,15 +297,16 @@ __elfN(loadimage)(struct preloaded_file * the MI code below uses the p_vaddr fields with an offset added for * loading (doing so is arguably wrong). To make loading work, we need * an offset that represents the difference between physical and virtual - * addressing. ARM kernels are always linked at 0xC0000000. Depending + * addressing. ARM kernels are always linked at 0xCnnnnnnn. Depending * on the headers, the offset value passed in may be physical or virtual * (because it typically comes from e_entry), but we always replace * whatever is passed in with the va<->pa offset. On the other hand, we - * only adjust the entry point if it's a virtual address to begin with. + * always remove the high-order part of the entry address whether it's + * physical or virtual, because it will be adjusted later for the actual + * physical entry point based on where the image gets loaded. */ - off = -0xc0000000u; - if ((ehdr->e_entry & 0xc0000000u) == 0xc0000000u) - ehdr->e_entry += off; + off = -0xc0000000; + ehdr->e_entry &= ~0xf0000000; #ifdef ELF_VERBOSE printf("ehdr->e_entry 0x%08x, va<->pa off %llx\n", ehdr->e_entry, off); #endif