From nobody Tue Jan 24 22:12:37 2023 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4P1h6Y4HWNz3bfyt; Tue, 24 Jan 2023 22:12:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4P1h6Y2dTVz3DQ2; Tue, 24 Jan 2023 22:12:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674598357; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=C0nkvQ6gB5WW9nobvIoqNmYtVzBoOTHxtqP9JxOkiEw=; b=esbphbNFXiThFlsz0ST/j0s1lB0T2j2BPZfw3qE735r7RSHYW1rFw0HHR97p7H5JfMYBoh gy7vLwA7TyDQWRlPYkyDmadpzg/erdr89ocGLs4dP7Du3vq/KPKV1S8Ebf8I2Dy2n6xSsf RAmYhAfTLwY90lDvJWBr0DpB+R6um3TiR6yQM2/MxsjB98LJiEXCf1uy/OD3a3qo3tXHpq /80YMB19f0GZtFcHFegCA8UF4u4ba57dEW8TT88VkPCCfC+hoaeglfOfteGU4W/h0Ecb4C 2bCMa4wj+GRFOnkqODMB2Ny58Lpw3vUqRfbbVOikudRYBlTVfrNP7geFm0yRZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674598357; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=C0nkvQ6gB5WW9nobvIoqNmYtVzBoOTHxtqP9JxOkiEw=; b=lG/DZajDUtFC5D4/RNN1gsiWMpIXPuL35YH7c0eCOvjilGUmXJbrvE2KPxSLIaxVEdfNB4 EeLlPSgACIBlEZSyGxw7fvFV6cRWJHSR3MAHOrACZ3CkFaABnE1PLw53cBODK2xBCr2lbq 7naGzqkl0XAOKgVv4lOFHzqAkANZK0nxfoISuVCV3QhHBQnrBLFril/otdfD2urUrMMk4t z8F+pddpSuP+u7R/0eZ2sw8UB06l7UgS2RQd38u6r7Ds7tQYHWwFJSIKm+b3NwshkO2EM6 JF7eJ+zPvCJzTUnFEGuNTVkJ5q5hcVg1QSQRusBxNxGkW1Vkl9ecHMDv8jPfRA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674598357; a=rsa-sha256; cv=none; b=dhmQTJKxKsc1Unx2WQtF4tqt/EO0iaiZyAGZsLb6DJ7s2UBFsvaqPMEnFUDf1MsX3AfYJV 1RF5wZCHMxWSzB56rNzDfe0C1OREAfmy0k58NxzBvKz/EeEfcaz/0aMwTBJbaN37bJtooM id5tJVKrjm4BOm5NK+EO+PscYtePms8pesi4XPJv0D6jvnLZRMB/F8L+j8twfBCh6kGym1 ZPDZnfIIjm7hOytY77XWdqXU/bOdU20EmK+pAm+9JZ0KVsnXRX/bPO9/Gj712rhK42gkdo yr5D5cTKh+qmrM7t56mK7YkQCVza3tTIood6nlvpWYWuxLm8+sIu+2i0nLWORA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4P1h6Y13vrzQgj; Tue, 24 Jan 2023 22:12:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 30OMCbpX087275; Tue, 24 Jan 2023 22:12:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30OMCbmh087274; Tue, 24 Jan 2023 22:12:37 GMT (envelope-from git) Date: Tue, 24 Jan 2023 22:12:37 GMT Message-Id: <202301242212.30OMCbmh087274@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: 2b3598753e20 - stable/13 - stand: Move md_copymodules into modinfo.c and reduce copies List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 2b3598753e203b5a418cafdcd7a1e981d82d0657 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=2b3598753e203b5a418cafdcd7a1e981d82d0657 commit 2b3598753e203b5a418cafdcd7a1e981d82d0657 Author: Warner Losh AuthorDate: 2022-09-16 15:08:47 +0000 Commit: Warner Losh CommitDate: 2023-01-24 21:49:34 +0000 stand: Move md_copymodules into modinfo.c and reduce copies md_copymodules, bi_copymdoules, bi_copymodules32 (x2) and bi_copymodules64 (x2) are all the same routine... Replace them all with md_copymodules. This saves about 800 bytes on i386 BIOS loader, which is a nice bonus. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D36572 (cherry picked from commit 5d1531d9d4e7d1b1b706ab23ac3f864416e87522) stand: fix mismerge Remove stray line from mismerge of 5d1531d9d4e7. This is no longer needed. Fixes: 5d1531d9d4e7 Sponsored by: Netflix (cherry picked from commit dd2b9c2967767b19bcbc33de0e487405c612f59f) stand/efi: Call md_copymodules based on __LP64__ to fix 32-bit arm When I refactored everything, I neglected to pass in the proper is64 value on 32-bit platforms. This corrects that. This prevented armv7 and armv6 platforms from booting due to misaligned data in the kernel. The only platform we support 32-bit booting in armv[67], which I apparently neglected to test before commiting my refactoring. Tested by: skibo Fixes: 5d1531d9d4e7d Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D37095 (cherry picked from commit e0c3f66b4d5f0282e9c7c4803c4cd26b5a388a38) --- stand/common/metadata.c | 44 ------------------ stand/common/modinfo.c | 86 ++++++++++++++++++++++++++++++++++++ stand/common/modinfo.h | 2 + stand/efi/loader/bootinfo.c | 45 ++++--------------- stand/i386/libi386/bootinfo32.c | 35 +-------------- stand/i386/libi386/bootinfo64.c | 38 +--------------- stand/loader.mk | 1 + stand/userboot/userboot/bootinfo32.c | 34 +------------- stand/userboot/userboot/bootinfo64.c | 38 +--------------- 9 files changed, 105 insertions(+), 218 deletions(-) diff --git a/stand/common/metadata.c b/stand/common/metadata.c index 99b67cfd1060..11a5276d0705 100644 --- a/stand/common/metadata.c +++ b/stand/common/metadata.c @@ -93,49 +93,6 @@ md_copyenv(vm_offset_t addr) return(addr); } -static int align; -#define MOD_ALIGN(l) roundup(l, align) - -static vm_offset_t -md_copymodules(vm_offset_t addr, int kern64) -{ - struct preloaded_file *fp; - struct file_metadata *md; - uint64_t scratch64; - uint32_t scratch32; - int c; - - c = addr != 0; - /* start with the first module on the list, should be the kernel */ - for (fp = file_findfile(NULL, NULL); fp != NULL; fp = fp->f_next) { - - MOD_NAME(addr, fp->f_name, c); /* this field must come first */ - MOD_TYPE(addr, fp->f_type, c); - if (fp->f_args) - MOD_ARGS(addr, fp->f_args, c); - if (kern64) { - scratch64 = fp->f_addr; - MOD_ADDR(addr, scratch64, c); - scratch64 = fp->f_size; - MOD_SIZE(addr, scratch64, c); - } else { - scratch32 = fp->f_addr; -#ifdef __arm__ - scratch32 -= __elfN(relocation_offset); -#endif - MOD_ADDR(addr, scratch32, c); - MOD_SIZE(addr, fp->f_size, c); - } - for (md = fp->f_metadata; md != NULL; md = md->md_next) { - if (!(md->md_type & MODINFOMD_NOCOPY)) { - MOD_METADATA(addr, md, c); - } - } - } - MOD_END(addr, c); - return(addr); -} - /* * Load the information expected by a kernel. * @@ -177,7 +134,6 @@ md_load_dual(char *args, vm_offset_t *modulep, vm_offset_t *dtb, int kern64) }; #endif - align = kern64 ? 8 : 4; howto = md_getboothowto(args); /* diff --git a/stand/common/modinfo.c b/stand/common/modinfo.c new file mode 100644 index 000000000000..a274890ace64 --- /dev/null +++ b/stand/common/modinfo.c @@ -0,0 +1,86 @@ +/*- + * Copyright (c) 1998 Michael Smith + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: FreeBSD: src/sys/boot/sparc64/loader/metadata.c,v 1.6 + */ +#include +#include +#include +#include +#include +#if defined(LOADER_FDT_SUPPORT) +#include +#endif + +#ifdef __arm__ +#include +#endif +#include + +#include "bootstrap.h" +#include "modinfo.h" + +static int align; +#define MOD_ALIGN(l) roundup(l, align) + +vm_offset_t +md_copymodules(vm_offset_t addr, bool kern64) +{ + struct preloaded_file *fp; + struct file_metadata *md; + uint64_t scratch64; + uint32_t scratch32; + int c; + + c = addr != 0; + /* start with the first module on the list, should be the kernel */ + for (fp = file_findfile(NULL, NULL); fp != NULL; fp = fp->f_next) { + + MOD_NAME(addr, fp->f_name, c); /* this field must come first */ + MOD_TYPE(addr, fp->f_type, c); + if (fp->f_args) + MOD_ARGS(addr, fp->f_args, c); + if (kern64) { + scratch64 = fp->f_addr; + MOD_ADDR(addr, scratch64, c); + scratch64 = fp->f_size; + MOD_SIZE(addr, scratch64, c); + } else { + scratch32 = fp->f_addr; +#ifdef __arm__ + scratch32 -= __elfN(relocation_offset); +#endif + MOD_ADDR(addr, scratch32, c); + MOD_SIZE(addr, fp->f_size, c); + } + for (md = fp->f_metadata; md != NULL; md = md->md_next) { + if (!(md->md_type & MODINFOMD_NOCOPY)) { + MOD_METADATA(addr, md, c); + } + } + } + MOD_END(addr, c); + return(addr); +} diff --git a/stand/common/modinfo.h b/stand/common/modinfo.h index 245784ccb2ed..3d7f26a3c963 100644 --- a/stand/common/modinfo.h +++ b/stand/common/modinfo.h @@ -69,4 +69,6 @@ COPY32(0, a, c); \ } +vm_offset_t md_copymodules(vm_offset_t addr, bool kern64); + #endif /* COMMON_MODINFO_H */ diff --git a/stand/efi/loader/bootinfo.c b/stand/efi/loader/bootinfo.c index 05dfc9f59c1f..bcd2dad0bae1 100644 --- a/stand/efi/loader/bootinfo.c +++ b/stand/efi/loader/bootinfo.c @@ -61,11 +61,6 @@ __FBSDID("$FreeBSD$"); #include "geliboot.h" #endif -/* - * Align to a pointer / long - */ -#define MOD_ALIGN(l) roundup(l, sizeof(u_long)) - int bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp, bool exit_bs); @@ -172,36 +167,6 @@ bi_copyenv(vm_offset_t start) return(last); } -static vm_offset_t -bi_copymodules(vm_offset_t addr) -{ - struct preloaded_file *fp; - struct file_metadata *md; - int c; - uint64_t v; - - c = addr != 0; - /* Start with the first module on the list, should be the kernel. */ - for (fp = file_findfile(NULL, NULL); fp != NULL; fp = fp->f_next) { - MOD_NAME(addr, fp->f_name, c); /* This must come first. */ - MOD_TYPE(addr, fp->f_type, c); - if (fp->f_args) - MOD_ARGS(addr, fp->f_args, c); - v = fp->f_addr; -#if defined(__arm__) - v -= __elfN(relocation_offset); -#endif - MOD_ADDR(addr, v, c); - v = fp->f_size; - MOD_SIZE(addr, v, c); - for (md = fp->f_metadata; md != NULL; md = md->md_next) - if (!(md->md_type & MODINFOMD_NOCOPY)) - MOD_METADATA(addr, md, c); - } - MOD_END(addr, c); - return(addr); -} - static EFI_STATUS efi_do_vmap(EFI_MEMORY_DESCRIPTOR *mm, UINTN sz, UINTN mmsz, UINT32 mmver) { @@ -392,6 +357,7 @@ bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp, bool exit_bs) vm_offset_t size; char *rootdevname; int howto; + bool is64; #if defined(LOADER_FDT_SUPPORT) vm_offset_t dtbp; int dtb_size; @@ -411,6 +377,11 @@ bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp, bool exit_bs) #endif }; #endif +#ifdef __LP64__ + is64 = true; +#else + is64 = false; +#endif howto = bi_getboothowto(args); @@ -489,7 +460,7 @@ bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp, bool exit_bs) #endif bi_load_efi_data(kfp, exit_bs); - size = bi_copymodules(0); + size = md_copymodules(0, is64); kernend = roundup(addr + size, PAGE_SIZE); *kernendp = kernend; @@ -514,7 +485,7 @@ bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp, bool exit_bs) #endif /* Copy module list and metadata. */ - (void)bi_copymodules(addr); + (void)md_copymodules(addr, is64); return (0); } diff --git a/stand/i386/libi386/bootinfo32.c b/stand/i386/libi386/bootinfo32.c index f00c692a3993..965b62bbad81 100644 --- a/stand/i386/libi386/bootinfo32.c +++ b/stand/i386/libi386/bootinfo32.c @@ -44,37 +44,6 @@ __FBSDID("$FreeBSD$"); static struct bootinfo bi; -/* - * We have 4 byte alignment for 32-bit targets. This code is compiled as 32-bit - * code... - */ -#define MOD_ALIGN(l) roundup(l, sizeof(u_long)) - -static vm_offset_t -bi_copymodules32(vm_offset_t addr) -{ - struct preloaded_file *fp; - struct file_metadata *md; - int c; - - c = addr != 0; - /* start with the first module on the list, should be the kernel */ - for (fp = file_findfile(NULL, NULL); fp != NULL; fp = fp->f_next) { - - MOD_NAME(addr, fp->f_name, c); /* this field must come first */ - MOD_TYPE(addr, fp->f_type, c); - if (fp->f_args) - MOD_ARGS(addr, fp->f_args, c); - MOD_ADDR(addr, fp->f_addr, c); - MOD_SIZE(addr, fp->f_size, c); - for (md = fp->f_metadata; md != NULL; md = md->md_next) - if (!(md->md_type & MODINFOMD_NOCOPY)) - MOD_METADATA(addr, md, c); - } - MOD_END(addr, c); - return(addr); -} - /* * Load the information expected by an i386 kernel. * @@ -179,7 +148,7 @@ bi_load32(char *args, int *howtop, int *bootdevp, vm_offset_t *bip, vm_offset_t /* Figure out the size and location of the metadata */ *modulep = addr; - size = bi_copymodules32(0); + size = md_copymodules(0, false); kernend = roundup(addr + size, PAGE_SIZE); *kernendp = kernend; @@ -188,7 +157,7 @@ bi_load32(char *args, int *howtop, int *bootdevp, vm_offset_t *bip, vm_offset_t bcopy(&kernend, md->md_data, sizeof kernend); /* copy module list and metadata */ - (void)bi_copymodules32(addr); + (void)md_copymodules(addr, false); ssym = esym = 0; md = file_findmetadata(kfp, MODINFOMD_SSYM); diff --git a/stand/i386/libi386/bootinfo64.c b/stand/i386/libi386/bootinfo64.c index 18ed4af3e27f..8b5eb8c1db93 100644 --- a/stand/i386/libi386/bootinfo64.c +++ b/stand/i386/libi386/bootinfo64.c @@ -45,40 +45,6 @@ __FBSDID("$FreeBSD$"); #include "geliboot.h" #endif -/* - * We have 8 byte alignment for 64-bit targets. This code is compiled as 64-bit - * code... - */ -#define MOD_ALIGN(l) roundup(l, sizeof(uint64_t)) - -static vm_offset_t -bi_copymodules64(vm_offset_t addr) -{ - struct preloaded_file *fp; - struct file_metadata *md; - int c; - uint64_t v; - - c = addr != 0; - /* start with the first module on the list, should be the kernel */ - for (fp = file_findfile(NULL, NULL); fp != NULL; fp = fp->f_next) { - - MOD_NAME(addr, fp->f_name, c); /* this field must come first */ - MOD_TYPE(addr, fp->f_type, c); - if (fp->f_args) - MOD_ARGS(addr, fp->f_args, c); - v = fp->f_addr; - MOD_ADDR(addr, v, c); - v = fp->f_size; - MOD_SIZE(addr, v, c); - for (md = fp->f_metadata; md != NULL; md = md->md_next) - if (!(md->md_type & MODINFOMD_NOCOPY)) - MOD_METADATA(addr, md, c); - } - MOD_END(addr, c); - return(addr); -} - /* * Check to see if this CPU supports long mode. */ @@ -197,7 +163,7 @@ bi_load64(char *args, vm_offset_t *modulep, #endif bi_load_vbe_data(kfp); - size = bi_copymodules64(0); + size = md_copymodules(0, true); /* copy our environment */ envp = roundup(addr + size, PAGE_SIZE); @@ -216,7 +182,7 @@ bi_load64(char *args, vm_offset_t *modulep, bcopy(&envp, md->md_data, sizeof envp); /* copy module list and metadata */ - (void)bi_copymodules64(*modulep); + (void)md_copymodules(*modulep, true); return(0); } diff --git a/stand/loader.mk b/stand/loader.mk index aa88122cb7a1..9fa4c74e2501 100644 --- a/stand/loader.mk +++ b/stand/loader.mk @@ -6,6 +6,7 @@ CFLAGS+=-I${LDRSRC} SRCS+= boot.c commands.c console.c devopen.c interp.c SRCS+= interp_backslash.c interp_parse.c ls.c misc.c +SRCS+= modinfo.c SRCS+= module.c nvstore.c pnglite.c tslog.c CFLAGS.module.c += -I$(SRCTOP)/sys/teken -I${SRCTOP}/contrib/pnglite diff --git a/stand/userboot/userboot/bootinfo32.c b/stand/userboot/userboot/bootinfo32.c index a717f4ad1f5a..8203f90c98fe 100644 --- a/stand/userboot/userboot/bootinfo32.c +++ b/stand/userboot/userboot/bootinfo32.c @@ -43,36 +43,6 @@ __FBSDID("$FreeBSD$"); static struct bootinfo bi; -/* - * We have 4 byte alignment for 32-bit targets. - */ -#define MOD_ALIGN(l) roundup(l, sizeof(uint32_t)) - -static vm_offset_t -bi_copymodules32(vm_offset_t addr) -{ - struct preloaded_file *fp; - struct file_metadata *md; - int c; - - c = addr != 0; - /* start with the first module on the list, should be the kernel */ - for (fp = file_findfile(NULL, NULL); fp != NULL; fp = fp->f_next) { - - MOD_NAME(addr, fp->f_name, c); /* this field must come first */ - MOD_TYPE(addr, fp->f_type, c); - if (fp->f_args) - MOD_ARGS(addr, fp->f_args, c); - MOD_ADDR(addr, fp->f_addr, c); - MOD_SIZE(addr, fp->f_size, c); - for (md = fp->f_metadata; md != NULL; md = md->md_next) - if (!(md->md_type & MODINFOMD_NOCOPY)) - MOD_METADATA(addr, md, c); - } - MOD_END(addr, c); - return(addr); -} - /* * Load the information expected by an i386 kernel. * @@ -157,7 +127,7 @@ bi_load32(char *args, int *howtop, int *bootdevp, vm_offset_t *bip, vm_offset_t /* Figure out the size and location of the metadata */ *modulep = addr; - size = bi_copymodules32(0); + size = md_copymodules(0, false); kernend = roundup(addr + size, PAGE_SIZE); *kernendp = kernend; @@ -166,7 +136,7 @@ bi_load32(char *args, int *howtop, int *bootdevp, vm_offset_t *bip, vm_offset_t bcopy(&kernend, md->md_data, sizeof kernend); /* copy module list and metadata */ - (void)bi_copymodules32(addr); + (void)md_copymodules(addr, false); ssym = esym = 0; md = file_findmetadata(kfp, MODINFOMD_SSYM); diff --git a/stand/userboot/userboot/bootinfo64.c b/stand/userboot/userboot/bootinfo64.c index 773f59474bf4..6d711cf51759 100644 --- a/stand/userboot/userboot/bootinfo64.c +++ b/stand/userboot/userboot/bootinfo64.c @@ -40,40 +40,6 @@ __FBSDID("$FreeBSD$"); #include "modinfo.h" #include "libuserboot.h" -/* - * We have 8 byte alignment for 64-bit targets. This code is compiled as 32-bit - * code... - */ -#define MOD_ALIGN(l) roundup(l, sizeof(uint64_t)) - -static vm_offset_t -bi_copymodules64(vm_offset_t addr) -{ - struct preloaded_file *fp; - struct file_metadata *md; - int c; - uint64_t v; - - c = addr != 0; - /* start with the first module on the list, should be the kernel */ - for (fp = file_findfile(NULL, NULL); fp != NULL; fp = fp->f_next) { - - MOD_NAME(addr, fp->f_name, c); /* this field must come first */ - MOD_TYPE(addr, fp->f_type, c); - if (fp->f_args) - MOD_ARGS(addr, fp->f_args, c); - v = fp->f_addr; - MOD_ADDR(addr, v, c); - v = fp->f_size; - MOD_SIZE(addr, v, c); - for (md = fp->f_metadata; md != NULL; md = md->md_next) - if (!(md->md_type & MODINFOMD_NOCOPY)) - MOD_METADATA(addr, md, c); - } - MOD_END(addr, c); - return(addr); -} - /* * Check to see if this CPU supports long mode. */ @@ -190,7 +156,7 @@ bi_load64(char *args, vm_offset_t *modulep, vm_offset_t *kernendp) /* Figure out the size and location of the metadata */ *modulep = addr; - size = bi_copymodules64(0); + size = md_copymodules(0, true); kernend = roundup(addr + size, PAGE_SIZE); *kernendp = kernend; @@ -199,7 +165,7 @@ bi_load64(char *args, vm_offset_t *modulep, vm_offset_t *kernendp) bcopy(&kernend, md->md_data, sizeof kernend); /* copy module list and metadata */ - (void)bi_copymodules64(addr); + (void)md_copymodules(addr, true); return(0); }