From patchwork Mon Oct 6 23:21:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 540 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=1759793007; bh=OVufrC9/UToOaNlCJvfKd31nWKSsOMszQQ7hXHaxivE=; 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=L9U6K92jXPhl2MB0cwH3rkbwSu+VLF7C6gDrV50M53HMizSCi0V1FohKhd6BCias6 rI6IQQm0S2xY9Oz9gXLphBtya0ohFHN8eExtnwEGYgMWhqLyF4RZFWK0s9onHzRC8O yol+YMpUdNJ9m03AQ4Tm8HE4vVA/bcQKPN9cM3CDdH6LjPPU4bGyXeGCyeVhsTIxZU DvReV4JuktivbxZOxCrRQXcdI+Uln0FmIbMD4R975T/yB9MjUWAeC2gfN/B9lC8jKS Y8hVY7nIWSgvZ9yPL9TlbD4hIjBX3SlOVF7qLBHBd9Hi4WnlmNUw7hWnr6WaG0OKe2 ZeIWcxVnptw1g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C49CD67FC6 for ; Mon, 6 Oct 2025 17:23:27 -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 LGtR-5RBC0UX for ; Mon, 6 Oct 2025 17:23:27 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759793007; bh=OVufrC9/UToOaNlCJvfKd31nWKSsOMszQQ7hXHaxivE=; 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=L9U6K92jXPhl2MB0cwH3rkbwSu+VLF7C6gDrV50M53HMizSCi0V1FohKhd6BCias6 rI6IQQm0S2xY9Oz9gXLphBtya0ohFHN8eExtnwEGYgMWhqLyF4RZFWK0s9onHzRC8O yol+YMpUdNJ9m03AQ4Tm8HE4vVA/bcQKPN9cM3CDdH6LjPPU4bGyXeGCyeVhsTIxZU DvReV4JuktivbxZOxCrRQXcdI+Uln0FmIbMD4R975T/yB9MjUWAeC2gfN/B9lC8jKS Y8hVY7nIWSgvZ9yPL9TlbD4hIjBX3SlOVF7qLBHBd9Hi4WnlmNUw7hWnr6WaG0OKe2 ZeIWcxVnptw1g== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B32C667F5A for ; Mon, 6 Oct 2025 17:23:27 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759793005; bh=rFPSV0HicL1aV2kjOT57GcPk5WsZ5VwRcElJ6XBRWhM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FQUHx3veJUcrB7bCzGfy0g/CtWjxAvLI2HdMIbIVoTc0DiCGYFM6n2OnC/pjF6C+E PK5kdTc/2jEe3WsAL2EdPihXAEX20Mb9Z6oxbwfNhj0cjdVQB8FGr7mudutBpjHFtJ NjRmzK94iULd3Rtm3yK92Wm70grlYRGPBc9ite4rEd8Bdman3ouQuhd1ncZR37kAob y5ozN+JjuDsN19wOLfOztAjlth+oCOhFCuGfrABUoqpWhw9MRM7/eDjSWZhUORyIKh dpbRqdRvsvkbafqpCPQVALET8LvJVSR1Rybicw+B93e0baIr5u4wqwIyNfzxJ26Y5f Kler/YnQ0mRmw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 62A3267DB4; Mon, 6 Oct 2025 17:23:25 -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 jTMvNlZeVPzA; Mon, 6 Oct 2025 17:23:25 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759793001; bh=kM9qe7jnLsSqj+hXsKu1RrOJn6z9xXzKmWyZClloKmw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n54uyYCcbcMa1MjkZHHfS64D4zMADdKPTVk+y6ExYShh3AatwOXvb4ObV7NB1ZEpf +7NcgvtR4G/IFtdiTV7kKQoHPt8sVTEYOEdMhgZmJnaJg0dqzzuA9KaMVM1e9KO3qX O1lDcK5iUs488Amv2j5lP5E0UmU9ERZYuFNW78X4/rYidiBeTriWRgmoCe2sSAeKrH bXDxAKCOJ9O588mGgDw46iFnnnt6GLkzAIa96SMi3bAnEv+d0jLEnoNUxE015WbDnc oRIOpIoYpFbSMbf2+8K1Ij5T74Q9GUOKyFinDlzmipA9NQdvtd6JSfgKMwbDNbLgHc ljc+SyJpEkqMw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 6C7F767F3F; Mon, 6 Oct 2025 17:23:20 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 6 Oct 2025 17:21:51 -0600 Message-ID: <20251006232236.2091941-10-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251006232236.2091941-1-sjg@u-boot.org> References: <20251006232236.2091941-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: WUA2SKV4REZRBLA7W3E37TKEUY7NHAHM X-Message-ID-Hash: WUA2SKV4REZRBLA7W3E37TKEUY7NHAHM 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 09/17] 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 --- 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);