Received: by 2002:a17:504:6810:b0:1be9:327d:8ee3 with SMTP id f16csp96634njm; Tue, 4 Mar 2025 04:49:24 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUscXVNirWR+kxY+hhEovrTofGpSYtgGBb+3CidgsCokPLVLF/5doCzG5yrdHM6ntOTdpA469UjxJ+IeA==@linaro.org X-Google-Smtp-Source: AGHT+IEttaNWYyq7y/4qMmKv+s32CbLkn/NYEU6edy+/V+Um/h6fwQAZ6XW9Umplqh7zhSOTjq0a X-Received: by 2002:a05:620a:268b:b0:7c3:ca0d:6ba2 with SMTP id af79cd13be357-7c3ca0d715emr587451785a.58.1741092564599; Tue, 04 Mar 2025 04:49:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1741092564; cv=none; d=google.com; s=arc-20240605; b=WhCvEftg4rsx6xFzbhSuLGYeQOgNaqoM2iOmGaDaR23YxdMi0+nN2gvmvAZOkXvTYF +VpOov29USWv3dTjxarOcFBR+ObbE8GCIzBxJLxloed0K1wPgTgdJm5eVdTPirnEDGRD 6Ttc5KshFMo8t4n2/OBsQlhezpvRqAWOzVvNO+Arbvl2bphm2gp557DfPbAqlDrKl8l3 3b+IzEK4caj/0Xh3Kb9CYBzle+YhlaDjEfSbPnmkiH75dbOWGGEnlI/w0PQInNmSG/UQ DlGZ1Yxsnf3klkgxiOsc/Fr1OCLcHJYn0JdisOsr4wXm5bLdFpIia9zAKM+1VufetgZr 0Ecg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=gkcyaZ27h2WsA2IHdLuCkDhTgUP4RBoCBo8IPYTJMjw=; fh=AUxCU78jacJE1vSghMJJha3+F2+VikVKZl38eSKs5/I=; b=h7COLIiDhqfCxlPpTC4qQo1wdXhTFaRyzxiL1RZXiL4ubmYBYAqzQdmq8loRO7nk40 bQF9246WoFWFYLa/+sxewLjPCeyMY3lFf4reMGpNmpdzoPclNBi5yRrALVc73Qojh3p9 DPYr2NpCkVGOJUMM78T0bFr9t6IS+7rgWupZ2hOkNMBiE6Mkuw5ma5F30pqn5Y/avbgk BPFp0RqHptUmqWvADRV7aI4kF3E6nrhpOITZr5+Kc32cn3w44ZE/iERU0nHda96HYHtk nPOl3tbhiQJ/6SzdWB92KdyCOu+g8fKFO1UZTxCjjdh5v/mNueb41dpbBvM0M4Zq5/nE ViAg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MtzfkzLu; spf=pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7c3d0b58cd2si83014785a.60.2025.03.04.04.49.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Mar 2025 04:49:24 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MtzfkzLu; spf=pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tpRhM-0004ff-HG; Tue, 04 Mar 2025 07:48:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tpRhI-0004ei-Sh for qemu-devel@nongnu.org; Tue, 04 Mar 2025 07:48:32 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tpRhF-0006he-P3 for qemu-devel@nongnu.org; Tue, 04 Mar 2025 07:48:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741092508; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gkcyaZ27h2WsA2IHdLuCkDhTgUP4RBoCBo8IPYTJMjw=; b=MtzfkzLu/sFQyQJF5XNjNfocOJMk5mg2ZOxXLdeGOTnyBpYB+2vAIWkmLDac4t1zy9nm81 pyfAANnIjDt4NMK8kngAesqeIePhOsSWyWualRBqB24yXB0LJ2L1TGzm98iEZ2+yfhp+xr ZdqCV3OyEfq2/SyBZ1l3aFYZCSurLx0= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-570-9L6nYouiMkCypSe16qSyxw-1; Tue, 04 Mar 2025 07:48:22 -0500 X-MC-Unique: 9L6nYouiMkCypSe16qSyxw-1 X-Mimecast-MFC-AGG-ID: 9L6nYouiMkCypSe16qSyxw_1741092500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6009F1954B20; Tue, 4 Mar 2025 12:48:19 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.44.32.122]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A30841956048; Tue, 4 Mar 2025 12:48:17 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 3B4931800392; Tue, 04 Mar 2025 13:48:15 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Richard Henderson , Marcel Apfelbaum , "Michael S. Tsirkin" , Eric Blake , Paolo Bonzini , Gerd Hoffmann , Peter Maydell , qemu-arm@nongnu.org, Michael Roth , Markus Armbruster , Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 01/24] Add support for etc/hardware-info fw_cfg file Date: Tue, 4 Mar 2025 13:47:49 +0100 Message-ID: <20250304124815.591749-2-kraxel@redhat.com> In-Reply-To: <20250304124815.591749-1-kraxel@redhat.com> References: <20250304124815.591749-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org Sender: qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org X-TUID: PIJWe/cXz78J edk2 looks for the etc/hardware-info fw_cfg file to discover hardware which can not easily be found in other ways. Entries consist of a header with hardware type and entry size (HARDWARE_INFO_HEADER), followed by the actual hardware description (which is type specific). The file can have multiple entries. This patch adds the infrastructure to add entries to the file and an entry struct for simple devices (HARDWARE_INFO_SIMPLE_DEVICE) which have an mmio address only. Signed-off-by: Gerd Hoffmann Message-ID: <20250225163031.1409078-2-kraxel@redhat.com> --- include/hw/uefi/hardware-info.h | 35 +++++++++++++++++++++++++++++++++ hw/uefi/hardware-info.c | 31 +++++++++++++++++++++++++++++ hw/uefi/meson.build | 1 + 3 files changed, 67 insertions(+) create mode 100644 include/hw/uefi/hardware-info.h create mode 100644 hw/uefi/hardware-info.c create mode 100644 hw/uefi/meson.build diff --git a/include/hw/uefi/hardware-info.h b/include/hw/uefi/hardware-info.h new file mode 100644 index 000000000000..94c38cff2007 --- /dev/null +++ b/include/hw/uefi/hardware-info.h @@ -0,0 +1,35 @@ +/* + * SPDX-License-Identifier: GPL-2.0-or-later + * + * pass hardware information to uefi + * + * see OvmfPkg/Library/HardwareInfoLib/ in edk2 + */ +#ifndef QEMU_UEFI_HARDWARE_INFO_H +#define QEMU_UEFI_HARDWARE_INFO_H + +/* data structures */ + +typedef enum { + HardwareInfoTypeUndefined = 0, + HardwareInfoTypeHostBridge = 1, + HardwareInfoQemuUefiVars = 2, +} HARDWARE_INFO_TYPE; + +typedef struct { + union { + uint64_t uint64; + HARDWARE_INFO_TYPE value; + } type; + uint64_t size; +} HARDWARE_INFO_HEADER; + +typedef struct { + uint64_t mmio_address; +} HARDWARE_INFO_SIMPLE_DEVICE; + +/* qemu functions */ + +void hardware_info_register(HARDWARE_INFO_TYPE type, void *info, uint64_t size); + +#endif /* QEMU_UEFI_HARDWARE_INFO_H */ diff --git a/hw/uefi/hardware-info.c b/hw/uefi/hardware-info.c new file mode 100644 index 000000000000..930502a4df3a --- /dev/null +++ b/hw/uefi/hardware-info.c @@ -0,0 +1,31 @@ +/* + * SPDX-License-Identifier: GPL-2.0-or-later + * + * pass hardware information to uefi + * + * see OvmfPkg/Library/HardwareInfoLib/ in edk2 + */ + +#include "qemu/osdep.h" + +#include "hw/nvram/fw_cfg.h" +#include "hw/uefi/hardware-info.h" + +static void *blob; +static uint64_t blobsize; + +void hardware_info_register(HARDWARE_INFO_TYPE type, void *info, uint64_t infosize) +{ + HARDWARE_INFO_HEADER hdr = { + .type.value = cpu_to_le64(type), + .size = cpu_to_le64(infosize), + }; + + blob = g_realloc(blob, blobsize + sizeof(hdr) + infosize); + memcpy(blob + blobsize, &hdr, sizeof(hdr)); + blobsize += sizeof(hdr); + memcpy(blob + blobsize, info, infosize); + blobsize += infosize; + + fw_cfg_modify_file(fw_cfg_find(), "etc/hardware-info", blob, blobsize); +} diff --git a/hw/uefi/meson.build b/hw/uefi/meson.build new file mode 100644 index 000000000000..a8b168941255 --- /dev/null +++ b/hw/uefi/meson.build @@ -0,0 +1 @@ +system_ss.add(files('hardware-info.c')) -- 2.48.1