From nobody Fri Sep 20 14:59:22 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 4X9FsQ5YFZz5XT22; Fri, 20 Sep 2024 14:59:22 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4X9FsQ49RTz4Nl2; Fri, 20 Sep 2024 14:59:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1726844362; 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=zrGCSgwKlcJrZafU9aAuaVfOHiLcsEpOU7dNDbZ5MKU=; b=mU49HpKL/s1IQ+IHdGZF/fzuqZbMyUVOaB2sSyn6qLBGhyLf2/Rl2YF0z60KZwAEqOTqK5 TPwQl3OzhYUcYARj4QynqVQAIzoosUKD8HuHr2mOVv1HHzyvTatRSkelAKXIomph9t2wo4 gUgMCuXnMStQkevoqVRdZpWcDJbvJvYlgvVXm3lJOu0IIK3441/U9HHlJTIhRLF8YoGXfT WFIiD2sYnsGLRAprzait/t3VoTecMB2hAboW2oXPdbb6sfj+rU2uZdTldPtIkkUceRpdCX Hcyw9uPey9za2DqXxmU5V8iWpH9BPczOzOWaZPPL1C++uw6AkGtB5E+EHNVi8g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1726844362; a=rsa-sha256; cv=none; b=iFKEQ3+dg+XYKpqWUg4/hF+KldApRvDc4puyh9DRwAcsAndt4PNgXp3ckbwC31XNpY7flB a464QPKtHLdNPzaQXICqgM76KGbVHmPegDW+nRSDkYT8KofH9d0d7P825DV+9+oR8ODNND TQOeMOvJ2oAZlej6c/qQrQ5KICKoTrUJoEP298aFDJSDSTW5v0b8ReeeLWlzKfjrI7mxnv 5AnnNgBybBv5w6NP+5EogT6vd+Gvm5TbyHYxdhDPwQgx8lUNLby+1x8Sh1urEMb8oymkBe 5pNP+qgMo9MJmJjTLnWBW/YxL2eCAqWelJgsKD+pW3YbtyyaTv4hOnUOw6VQ+w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1726844362; 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=zrGCSgwKlcJrZafU9aAuaVfOHiLcsEpOU7dNDbZ5MKU=; b=HDeBPqXxawiqS+mxfPekEBOuZIgYb7ZC67HD+35dsCagQOA7LLOWlGV8GOOrwEDDq4vR5X 2s7n8OsMooZjitvnlBtOdCynL62RURBqOEAjxKpxNWRUX9PhOBaSH7W8pefFU7diVOj9Mb z+kAmvE7HrEZXSi3JqDu/f3xyiWOxHlP881RKvqdrCkRBzYSL0B2A3v2tufwHbE04lDNT0 gn8aIXxFInkeKBWIFiG0frkR/m6uUml6ub7lnuI8682YVEaX0rMe5aNuK98b/CjwVBxi4b Ys1P6LkK1otywLPtgHMesZ083OpRMUodi9KoAxYONdVtv8GqQ4lQ46NCMqD90Q== 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 4X9FsQ2db6zv3v; Fri, 20 Sep 2024 14:59:22 +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 48KExMrt046816; Fri, 20 Sep 2024 14:59:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 48KExMDN046813; Fri, 20 Sep 2024 14:59:22 GMT (envelope-from git) Date: Fri, 20 Sep 2024 14:59:22 GMT Message-Id: <202409201459.48KExMDN046813@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: b538d4911004 - main - Add a new sysctl in order to diffrentiate UEFI architectures 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: b538d4911004ca541507166b8ec9689d2e87d1aa Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=b538d4911004ca541507166b8ec9689d2e87d1aa commit b538d4911004ca541507166b8ec9689d2e87d1aa Author: Ahmad Khalifa AuthorDate: 2024-06-03 01:40:43 +0000 Commit: Warner Losh CommitDate: 2024-09-20 14:45:09 +0000 Add a new sysctl in order to diffrentiate UEFI architectures With the new 32-bit UEFI loader, it's convenient to have a sysctl to figure out how we booted. Can be accessed at machdep.efi_arch Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1098 --- stand/efi/loader/bootinfo.c | 8 +++++++- sys/amd64/amd64/machdep.c | 21 +++++++++++++++++++++ sys/x86/include/metadata.h | 1 + 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/stand/efi/loader/bootinfo.c b/stand/efi/loader/bootinfo.c index 5afb4c78353e..2961b8b97fb7 100644 --- a/stand/efi/loader/bootinfo.c +++ b/stand/efi/loader/bootinfo.c @@ -447,9 +447,15 @@ bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp, bool exit_bs) module = *modulep; file_addmetadata(kfp, MODINFOMD_MODULEP, sizeof(module), &module); #endif -#if defined(EFI) && !defined(__i386__) +#ifdef EFI +#ifndef __i386__ file_addmetadata(kfp, MODINFOMD_FW_HANDLE, sizeof(ST), &ST); #endif +#if defined(__amd64__) || defined(__i386__) + file_addmetadata(kfp, MODINFOMD_EFI_ARCH, sizeof(MACHINE_ARCH), + MACHINE_ARCH); +#endif +#endif #ifdef LOADER_GELI_SUPPORT geli_export_key_metadata(kfp); #endif diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index f4b3b9702e00..5dbc41553452 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -1689,6 +1689,27 @@ SYSCTL_PROC(_machdep, OID_AUTO, efi_map, efi_map_sysctl_handler, "S,efi_map_header", "Raw EFI Memory Map"); +static int +efi_arch_sysctl_handler(SYSCTL_HANDLER_ARGS) +{ + char *arch; + caddr_t kmdp; + + kmdp = preload_search_by_type("elf kernel"); + if (kmdp == NULL) + kmdp = preload_search_by_type("elf64 kernel"); + + arch = (char *)preload_search_info(kmdp, + MODINFO_METADATA | MODINFOMD_EFI_ARCH); + if (arch == NULL) + return (0); + + return (SYSCTL_OUT_STR(req, arch)); +} +SYSCTL_PROC(_machdep, OID_AUTO, efi_arch, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, + efi_arch_sysctl_handler, "A", "EFI Firmware Architecture"); + void spinlock_enter(void) { diff --git a/sys/x86/include/metadata.h b/sys/x86/include/metadata.h index dbc6d3275e53..b3eb4b16c1ba 100644 --- a/sys/x86/include/metadata.h +++ b/sys/x86/include/metadata.h @@ -34,6 +34,7 @@ #define MODINFOMD_EFI_FB 0x1005 #define MODINFOMD_MODULEP 0x1006 #define MODINFOMD_VBE_FB 0x1007 +#define MODINFOMD_EFI_ARCH 0x1008 struct efi_map_header { uint64_t memory_size;