From nobody Thu Dec 05 00:18:55 2024 X-Original-To: dev-commits-src-main@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 4Y3ZkR3fN6z5gRN3; Thu, 05 Dec 2024 00:18:55 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Y3ZkR26FZz4b5m; Thu, 5 Dec 2024 00:18:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733357935; 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=qDcQUrx2Asrf6Dh/D1zzAQo+EcySRoWw4kSDCtxLLhA=; b=fRDhcGvu6L4xP4oziwPvQIqKwklP3DcS5qvT7nlehd7c2NTD/ueWRnbMV04PFf6dWfqub0 XscG2pHhq+p7/Ao64JK0iEY/EvqYkwCrFMtefVWFUCFR3v96uWpGseN0L/tSo4pbB2ILHb X8SiFp4NNDtJ/qBANQHcmQcvillkHOo4uWVDlsAtANsG1UkYHSRck8e33n8/UrDOU1ndSG ZK5YX+AuYzlPp1/BRCNNb3YlmAq4sN2wor0j2oZBjSjMAhLew56V1YpHBhQOGJWmfdZrVd M5xJM/FgN7zxh/rXmBzO6Xna9Hicla5bsEuplWsy9wRezQW2kQ+Bf+huE/25Iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733357935; 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=qDcQUrx2Asrf6Dh/D1zzAQo+EcySRoWw4kSDCtxLLhA=; b=nWb7LeL3XmHzK8jUF8BeYW91tPZVjFWzw/A6woibs/czYc3VqKp0tCYJhQbUST9tLNsZVC j+Fbbrsh9Y8z4BhAUhKntcHP1KneQsrTKeYC+IxyhQn9l57k4C5/xER0w1SUoR7wKVZ0B9 YLhGKwkBL4ThGAQZ01OP/nyECv/gTHjCHsvig2v6X3lH/RbXvcwZn1QnD4JKz5DsRxojzQ Dnwwp+NPycG6DlFhvHP9Ve48k9KPOIg4vmLlQ7SVGGUzl1Xmqb+gVIwAvfCUuhACMpbEpD 1zO/+w4XFWJ/HHa9o0nsqynEGel82hdJeWkjgo+GvJIYCaxM0XvMGdg2xYxwCw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1733357935; a=rsa-sha256; cv=none; b=X0Bf2vtM2USy2INdmtNWPzImot4sYVwnxmwjw7WVSkcyRRRSuPDKfBQG7P9s9pldTXgMCK YKM06AXBZNYUssPAtspaU2fgeW7amzOuDCLIWU8ZQ9U479ypP0X+rAf/JCEvMfrW/2ueb1 Ji/Slg1dWmEjmMDWklkx2YgDSF0a5IKIVHKyUpwkh378Q4GXB3E8lY1IyEmjXj33Z8tENc tFq0kIsu896fl7nGPQtrScd1WArXFRU+ODwekpB05IPDZZH5pvhj+AfWRoKG0EZK6O6vor UIl1Sq0vv37/di56NHr/Dz3ltiGZZZZjBXPmVPxNiYr7RcYlE1Zo5YxChCLEdw== 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 4Y3ZkR1jnRzTg3; Thu, 5 Dec 2024 00:18:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4B50Itnl013416; Thu, 5 Dec 2024 00:18:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4B50Ite2013413; Thu, 5 Dec 2024 00:18:55 GMT (envelope-from git) Date: Thu, 5 Dec 2024 00:18:55 GMT Message-Id: <202412050018.4B50Ite2013413@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: ea0f267c8bf0 - main - stand/efi: move G(x) and M(x) macros to loader_efi.h List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: ea0f267c8bf07bafc53a50fe52e7cdf42e63c3f2 Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=ea0f267c8bf07bafc53a50fe52e7cdf42e63c3f2 commit ea0f267c8bf07bafc53a50fe52e7cdf42e63c3f2 Author: Ahmad Khalifa AuthorDate: 2024-09-27 16:01:27 +0000 Commit: Warner Losh CommitDate: 2024-12-05 00:19:17 +0000 stand/efi: move G(x) and M(x) macros to loader_efi.h These are often needed for copying to the staging area or just general page table calculations on amd64. Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1446 --- stand/efi/loader/arch/amd64/elf64_freebsd.c | 9 ++++----- stand/efi/loader/arch/i386/elf64_freebsd.c | 3 --- stand/efi/loader/copy.c | 3 --- stand/efi/loader/loader_efi.h | 4 ++++ stand/kboot/kboot/arch/amd64/elf64_freebsd.c | 9 ++++----- 5 files changed, 12 insertions(+), 16 deletions(-) diff --git a/stand/efi/loader/arch/amd64/elf64_freebsd.c b/stand/efi/loader/arch/amd64/elf64_freebsd.c index 3883c309e724..c4265aca035e 100644 --- a/stand/efi/loader/arch/amd64/elf64_freebsd.c +++ b/stand/efi/loader/arch/amd64/elf64_freebsd.c @@ -101,8 +101,7 @@ elf64_exec(struct preloaded_file *fp) ehdr = (Elf_Ehdr *)&(md->md_data); trampcode = copy_staging == COPY_STAGING_ENABLE ? - (vm_offset_t)0x0000000040000000 /* 1G */ : - (vm_offset_t)0x0000000100000000; /* 4G */; + (vm_offset_t)G(1) : (vm_offset_t)G(4); err = BS->AllocatePages(AllocateMaxAddress, EfiLoaderData, 1, (EFI_PHYSICAL_ADDRESS *)&trampcode); if (EFI_ERROR(err)) { @@ -117,7 +116,7 @@ elf64_exec(struct preloaded_file *fp) trampoline = (void *)trampcode; if (copy_staging == COPY_STAGING_ENABLE) { - PT4 = (pml4_entry_t *)0x0000000040000000; /* 1G */ + PT4 = (pml4_entry_t *)G(1); err = BS->AllocatePages(AllocateMaxAddress, EfiLoaderData, 3, (EFI_PHYSICAL_ADDRESS *)&PT4); if (EFI_ERROR(err)) { @@ -154,11 +153,11 @@ elf64_exec(struct preloaded_file *fp) /* * The L2 page slots are mapped with 2MB pages for 1GB. */ - PT2[i] = (pd_entry_t)i * (2 * 1024 * 1024); + PT2[i] = (pd_entry_t)i * M(2); PT2[i] |= PG_V | PG_RW | PG_PS; } } else { - PT4 = (pml4_entry_t *)0x0000000100000000; /* 4G */ + PT4 = (pml4_entry_t *)G(4); err = BS->AllocatePages(AllocateMaxAddress, EfiLoaderData, 9, (EFI_PHYSICAL_ADDRESS *)&PT4); if (EFI_ERROR(err)) { diff --git a/stand/efi/loader/arch/i386/elf64_freebsd.c b/stand/efi/loader/arch/i386/elf64_freebsd.c index 2c6be607dc4d..0dc16437d905 100644 --- a/stand/efi/loader/arch/i386/elf64_freebsd.c +++ b/stand/efi/loader/arch/i386/elf64_freebsd.c @@ -71,9 +71,6 @@ struct gdtr { #define GDT_RW 0x00020000000000 #define GDT_L 0x20000000000000 -#define M(x) ((x) * 1024 * 1024) -#define G(x) (1ULL * (x) * 1024 * 1024 * 1024) - typedef uint64_t p4_entry_t; typedef uint64_t p3_entry_t; typedef uint64_t p2_entry_t; diff --git a/stand/efi/loader/copy.c b/stand/efi/loader/copy.c index 90a55089ffc4..485ec152ae21 100644 --- a/stand/efi/loader/copy.c +++ b/stand/efi/loader/copy.c @@ -35,9 +35,6 @@ #include "loader_efi.h" -#define M(x) ((x) * 1024 * 1024) -#define G(x) (1ULL * (x) * 1024 * 1024 * 1024) - #if defined(__amd64__) #include #include diff --git a/stand/efi/loader/loader_efi.h b/stand/efi/loader/loader_efi.h index b2d7817b87dd..be991eeb9573 100644 --- a/stand/efi/loader/loader_efi.h +++ b/stand/efi/loader/loader_efi.h @@ -41,6 +41,10 @@ enum { extern int copy_staging; #endif +/* Useful for various calculations */ +#define M(x) ((x) * 1024 * 1024) +#define G(x) (1ULL * (x) * 1024 * 1024 * 1024) + extern EFI_LOADED_IMAGE *boot_img; int efi_autoload(void); diff --git a/stand/kboot/kboot/arch/amd64/elf64_freebsd.c b/stand/kboot/kboot/arch/amd64/elf64_freebsd.c index b0efbfe09629..495c4c0b320e 100644 --- a/stand/kboot/kboot/arch/amd64/elf64_freebsd.c +++ b/stand/kboot/kboot/arch/amd64/elf64_freebsd.c @@ -209,8 +209,7 @@ elf64_exec(struct preloaded_file *fp) #ifdef EFI trampcode = copy_staging == COPY_STAGING_ENABLE ? - (vm_offset_t)0x0000000040000000 /* 1G */ : - (vm_offset_t)0x0000000100000000; /* 4G */; + (vm_offset_t)G(1) : (vm_offset_t)G(4); err = BS->AllocatePages(AllocateMaxAddress, EfiLoaderData, 1, (EFI_PHYSICAL_ADDRESS *)&trampcode); if (EFI_ERROR(err)) { @@ -234,7 +233,7 @@ elf64_exec(struct preloaded_file *fp) #ifdef EFI if (copy_staging == COPY_STAGING_ENABLE) { - PT4 = (pml4_entry_t *)0x0000000040000000; /* 1G */ + PT4 = (pml4_entry_t *)G(1); err = BS->AllocatePages(AllocateMaxAddress, EfiLoaderData, 3, (EFI_PHYSICAL_ADDRESS *)&PT4); if (EFI_ERROR(err)) { @@ -271,11 +270,11 @@ elf64_exec(struct preloaded_file *fp) /* * The L2 page slots are mapped with 2MB pages for 1GB. */ - PT2[i] = (pd_entry_t)i * (2 * 1024 * 1024); + PT2[i] = (pd_entry_t)i * M(2); PT2[i] |= PG_V | PG_RW | PG_PS; } } else { - PT4 = (pml4_entry_t *)0x0000000100000000; /* 4G */ + PT4 = (pml4_entry_t *)G(4); err = BS->AllocatePages(AllocateMaxAddress, EfiLoaderData, 9, (EFI_PHYSICAL_ADDRESS *)&PT4); if (EFI_ERROR(err)) {