From patchwork Tue Oct 7 17:05:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 559 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856809; bh=zjAwPyQAyG8UiswvLy/3B4KkBzYtZR9+AUPCixGY/SI=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=WkZgcNPQQx777O0a82utG9wo/Epf37GCA5AdNsm5zOZmMP6ZN2Hp4nLUl0V/562la qgARUSXMKFL5Fdr9/+dfCXHdejmLnyBCGtk8WrJ1lXyvvIo5zq0750akAQ3T2y39wR KA6TVIaJwarFte0lZLjs9HLa/v66jIp5+JKpRsx24D7evEbykHoEhzcQ7JoOXXROEN 01f3mGXMIKVmRDgwvUqYDWoLVQ2qK8zI+zepgfSwlItBRT43Wt0JYkqUQhyGVIOYnW k86hRYWVrAaIJP3UFCNvnskCeatnS/EC/t3yHf/Pp3SuVXWtBC7j8C5ak8NhLVePtu 4PNddOj42uQ0A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0664467F72 for ; Tue, 7 Oct 2025 11:06:49 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id NtldiW2FaUWw for ; Tue, 7 Oct 2025 11:06:48 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856808; bh=zjAwPyQAyG8UiswvLy/3B4KkBzYtZR9+AUPCixGY/SI=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=ElJ0lbJadKQy4hTt/jentEUYbn3wdcAcQ6JkhpNyEjW842Hhs0t3CywWHq2zSd6H5 pMSrAARJS8fGOjCio6Eo+zQH6Sn+L8F/+bliXmUta22OfNMHweUH1c8CoPNDH65tN5 4AEud2x3BUwD0h8fcnjZ9G2uJLmQ5ee4M+3gp34Jt1ZhAKUXQhf2HKTpVO613qbN9S mBkrDYf+AmWvEsmJViI7en4IcKsjFOZ1AIPN7DL/t/jbM5wMtk9zID96VC6VLO550B FTsI18BuTka6mDwUcvxSope2lWqJCAiPQP8DKo9QLUMtJSNucEl45//4p7N0xAtDyH V6YEnIO2KY1kw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EA41A67DD0 for ; Tue, 7 Oct 2025 11:06:48 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856807; bh=AINa3BI9+CGpKiHjMZU04wSCqwcLtC0TqbW2RI8ryNI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=drvewIcE8iB3DXvHaTWpnoMq4X7dAYrbeEBIRSgIv8TzIE16Q6efKNxuWcTqJYbje FBjt9//VPJLjgTX4vs3Xlx2/K9p8Fu7rFhEOvX2bEdYKidj7ZJai1AL5NN4gID0h7p iopUVZncE6rDmG7Rq/1/FyXHlV0ggKqfd4Nk2vL8o5kcFDSyYXQGRu1zj5muLYko9l Q+881vm3F+bBellRjhK//Acyv/5xobTBtrJmofbLWaC8Cn6kXbW4HIWDCgot3XuUAX fKM4l7vfDWkjL+3Pcqmf51De1I5X2U38WYR7m4eZONIgimXdpLEHgCXtwPNYhz+xC+ hnZBHzYACNAEA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1D19E67F1E; Tue, 7 Oct 2025 11:06:47 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id mMYRKAf_idLa; Tue, 7 Oct 2025 11:06:47 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856802; bh=pfPIL9XEqgO2zCFwqufgxqaHE0S3xupuPdT2MtLNpYk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MvFl5N8AQm8xM6Xdk9Uz+pfMBbldJGbI8C0e4ueUY+GyWag79LndtPNIXC8VnWIw1 +igryzBY3fJenVLL/Ke+kuPopaznQSf+RcYbPOqY8bdJwa95QucpTjfYwQpOMqvbhh DnoB2KQ1CjwFIZHsUs1bdtNNa9IldQiQJRXo6g7f1WxtmsEjJ12oQhZMwjioiK8TMI H3zPAgH/VBufknDlIEEcZE5zBpsDVjVCNw5pUaX83gkZZF2CpSR5WK2ibJG0Z6FB+g lQ+2tM7Gw7/I/Trj/GkAHE/1JqfdVs5WJ9qgxBq3iKHtFuptiWueOm//eOcsWsj38d UpJlfNcPs+PQA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 2426B67ECE; Tue, 7 Oct 2025 11:06:42 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 7 Oct 2025 11:05:26 -0600 Message-ID: <20251007170549.541981-13-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251007170549.541981-1-sjg@u-boot.org> References: <20251007170549.541981-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: VA5TP3TPGANEJ43C2EPURXNN6FDZPFHM X-Message-ID-Hash: VA5TP3TPGANEJ43C2EPURXNN6FDZPFHM X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 12/20] efi: app: Detect running under QEMU List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass When the app is running under QEMU we may wish to do some things differently. Add a flag for this and use the SMBIOS tables to detect it. Co-developed-by: Claude Signed-off-by: Simon Glass --- (no changes since v1) include/asm-generic/global_data.h | 6 ++++++ lib/efi_client/efi_app.c | 25 ++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index 8b59df66ec5..cff9066de53 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -764,6 +764,12 @@ enum gd_flags { * For now, this just avoids console output on startup */ GD_FLG_ULIB = 0x10000000, + /** + * @GD_FLG_EMUL: Running in an emulator (e.g. QEMU) + * + * Detected from SMBIOS or other platform information + */ + GD_FLG_EMUL = 0x20000000, }; #if CONFIG_IS_ENABLED(ULIB) diff --git a/lib/efi_client/efi_app.c b/lib/efi_client/efi_app.c index 00003c27ec5..1d5a88b4827 100644 --- a/lib/efi_client/efi_app.c +++ b/lib/efi_client/efi_app.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -179,6 +180,27 @@ static void scan_tables(struct efi_system_table *sys_table) } } +static bool detect_emulator(void) +{ + struct smbios_info info; + struct smbios_type1 *t1; + const char *manufacturer; + + /* Check if running in QEMU by looking at SMBIOS manufacturer */ + if (!smbios_locate(gd_smbios_start(), &info)) { + t1 = (void *)smbios_get_header(&info, + SMBIOS_SYSTEM_INFORMATION); + if (t1) { + manufacturer = smbios_get_string(&t1->hdr, + t1->manufacturer); + if (manufacturer && !strcmp(manufacturer, "QEMU")) + return true; + } + } + + return false; +} + static void find_protocols(struct efi_priv *priv) { efi_guid_t guid = EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID; @@ -415,7 +437,8 @@ efi_status_t EFIAPI efi_main(efi_handle_t image, printf("starting\n"); - board_init_f(GD_FLG_SKIP_RELOC); + board_init_f(GD_FLG_SKIP_RELOC | + (detect_emulator() ? GD_FLG_EMUL : 0)); gd = gd->new_gd; board_init_r(NULL, 0); free_memory(priv);