From owner-svn-src-all@freebsd.org Thu Feb 15 15:01:07 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A7C9CF2484A; Thu, 15 Feb 2018 15:01:07 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5993E7C88C; Thu, 15 Feb 2018 15:01:07 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5478B20497; Thu, 15 Feb 2018 15:01:07 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w1FF178S070943; Thu, 15 Feb 2018 15:01:07 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1FF17bB070942; Thu, 15 Feb 2018 15:01:07 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201802151501.w1FF17bB070942@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 15 Feb 2018 15:01:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r329315 - head/stand/common X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/stand/common X-SVN-Commit-Revision: 329315 X-SVN-Commit-Repository: base 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.25 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: Thu, 15 Feb 2018 15:01:07 -0000 Author: kevans Date: Thu Feb 15 15:01:07 2018 New Revision: 329315 URL: https://svnweb.freebsd.org/changeset/base/329315 Log: stand: Fix ubldr after r329190 metadata load files were consolidated in r329190, and these relocation fixup bits were inadvertently dropped in the process. Re-add them to fix boot with ubldr. Glanced over by: jhibbits X-MFC-With: r329190 Modified: head/stand/common/metadata.c Modified: head/stand/common/metadata.c ============================================================================== --- head/stand/common/metadata.c Thu Feb 15 14:46:29 2018 (r329314) +++ head/stand/common/metadata.c Thu Feb 15 15:01:07 2018 (r329315) @@ -38,6 +38,9 @@ __FBSDID("$FreeBSD$"); #include #endif +#ifdef __arm__ +#include +#endif #include #include "bootstrap.h" @@ -315,7 +318,23 @@ md_load_dual(char *args, vm_offset_t *modulep, vm_offs uint64_t scratch64; char *rootdevname; int howto; +#ifdef __arm__ + vm_offset_t vaddr; + int i; + /* + * These metadata addreses must be converted for kernel after + * relocation. + */ + uint32_t mdt[] = { + MODINFOMD_SSYM, MODINFOMD_ESYM, MODINFOMD_KERNEND, + MODINFOMD_ENVP, +#if defined(LOADER_FDT_SUPPORT) + MODINFOMD_DTBP +#endif + }; +#endif + align = kern64 ? 8 : 4; howto = md_getboothowto(args); @@ -409,6 +428,23 @@ md_load_dual(char *args, vm_offset_t *modulep, vm_offs } else { bcopy(&kernend, md->md_data, sizeof kernend); } + +#ifdef __arm__ + /* Convert addresses to the final VA */ + *modulep -= __elfN(relocation_offset); + + /* Do relocation fixup on metadata of each module. */ + for (xp = file_findfile(NULL, NULL); xp != NULL; xp = xp->f_next) { + for (i = 0; i < nitems(mdt); i++) { + md = file_findmetadata(xp, mdt[i]); + if (md) { + bcopy(md->md_data, &vaddr, sizeof vaddr); + vaddr -= __elfN(relocation_offset); + bcopy(&vaddr, md->md_data, sizeof vaddr); + } + } + } +#endif (void)md_copymodules(addr, kern64); #if defined(LOADER_FDT_SUPPORT)