From nobody Sun May 12 20:53:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+111677+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+111677+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1700751760; cv=none; d=zohomail.com; s=zohoarc; b=j6j1ImOsSCCyvmjKsOYTydd9On/MhxK3S8zszqgxacuysfiQBXv183D00YcGvO/VVGKFhWDHAf17oLBGI4Kdtm0Qpult4Sq7+Ef+uXkhFHiPvGVqzOrEe8QDYETJgN45/P/NqcEW2xg1lHkgpAL1ijJWnoUI7yjs1mmQ4gT7XNE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700751760; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=4E6pSubrhbiX3gL0fi/avpzXRglmVXBiHwPbr4EHJ+E=; b=KxaFzt1SSeFRLDEKoNQicDIflzzQ36wUhD3ErFEFh4ZXRDaBMIEGSggtY1ujVicy0BiSh6hpTgM79lPQiamkwFeZmbFnbe1RRmZSDvdE9++l+8szPDBPhEyCjCYQVGcMWiiVs/jw0Glv1mejhcwjQM6CCMfdy9VjBLfjnOojgwo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+111677+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1700751760010839.0325759125798; Thu, 23 Nov 2023 07:02:40 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=f3GRNuEp0BeG5St4VZkRKXWX5FO4YvJMy73PuBO4XLk=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1700751759; v=1; b=OK/fcUglHMGrzl/Wg652i1lm7+nWoPFyZ7WPOP9+YFFlj207Op5+D2AZQEPsDhod8z/BH1yH u2Kdq7vUrC0BciosoWMj4Q+JbraVbr5Ypkqn2/FCuUnvtHzoAo/HEz0xqcWHsFuoazQyZ3IqF+M vAQBBti2qr4UaN65y/NnzECk= X-Received: by 127.0.0.2 with SMTP id OVx4YY1788612x5GUhnLEhuO; Thu, 23 Nov 2023 07:02:39 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web10.92691.1700751758554407946 for ; Thu, 23 Nov 2023 07:02:38 -0800 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-75-Ncke5Jo8MVi8ISWuaIRiig-1; Thu, 23 Nov 2023 10:02:36 -0500 X-MC-Unique: Ncke5Jo8MVi8ISWuaIRiig-1 X-Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 428FE83FC2B for ; Thu, 23 Nov 2023 15:02:36 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.193.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0ECEC1C060B0; Thu, 23 Nov 2023 15:02:36 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id D321418007A1; Thu, 23 Nov 2023 16:02:34 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Oliver Steffen , =?UTF-8?q?L=C3=A1szl=C3=B3=20=C3=89rsek?= , Gerd Hoffmann Subject: [edk2-devel] [PATCH 1/7] OvmfPkg: add IndustryStandard/QemuUefiVars.h Date: Thu, 23 Nov 2023 16:02:28 +0100 Message-ID: <20231123150234.117835-2-kraxel@redhat.com> In-Reply-To: <20231123150234.117835-1-kraxel@redhat.com> References: <20231123150234.117835-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,kraxel@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: Gcq4iSUIhjDIfNlUlZBX7jGYx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1700751761233100003 Content-Type: text/plain; charset="utf-8"; x-default="true" Add header file for the qemu uefi variable service device. This defines the registers of the device, the location in io address space (x86) and the device tree name (arm). Signed-off-by: Gerd Hoffmann --- .../Include/IndustryStandard/QemuUefiVars.h | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 OvmfPkg/Include/IndustryStandard/QemuUefiVars.h diff --git a/OvmfPkg/Include/IndustryStandard/QemuUefiVars.h b/OvmfPkg/Incl= ude/IndustryStandard/QemuUefiVars.h new file mode 100644 index 000000000000..64ca5628ca58 --- /dev/null +++ b/OvmfPkg/Include/IndustryStandard/QemuUefiVars.h @@ -0,0 +1,41 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause-Patent + * + * uefi-vars device - API of the virtual device for guest/host communicati= on. + * + * copied from qemu.git (include/hw/uefi/var-service-api.h) + */ + +#ifndef QEMU_UEFI_VAR_SERVICE_API_H +#define QEMU_UEFI_VAR_SERVICE_API_H + +/* isa: io range */ +#define UEFI_VARS_IO_BASE 0x520 + +/* sysbus: fdt node path */ +#define UEFI_VARS_FDT_NODE "qemu-uefi-vars" +#define UEFI_VARS_FDT_COMPAT "qemu,uefi-vars" + +/* registers */ +#define UEFI_VARS_REG_MAGIC 0x00 /* 16 bit */ +#define UEFI_VARS_REG_CMD_STS 0x02 /* 16 bit */ +#define UEFI_VARS_REG_BUFFER_SIZE 0x04 /* 32 bit */ +#define UEFI_VARS_REG_BUFFER_ADDR_LO 0x08 /* 32 bit */ +#define UEFI_VARS_REG_BUFFER_ADDR_HI 0x0c /* 32 bit */ +#define UEFI_VARS_REGS_SIZE 0x10 + +/* magic value */ +#define UEFI_VARS_MAGIC_VALUE 0xef1 + +/* command values */ +#define UEFI_VARS_CMD_RESET 0x01 +#define UEFI_VARS_CMD_MM 0x02 + +/* status values */ +#define UEFI_VARS_STS_SUCCESS 0x00 +#define UEFI_VARS_STS_BUSY 0x01 +#define UEFI_VARS_STS_ERR_UNKNOWN 0x10 +#define UEFI_VARS_STS_ERR_NOT_SUPPORTED 0x11 +#define UEFI_VARS_STS_ERR_BAD_BUFFER_SIZE 0x12 + +#endif /* QEMU_UEFI_VAR_SERVICE_API_H */ --=20 2.42.0 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#111677): https://edk2.groups.io/g/devel/message/111677 Mute This Topic: https://groups.io/mt/102767934/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sun May 12 20:53:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+111679+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+111679+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1700751762; cv=none; d=zohomail.com; s=zohoarc; b=Gi6ukHK1frAvXFQVeekIiBJMlncPZo11hLU8AP6KH+SCWLboZd7Dfh+OJjtYmG2HED5alEvqZSt5KE3fVJoKSFGgfkVw34XRQNW06TDCgSWySTznwobRDQHRT5Owti6+rEdAlxem8bBGiNv8x44e3Fpk0pmIsLArBKk3ImNCfn0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700751762; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=7tSkuZEJaWaXmgVUfEmq0orKhGoywBFzq8JbJvMWzRg=; b=R7cELe0BCa/iGK2cYww0EYuQ0npy1iyZw3d9tTfEN7E8nLkZdPkb+UaKrugx+JCUFwAlorXACfD2A7o5vDizT9hcO+fgxT/LmnMiht8f0YMxePa6tv43RNWhlgSZRYkidf/Clj1ixzCFsthxVjharFmDFYsuvPWSc7kd5AZuaw8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+111679+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1700751762488867.4997137565675; Thu, 23 Nov 2023 07:02:42 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=tBkfTlvjP1K6rxbgiFmnYr+4JtnuncRL+D/RM9sh+R8=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1700751762; v=1; b=JRl0uBpLJKM9Jd8Vf5ycjYX/XSGjUgf7jqTMTDizMJPptGx/eSWFExNjHsUhWoe0ICfGht6H 961G+n4neJLG+K8TVlcy9xMc8LXBEXbHIvJq4YRg37HmniWGttHlhrYZfnW548ffY8BS1JSrKRt menikZt+Ca6B0CgviuUo2xag= X-Received: by 127.0.0.2 with SMTP id WksmYY1788612xtYbDcffioC; Thu, 23 Nov 2023 07:02:42 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web11.93007.1700751761078057996 for ; Thu, 23 Nov 2023 07:02:41 -0800 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-640-yUjtKxnVPlO5Hg1sVIstbg-1; Thu, 23 Nov 2023 10:02:38 -0500 X-MC-Unique: yUjtKxnVPlO5Hg1sVIstbg-1 X-Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id E406189C561 for ; Thu, 23 Nov 2023 15:02:37 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.193.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5D09F492BE0; Thu, 23 Nov 2023 15:02:37 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id D6C4818009BA; Thu, 23 Nov 2023 16:02:34 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Oliver Steffen , =?UTF-8?q?L=C3=A1szl=C3=B3=20=C3=89rsek?= , Gerd Hoffmann Subject: [edk2-devel] [PATCH 2/7] OvmfPkg: add new VirtMmCommunicationDxe driver Date: Thu, 23 Nov 2023 16:02:29 +0100 Message-ID: <20231123150234.117835-3-kraxel@redhat.com> In-Reply-To: <20231123150234.117835-1-kraxel@redhat.com> References: <20231123150234.117835-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,kraxel@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: K9NeofcVvCGhzB5dVSpT3uhcx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1700751763362100011 Content-Type: text/plain; charset="utf-8"; x-default="true" EFI driver implementing the MmCommunication2Protocol, but instead of trapping to MM mode (SMM on x86, el3 on arm) trap to the host, using a virtual device. Moving the efi variable management to the host allows to have persistent efi variables without flash storage, and it also allows to have secure boot support without requiring MM mode to protect variable storage in flash. This patch brings the core code, and the x64 bits which talk to 'qemu -device uefi-vars-isa'. Signed-off-by: Gerd Hoffmann --- .../VirtMmCommunication.inf | 50 +++ .../VirtMmCommunication.h | 37 ++ OvmfPkg/VirtMmCommunicationDxe/QemuX64.c | 106 +++++ .../VirtMmCommunication.c | 380 ++++++++++++++++++ 4 files changed, 573 insertions(+) create mode 100644 OvmfPkg/VirtMmCommunicationDxe/VirtMmCommunication.inf create mode 100644 OvmfPkg/VirtMmCommunicationDxe/VirtMmCommunication.h create mode 100644 OvmfPkg/VirtMmCommunicationDxe/QemuX64.c create mode 100644 OvmfPkg/VirtMmCommunicationDxe/VirtMmCommunication.c diff --git a/OvmfPkg/VirtMmCommunicationDxe/VirtMmCommunication.inf b/OvmfP= kg/VirtMmCommunicationDxe/VirtMmCommunication.inf new file mode 100644 index 000000000000..a9998f3db8cd --- /dev/null +++ b/OvmfPkg/VirtMmCommunicationDxe/VirtMmCommunication.inf @@ -0,0 +1,50 @@ +#/** @file +# +# Virt MM Communicate driver +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +#**/ + +[Defines] + INF_VERSION =3D 0x0001001A + BASE_NAME =3D VirtMmCommunication + FILE_GUID =3D 0B807404-2D1C-4066-95F4-F28A58800185 + MODULE_TYPE =3D DXE_RUNTIME_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D VirtMmCommunication2Initialize + +[Sources] + VirtMmCommunication.c + +[Sources.X64] + QemuX64.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + +[LibraryClasses] + BaseMemoryLib + DebugLib + DxeServicesTableLib + HobLib + MemoryAllocationLib + UefiDriverEntryPoint + +[FeaturePcd] + gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache #= # CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdVariableCollectStatistics #= # CONSUMES + +[Protocols] + gEfiMmCommunication2ProtocolGuid ## PRODUCES + gEfiSmmVariableProtocolGuid ## PRODUCES + +[Guids] + gEfiEndOfDxeEventGroupGuid + gEfiEventExitBootServicesGuid + gEfiEventReadyToBootGuid + gSmmVariableWriteGuid + +[Depex] + gEfiCpuArchProtocolGuid diff --git a/OvmfPkg/VirtMmCommunicationDxe/VirtMmCommunication.h b/OvmfPkg= /VirtMmCommunicationDxe/VirtMmCommunication.h new file mode 100644 index 000000000000..32f9d16c42e3 --- /dev/null +++ b/OvmfPkg/VirtMmCommunicationDxe/VirtMmCommunication.h @@ -0,0 +1,37 @@ +/** @file + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef _VIRT_MM_COMM_DXE_H_ +#define _VIRT_MM_COMM_DXE_H_ + +/* communication buffer */ + +#define MAX_BUFFER_SIZE (64 * 1024) + +extern VOID *mCommunicateBuffer; +extern EFI_PHYSICAL_ADDRESS mCommunicateBufferPhys; + +/* arch specific hooks */ + +EFI_STATUS +EFIAPI +VirtMmHwInit ( + VOID + ); + +EFI_STATUS +EFIAPI +VirtMmHwComm ( + VOID + ); + +EFI_STATUS +EFIAPI +VirtMmHwVirtMap ( + VOID + ); + +#endif /* _VIRT_MM_COMM_DXE_H_ */ diff --git a/OvmfPkg/VirtMmCommunicationDxe/QemuX64.c b/OvmfPkg/VirtMmCommu= nicationDxe/QemuX64.c new file mode 100644 index 000000000000..6470cfc7f73b --- /dev/null +++ b/OvmfPkg/VirtMmCommunicationDxe/QemuX64.c @@ -0,0 +1,106 @@ +/** @file + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +#include +#include +#include + +#include "VirtMmCommunication.h" + +STATIC +EFI_STATUS +EFIAPI +VirtMmHwCommand ( + UINT32 Cmd + ) +{ + UINT32 Count; + UINT32 Sts; + + IoWrite16 (UEFI_VARS_IO_BASE + UEFI_VARS_REG_CMD_STS, Cmd); + for (Count =3D 0; Count < 100; Count++) { + Sts =3D IoRead16 (UEFI_VARS_IO_BASE + UEFI_VARS_REG_CMD_STS); + DEBUG ((DEBUG_VERBOSE, "%a: Sts: 0x%x\n", __func__, Sts)); + switch (Sts) { + case UEFI_VARS_STS_SUCCESS: + return RETURN_SUCCESS; + case UEFI_VARS_STS_BUSY: + CpuPause (); + break; + case UEFI_VARS_STS_ERR_NOT_SUPPORTED: + return RETURN_UNSUPPORTED; + case UEFI_VARS_STS_ERR_BAD_BUFFER_SIZE: + return RETURN_BAD_BUFFER_SIZE; + default: + return RETURN_DEVICE_ERROR; + } + } + + return RETURN_TIMEOUT; +} + +EFI_STATUS +EFIAPI +VirtMmHwInit ( + VOID + ) +{ + UINT32 Magic, AddrLo, AddrHi; + EFI_STATUS Status; + + Magic =3D IoRead16 (UEFI_VARS_IO_BASE + UEFI_VARS_REG_MAGIC); + if (Magic !=3D UEFI_VARS_MAGIC_VALUE) { + DEBUG (( + DEBUG_ERROR, + "%a: Magic value mismatch (0x%x !=3D 0x%x)\n", + __func__, + Magic, + UEFI_VARS_MAGIC_VALUE + )); + return RETURN_DEVICE_ERROR; + } + + DEBUG ((DEBUG_INFO, "%a: Magic 0x%x, good\n", __func__, Magic)); + + Status =3D VirtMmHwCommand (UEFI_VARS_CMD_RESET); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Reset failed: %d\n", __func__, Status)); + return Status; + } + + AddrLo =3D (UINT32)mCommunicateBufferPhys; + AddrHi =3D (UINT32)RShiftU64 (mCommunicateBufferPhys, 32); + IoWrite32 (UEFI_VARS_IO_BASE + UEFI_VARS_REG_BUFFER_ADDR_LO, AddrLo); + IoWrite32 (UEFI_VARS_IO_BASE + UEFI_VARS_REG_BUFFER_ADDR_HI, AddrHi); + IoWrite32 (UEFI_VARS_IO_BASE + UEFI_VARS_REG_BUFFER_SIZE, MAX_BUFFER_SIZ= E); + + return RETURN_SUCCESS; +} + +EFI_STATUS +EFIAPI +VirtMmHwVirtMap ( + VOID + ) +{ + return RETURN_SUCCESS; +} + +EFI_STATUS +EFIAPI +VirtMmHwComm ( + VOID + ) +{ + EFI_STATUS Status; + + Status =3D VirtMmHwCommand (UEFI_VARS_CMD_MM); + DEBUG ((DEBUG_VERBOSE, "%a: Status: %r\n", __func__, Status)); + + return Status; +} diff --git a/OvmfPkg/VirtMmCommunicationDxe/VirtMmCommunication.c b/OvmfPkg= /VirtMmCommunicationDxe/VirtMmCommunication.c new file mode 100644 index 000000000000..7b4ebe1257c6 --- /dev/null +++ b/OvmfPkg/VirtMmCommunicationDxe/VirtMmCommunication.c @@ -0,0 +1,380 @@ +/** @file + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "VirtMmCommunication.h" + +VOID *mCommunicateBuffer; +EFI_PHYSICAL_ADDRESS mCommunicateBufferPhys; + +// Notification event when virtual address map is set. +STATIC EFI_EVENT mSetVirtualAddressMapEvent; + +// Handle to install the MM Communication Protocol +STATIC EFI_HANDLE mMmCommunicateHandle; + +// Handle to install the EfiSmmVariableProtocol +STATIC EFI_HANDLE mSmmVariableHandle; + +// Handle to install the SmmVariableWrite +STATIC EFI_HANDLE mSmmVariableWriteHandle; + +/** + Communicates with a registered handler. + + This function provides a service to send and receive messages from a reg= istered UEFI service. + + @param[in] This The EFI_MM_COMMUNICATION_PROTOCOL in= stance. + @param[in, out] CommBufferPhysical Physical address of the MM communica= tion buffer + @param[in, out] CommBufferVirtual Virtual address of the MM communicat= ion buffer + @param[in, out] CommSize The size of the data buffer being pa= ssed in. On input, + when not omitted, the buffer should = cover EFI_MM_COMMUNICATE_HEADER + and the value of MessageLength field= . On exit, the size + of data being returned. Zero if the = handler does not + wish to reply with any data. This pa= rameter is optional + and may be NULL. + + @retval EFI_SUCCESS The message was successfully posted. + @retval EFI_INVALID_PARAMETER CommBufferPhysical or CommBufferVirtual w= as NULL, or + integer value pointed by CommSize does no= t cover + EFI_MM_COMMUNICATE_HEADER and the value o= f MessageLength + field. + @retval EFI_BAD_BUFFER_SIZE The buffer is too large for the MM implem= entation. + If this error is returned, the MessageLen= gth field + in the CommBuffer header or the integer p= ointed by + CommSize, are updated to reflect the maxi= mum payload + size the implementation can accommodate. + @retval EFI_ACCESS_DENIED The CommunicateBuffer parameter or CommSi= ze parameter, + if not omitted, are in address range that= cannot be + accessed by the MM environment. + +**/ +EFI_STATUS +EFIAPI +VirtMmCommunication2Communicate ( + IN CONST EFI_MM_COMMUNICATION2_PROTOCOL *This, + IN OUT VOID *CommBufferPhysical, + IN OUT VOID *CommBufferVirtual, + IN OUT UINTN *CommSize OPTIONAL + ) +{ + EFI_MM_COMMUNICATE_HEADER *CommunicateHeader; + EFI_STATUS Status; + UINTN BufferSize; + + // + // Check parameters + // + if ((CommBufferVirtual =3D=3D NULL) || (CommBufferPhysical =3D=3D NULL))= { + return EFI_INVALID_PARAMETER; + } + + Status =3D EFI_SUCCESS; + CommunicateHeader =3D CommBufferVirtual; + // CommBuffer is a mandatory parameter. Hence, Rely on + // MessageLength + Header to ascertain the + // total size of the communication payload rather than + // rely on optional CommSize parameter + BufferSize =3D CommunicateHeader->MessageLength + + sizeof (CommunicateHeader->HeaderGuid) + + sizeof (CommunicateHeader->MessageLength); + + DEBUG (( + DEBUG_VERBOSE, + "%a: %g msglen %ld, BufferSize %ld, CommSize %ld\n", + __func__, + &CommunicateHeader->HeaderGuid, + CommunicateHeader->MessageLength, + BufferSize, + *CommSize + )); + + // If CommSize is not omitted, perform size inspection before proceeding. + if (CommSize !=3D NULL) { + // This case can be used by the consumer of this driver to find out the + // max size that can be used for allocating CommBuffer. + if ((*CommSize =3D=3D 0) || + (*CommSize > MAX_BUFFER_SIZE)) + { + *CommSize =3D MAX_BUFFER_SIZE; + Status =3D EFI_BAD_BUFFER_SIZE; + } + + // + // CommSize should cover at least MessageLength + sizeof (EFI_MM_COMMU= NICATE_HEADER); + // + if (*CommSize < BufferSize) { + Status =3D EFI_INVALID_PARAMETER; + } + } + + // + // If the message length is 0 or greater than what can be tolerated by t= he MM + // environment then return the expected size. + // + if ((CommunicateHeader->MessageLength =3D=3D 0) || + (BufferSize > MAX_BUFFER_SIZE)) + { + CommunicateHeader->MessageLength =3D MAX_BUFFER_SIZE - + sizeof (CommunicateHeader->HeaderGu= id) - + sizeof (CommunicateHeader->MessageL= ength); + Status =3D EFI_BAD_BUFFER_SIZE; + } + + // MessageLength or CommSize check has failed, return here. + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_WARN, "%a: check error: %r\n", __func__, Status)); + return Status; + } + + // Copy Communication Payload + CopyMem (mCommunicateBuffer, CommBufferVirtual, BufferSize); + + Status =3D VirtMmHwComm (); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_WARN, "%a: comm error: %r\n", __func__, Status)); + return Status; + } + + CopyMem (CommBufferVirtual, mCommunicateBuffer, BufferSize); + + DEBUG ((DEBUG_VERBOSE, "%a: success (%d)\n", __func__, BufferSize)); + return EFI_SUCCESS; +} + +// +// MM Communication Protocol instance +// +STATIC EFI_MM_COMMUNICATION2_PROTOCOL mMmCommunication2 =3D { + VirtMmCommunication2Communicate +}; + +/** + Notification callback on SetVirtualAddressMap event. + + This function notifies the MM communication protocol interface on + SetVirtualAddressMap event and converts pointers used in this driver + from physical to virtual address. + + @param Event SetVirtualAddressMap event. + @param Context A context when the SetVirtualAddressMap triggered. + + @retval EFI_SUCCESS The function executed successfully. + @retval Other Some error occurred when executing this function. + +**/ +STATIC +VOID +EFIAPI +VirtMmNotifySetVirtualAddressMap ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EFI_STATUS Status; + + DEBUG ((DEBUG_VERBOSE, "%a: << %p\n", __func__, mCommunicateBuffer)); + Status =3D gRT->ConvertPointer (EFI_OPTIONAL_PTR, &mCommunicateBuffer); + DEBUG ((DEBUG_VERBOSE, "%a: >> %p\n", __func__, mCommunicateBuffer)); + + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "%a: Unable to convert MM runtime pointer. Status: %r\n", + __func__, + Status + )); + } + + Status =3D VirtMmHwVirtMap (); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "%a: VirtMmHwVirtMap failed. Status: %r\n", + __func__, + Status + )); + } +} + +STATIC EFI_GUID *CONST mGuidedEventGuid[] =3D { + &gEfiEndOfDxeEventGroupGuid, + &gEfiEventExitBootServicesGuid, + &gEfiEventReadyToBootGuid, +}; + +STATIC EFI_EVENT mGuidedEvent[ARRAY_SIZE (mGuidedEventGuid)]; + +/** + Event notification that is fired when GUIDed Event Group is signaled. + + @param Event The Event that is being processed, not use= d. + @param Context Event Context, not used. + +**/ +STATIC +VOID +EFIAPI +VirtMmGuidedEventNotify ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EFI_MM_COMMUNICATE_HEADER Header; + UINTN Size; + + // + // Use Guid to initialize EFI_SMM_COMMUNICATE_HEADER structure + // + CopyGuid (&Header.HeaderGuid, Context); + Header.MessageLength =3D 1; + Header.Data[0] =3D 0; + + Size =3D sizeof (Header); + VirtMmCommunication2Communicate (&mMmCommunication2, &Header, &Header, &= Size); +} + +/** + The Entry Point for MM Communication + + This function installs the MM communication protocol interface and finds= out + what type of buffer management will be required prior to invoking the + communication SMC. + + @param ImageHandle The firmware allocated handle for the EFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The entry point is executed successfully. + @retval Other Some error occurred when executing this entry poi= nt. + +**/ +EFI_STATUS +EFIAPI +VirtMmCommunication2Initialize ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + UINTN Index; + + if (FeaturePcdGet (PcdEnableVariableRuntimeCache)) { + ASSERT (!"Variable driver runtime cache is not supported.\n"); + CpuDeadLoop (); + } + + if (FeaturePcdGet (PcdVariableCollectStatistics)) { + ASSERT (!"Variable driver statistics are not supported.\n"); + CpuDeadLoop (); + } + + mCommunicateBuffer =3D AllocateRuntimePages (EFI_SIZE_TO_PAGES (MAX_BUFF= ER_SIZE)); + if (!mCommunicateBuffer) { + Status =3D EFI_OUT_OF_RESOURCES; + goto ReturnErrorStatus; + } + + mCommunicateBufferPhys =3D (EFI_PHYSICAL_ADDRESS)(UINTN)(mCommunicateBuf= fer); + Status =3D VirtMmHwInit (); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "%a: Failed to init HW: %r\n", + __func__, + Status + )); + goto FreeBufferPages; + } + + // Install the communication protocol + Status =3D gBS->InstallProtocolInterface ( + &mMmCommunicateHandle, + &gEfiMmCommunication2ProtocolGuid, + EFI_NATIVE_INTERFACE, + &mMmCommunication2 + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "%a: Failed to install MM communication protocol\n", + __func__ + )); + goto FreeBufferPages; + } + + Status =3D gBS->InstallProtocolInterface ( + &mSmmVariableHandle, + &gEfiSmmVariableProtocolGuid, + EFI_NATIVE_INTERFACE, + NULL + ); + ASSERT_EFI_ERROR (Status); + + Status =3D gBS->InstallProtocolInterface ( + &mSmmVariableWriteHandle, + &gSmmVariableWriteGuid, + EFI_NATIVE_INTERFACE, + NULL + ); + ASSERT_EFI_ERROR (Status); + + // Register notification callback when virtual address is associated + // with the physical address. + // Create a Set Virtual Address Map event. + Status =3D gBS->CreateEvent ( + EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE, + TPL_NOTIFY, + VirtMmNotifySetVirtualAddressMap, + NULL, + &mSetVirtualAddressMapEvent + ); + ASSERT_EFI_ERROR (Status); + + for (Index =3D 0; Index < ARRAY_SIZE (mGuidedEventGuid); Index++) { + Status =3D gBS->CreateEventEx ( + EVT_NOTIFY_SIGNAL, + TPL_CALLBACK, + VirtMmGuidedEventNotify, + mGuidedEventGuid[Index], + mGuidedEventGuid[Index], + &mGuidedEvent[Index] + ); + ASSERT_EFI_ERROR (Status); + if (EFI_ERROR (Status)) { + while (Index-- > 0) { + gBS->CloseEvent (mGuidedEvent[Index]); + } + + goto UninstallProtocol; + } + } + + return EFI_SUCCESS; + +UninstallProtocol: + gBS->UninstallProtocolInterface ( + mMmCommunicateHandle, + &gEfiMmCommunication2ProtocolGuid, + &mMmCommunication2 + ); + +FreeBufferPages: + FreePages (mCommunicateBuffer, EFI_SIZE_TO_PAGES (MAX_BUFFER_SIZE)); + +ReturnErrorStatus: + return EFI_INVALID_PARAMETER; +} --=20 2.42.0 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#111679): https://edk2.groups.io/g/devel/message/111679 Mute This Topic: https://groups.io/mt/102767936/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sun May 12 20:53:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+111678+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+111678+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1700751762; cv=none; d=zohomail.com; s=zohoarc; b=FMy7eEKqZKa9yg+Xs5zzG074dJCmUF23B6yQn5zQ1l++PNJOmxgOPjYIGmEbY6FTHmqARjlx93H3KUshTteQxZMnhLKvP4xZDc6CZvSQNOpjUxwDxEhxhV0pe/LtjflnuA1Eiu1RWIFJP8jYLmY9udj8BzHG6I0ASqZ5sawT8oM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700751762; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=Ch+L6WOOa/FOuSoLE4I+lh5pLUSzhGwGDX1NV0PUoVg=; b=c8wWcfLCEsh+2VTHNWwLbjbDi2sGzainxtclo5bQw1cIfNKcqOK46avsvVjMduux2W4CtlZPrDN+tNAy5eZJv7RPInl5X/XNcprSKwFCq04sF8hCwNfWSTM6NVphoxe36zbufo40tXu6gXil1yd54QMWYMOqefY6KEI9knHEZVw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+111678+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1700751762027256.38161050665053; Thu, 23 Nov 2023 07:02:42 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=RBEedF9IK6NCiPKQZhvXP6Qy2JqVelVDabh+WXr23OU=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1700751761; v=1; b=TQdBKlkNcb7uivWFvhBdIuIBJ/57tZiLsDhIFXB1L+wQxU6c/sMlIAgk5lmVFXWxRS+TC7q0 LRxEtC0K24XP22KbnHlAsJixzoyDSCl39iAb95+yK683IqE9cJHnGIWwAXkQMc5c3TEdANcHV8u PsVv5rx1EStBRGpXydbLDAVc= X-Received: by 127.0.0.2 with SMTP id ZFR1YY1788612xl96rM3aS0V; Thu, 23 Nov 2023 07:02:41 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web10.92693.1700751761023629677 for ; Thu, 23 Nov 2023 07:02:41 -0800 X-Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-168-awxrm6thNMi_G19osB69QQ-1; Thu, 23 Nov 2023 10:02:37 -0500 X-MC-Unique: awxrm6thNMi_G19osB69QQ-1 X-Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id B224A3C10156 for ; Thu, 23 Nov 2023 15:02:37 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.193.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6223340C6EB9; Thu, 23 Nov 2023 15:02:37 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id DA4E21800DCF; Thu, 23 Nov 2023 16:02:34 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Oliver Steffen , =?UTF-8?q?L=C3=A1szl=C3=B3=20=C3=89rsek?= , Gerd Hoffmann Subject: [edk2-devel] [PATCH 3/7] OvmfPkg/OvmfPkgX64: add QEMU_VARS option Date: Thu, 23 Nov 2023 16:02:30 +0100 Message-ID: <20231123150234.117835-4-kraxel@redhat.com> In-Reply-To: <20231123150234.117835-1-kraxel@redhat.com> References: <20231123150234.117835-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,kraxel@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: KMti3YahEUKOqP50FhdE9c1Yx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1700751763270100005 Content-Type: text/plain; charset="utf-8"; x-default="true" Add config option to use qemu variable service, via VirtMmCommunicationDxe. Default is FALSE, build using '-D QEMU_VARS=3DTRUE' to enable. Signed-off-by: Gerd Hoffmann --- OvmfPkg/OvmfPkgX64.dsc | 15 ++++++++++++++- OvmfPkg/OvmfPkgX64.fdf | 12 +++++++++++- .../VirtMmCommunication.inf | 1 + 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index dc1a0942aa8b..4b044321e31b 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -378,7 +378,7 @@ [LibraryClasses.common.DXE_RUNTIME_DRIVER] PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyL= ibRuntimeDxe.inf -!if $(SMM_REQUIRE) =3D=3D TRUE +!if $(SMM_REQUIRE) =3D=3D TRUE || $(QEMU_VARS) =3D=3D TRUE MmUnblockMemoryLib|MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibN= ull.inf !endif =20 @@ -504,6 +504,9 @@ [PcdsFeatureFlag] gUefiCpuPkgTokenSpaceGuid.PcdCpuHotPlugSupport|TRUE gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache|FALSE !endif +!if $(QEMU_VARS) =3D=3D TRUE + gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache|FALSE +!endif !if $(SECURE_BOOT_ENABLE) =3D=3D TRUE gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported|TRUE gEfiMdeModulePkgTokenSpaceGuid.PcdRequireSelfSignedPk|TRUE @@ -1095,6 +1098,15 @@ [Components] } MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf =20 +!else +!if $(QEMU_VARS) =3D=3D TRUE + + # + # Variable driver stack (qemu -device uefi-vars) + # + OvmfPkg/VirtMmCommunicationDxe/VirtMmCommunication.inf + MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf + !else =20 # @@ -1110,6 +1122,7 @@ [Components] NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf } +!endif !endif =20 # diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf index 9c35b6e848a2..20cc6a49c72f 100644 --- a/OvmfPkg/OvmfPkgX64.fdf +++ b/OvmfPkg/OvmfPkgX64.fdf @@ -223,7 +223,7 @@ [FV.DXEFV] # encrypted region (Since the range has not been marked shared/unencrypt= ed). INF OvmfPkg/AmdSevDxe/AmdSevDxe.inf INF OvmfPkg/TdxDxe/TdxDxe.inf -!if $(SMM_REQUIRE) =3D=3D FALSE +!if $(SMM_REQUIRE) =3D=3D FALSE && $(QEMU_VARS) =3D=3D FALSE INF OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf !endif } @@ -392,6 +392,15 @@ [FV.DXEFV] INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf =20 +!else +!if $(QEMU_VARS) =3D=3D TRUE + + # + # Variable driver stack (qemu -device uefi-vars) + # +INF OvmfPkg/VirtMmCommunicationDxe/VirtMmCommunication.inf +INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf + !else =20 # @@ -402,6 +411,7 @@ [FV.DXEFV] INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf !endif +!endif =20 # # EFI_CC_MEASUREMENT_PROTOCOL diff --git a/OvmfPkg/VirtMmCommunicationDxe/VirtMmCommunication.inf b/OvmfP= kg/VirtMmCommunicationDxe/VirtMmCommunication.inf index a9998f3db8cd..1403e92e1d6d 100644 --- a/OvmfPkg/VirtMmCommunicationDxe/VirtMmCommunication.inf +++ b/OvmfPkg/VirtMmCommunicationDxe/VirtMmCommunication.inf @@ -23,6 +23,7 @@ [Sources.X64] [Packages] MdePkg/MdePkg.dec MdeModulePkg/MdeModulePkg.dec + OvmfPkg/OvmfPkg.dec =20 [LibraryClasses] BaseMemoryLib --=20 2.42.0 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#111678): https://edk2.groups.io/g/devel/message/111678 Mute This Topic: https://groups.io/mt/102767935/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sun May 12 20:53:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+111683+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+111683+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1700751766; cv=none; d=zohomail.com; s=zohoarc; b=WB/e0exfzzztCRECniN4GqpS4ufaPdb0n839OoZ6zHUXa7jeew/IysavcxHcB4HcMLCawnzZJV5XjP98c0gvamFeOx1rHw9+RvrRfd2lgsNHOECrJCsnx6pNvb7OFs2Gz83x5XvsfKfNugutTO2JMG31x0IrKBWEcxKeOc3wADE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700751766; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=6gmM952ukHp0rhFWBQL4AEjhlD3hVl95YcnLU8aBq2s=; b=a08o8TCnKhMV9nMZS5+rFKYtBkt585Q1WjiPdM8OfAeWMlHTERH23FOGipj15obcIsgzIJnhcbbtdYaF51iwLG4ONE+OLb/8bvnhsqGWhUaJOl9QuF7WqBwFW7Hllteel8dYowm6ppauIngq3pbTvw9iwaKD2wp/cekLoNDCbnE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+111683+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1700751766457688.165698369116; Thu, 23 Nov 2023 07:02:46 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=vQzEs7QGlhndHmKg+HMXLOMQ8PehFZAt6WWI4k8mZlg=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1700751766; v=1; b=QTnh2WKDetOamBHs3hns3nAtlzVbrnSADR+pK+fNJlhHloAmLzDXge0EkfEVUAWek8T3JWU4 BbbuLaZSb5bVLgMB2eqlFPPcpCJdOE5b6U6xryYPVHofg1vdOL/Y9EQcvK98yyTWnlET2MnJGIy uEASBX5vaSD6h+ZvAx+vi7ZI= X-Received: by 127.0.0.2 with SMTP id b53RYY1788612x87o4mySITl; Thu, 23 Nov 2023 07:02:46 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web11.93013.1700751765365869104 for ; Thu, 23 Nov 2023 07:02:45 -0800 X-Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-208-81ztUjC1OmqucAmjp-ZvNw-1; Thu, 23 Nov 2023 10:02:40 -0500 X-MC-Unique: 81ztUjC1OmqucAmjp-ZvNw-1 X-Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1353B3800BCF for ; Thu, 23 Nov 2023 15:02:39 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.193.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CF92C2166B26; Thu, 23 Nov 2023 15:02:38 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id DDEAC1800DDC; Thu, 23 Nov 2023 16:02:34 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Oliver Steffen , =?UTF-8?q?L=C3=A1szl=C3=B3=20=C3=89rsek?= , Gerd Hoffmann Subject: [edk2-devel] [PATCH 4/7] OvmfPkg: add PcdQemuVarsRequire Date: Thu, 23 Nov 2023 16:02:31 +0100 Message-ID: <20231123150234.117835-5-kraxel@redhat.com> In-Reply-To: <20231123150234.117835-1-kraxel@redhat.com> References: <20231123150234.117835-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,kraxel@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: Xu9CcczLnPgCVkG9Kmmu1PyBx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1700751767363100027 Content-Type: text/plain; charset="utf-8"; x-default="true" Add PcdQemuVarsRequire FeaturePcd, so firmware code can figure whenever the given build is supposed to use the qemu uefi variable service. Skip the emulated variable store setup in case PcdQemuVarsRequire is true. This is needed to make secure boot work. Signed-off-by: Gerd Hoffmann --- OvmfPkg/OvmfPkg.dec | 3 +++ OvmfPkg/OvmfPkgX64.dsc | 1 + OvmfPkg/PlatformPei/PlatformPei.inf | 1 + OvmfPkg/PlatformPei/Platform.c | 4 ++++ 4 files changed, 9 insertions(+) diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec index e3861e5c1b39..7fa7ee5e99e3 100644 --- a/OvmfPkg/OvmfPkg.dec +++ b/OvmfPkg/OvmfPkg.dec @@ -502,3 +502,6 @@ [PcdsFeatureFlag] # firmware contains a CSM (Compatibility Support Module). # gUefiOvmfPkgTokenSpaceGuid.PcdCsmEnable|FALSE|BOOLEAN|0x35 + + ## This feature flag indicates the firmware build needs the qemu variabl= e service. + gUefiOvmfPkgTokenSpaceGuid.PcdQemuVarsRequire|FALSE|BOOLEAN|0x6e diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index 4b044321e31b..a27ea95dedc5 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -505,6 +505,7 @@ [PcdsFeatureFlag] gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache|FALSE !endif !if $(QEMU_VARS) =3D=3D TRUE + gUefiOvmfPkgTokenSpaceGuid.PcdQemuVarsRequire|TRUE gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache|FALSE !endif !if $(SECURE_BOOT_ENABLE) =3D=3D TRUE diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/Plat= formPei.inf index 3934aeed9514..0794e605ef4c 100644 --- a/OvmfPkg/PlatformPei/PlatformPei.inf +++ b/OvmfPkg/PlatformPei/PlatformPei.inf @@ -135,6 +135,7 @@ [FixedPcd] [FeaturePcd] gUefiOvmfPkgTokenSpaceGuid.PcdCsmEnable gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire + gUefiOvmfPkgTokenSpaceGuid.PcdQemuVarsRequire =20 [Ppis] gEfiPeiMasterBootModePpiGuid diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c index f5dc41c3a8c4..31922a91fbfd 100644 --- a/OvmfPkg/PlatformPei/Platform.c +++ b/OvmfPkg/PlatformPei/Platform.c @@ -219,6 +219,10 @@ ReserveEmuVariableNvStore ( EFI_PHYSICAL_ADDRESS VariableStore; RETURN_STATUS PcdStatus; =20 + if (FeaturePcdGet (PcdQemuVarsRequire)) { + return; + } + VariableStore =3D (EFI_PHYSICAL_ADDRESS)(UINTN)PlatformReserveEmuVariabl= eNvStore (); PcdStatus =3D PcdSet64S (PcdEmuVariableNvStoreReserved, VariableStor= e); =20 --=20 2.42.0 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#111683): https://edk2.groups.io/g/devel/message/111683 Mute This Topic: https://groups.io/mt/102767941/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sun May 12 20:53:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+111680+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+111680+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1700751762; cv=none; d=zohomail.com; s=zohoarc; b=Q45rgTNc2L7F2obPapbKsrutWlCdRj31Uf64pKuO1MuS4fGHwSaupLrRbjBdyTZPDjFmlNT3aaR7Ax1KJ4LiM/eZqKTxnVDlizKLfrYTGqsXVM1bfw73aNF6kfTy92XFkPcfrfFJn5ZKtjjVNYiH8JSc4XhAyqHYbRmuXxplJIY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700751762; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=1F+8+4o5hqG4+92sJi0rixnW3mCJpmnDSQD4L+TUgoU=; b=D7RfWZRiS0piVtwLIb9gHNJSXPjBSIjXcHhQUh98m+4NmBEKIojUO75hl5+V2p6qcJoBWiyNjjivmIz4Ce/vCJ5Wyjy9fpWwfI2Zbi+bHwmhDDjQmflnaRPVcpaPp4NMlbda74BPNjsPKFOrju/e+JS5PCreCZQP+M7/8yC+vY4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+111680+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 170075176291287.24411255902396; Thu, 23 Nov 2023 07:02:42 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=swCiZNSxArgS9abR1xSkTVxh/eqAYZUlhXsW23oys0M=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1700751762; v=1; b=OO37HT5CPot6ofcYQUo9lwE/ED49UOEMQGmLxhAYX42yiMuI5AK3GIVWYh5PWg4xAQljGpgr hGs9qe5MDEtV1wAeKld2rWdtiHO5As/yt23GqExC9mu2HceHR7TL2/UsM7UYn1gje/ZyfEOaD9u 0GNifRM7Av/6eZQQpXDwUnYs= X-Received: by 127.0.0.2 with SMTP id THAXYY1788612xoxSaEUBSl8; Thu, 23 Nov 2023 07:02:42 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web11.93008.1700751761506314791 for ; Thu, 23 Nov 2023 07:02:41 -0800 X-Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-465-SIT5jAWHNxW5X6EBqiSLkg-1; Thu, 23 Nov 2023 10:02:39 -0500 X-MC-Unique: SIT5jAWHNxW5X6EBqiSLkg-1 X-Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3D3941C05135 for ; Thu, 23 Nov 2023 15:02:39 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.193.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0DD9D492BE0; Thu, 23 Nov 2023 15:02:39 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id E19B71800DDE; Thu, 23 Nov 2023 16:02:34 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Oliver Steffen , =?UTF-8?q?L=C3=A1szl=C3=B3=20=C3=89rsek?= , Gerd Hoffmann Subject: [edk2-devel] [PATCH 5/7] OvmfPkg/VirtMmCommunicationDxe: stop on init failure Date: Thu, 23 Nov 2023 16:02:32 +0100 Message-ID: <20231123150234.117835-6-kraxel@redhat.com> In-Reply-To: <20231123150234.117835-1-kraxel@redhat.com> References: <20231123150234.117835-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,kraxel@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: CtYrOWs3c8jBf5NoAgSUcp7Mx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1700751763275100007 Content-Type: text/plain; charset="utf-8"; x-default="true" Print an error and stop in case VirtMmCommunicationDxe initialization fails. Signed-off-by: Gerd Hoffmann --- OvmfPkg/VirtMmCommunicationDxe/VirtMmCommunication.inf | 1 + OvmfPkg/VirtMmCommunicationDxe/VirtMmCommunication.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/OvmfPkg/VirtMmCommunicationDxe/VirtMmCommunication.inf b/OvmfP= kg/VirtMmCommunicationDxe/VirtMmCommunication.inf index 1403e92e1d6d..08fadefa5275 100644 --- a/OvmfPkg/VirtMmCommunicationDxe/VirtMmCommunication.inf +++ b/OvmfPkg/VirtMmCommunicationDxe/VirtMmCommunication.inf @@ -36,6 +36,7 @@ [LibraryClasses] [FeaturePcd] gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache #= # CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdVariableCollectStatistics #= # CONSUMES + gUefiOvmfPkgTokenSpaceGuid.PcdQemuVarsRequire #= # CONSUMES =20 [Protocols] gEfiMmCommunication2ProtocolGuid ## PRODUCES diff --git a/OvmfPkg/VirtMmCommunicationDxe/VirtMmCommunication.c b/OvmfPkg= /VirtMmCommunicationDxe/VirtMmCommunication.c index 7b4ebe1257c6..c33561b39f9b 100644 --- a/OvmfPkg/VirtMmCommunicationDxe/VirtMmCommunication.c +++ b/OvmfPkg/VirtMmCommunicationDxe/VirtMmCommunication.c @@ -376,5 +376,15 @@ VirtMmCommunication2Initialize ( FreePages (mCommunicateBuffer, EFI_SIZE_TO_PAGES (MAX_BUFFER_SIZE)); =20 ReturnErrorStatus: + if (FeaturePcdGet (PcdQemuVarsRequire)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: qemu uefi variable service is not available, use \n" + " 'qemu-system-x86_64 -device uefi-vars-isa' or\n" + " 'qemu-system-aarch64 -machine virt,x-uefi-vars=3Don'\n" + )); + CpuDeadLoop (); + } + return EFI_INVALID_PARAMETER; } --=20 2.42.0 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#111680): https://edk2.groups.io/g/devel/message/111680 Mute This Topic: https://groups.io/mt/102767937/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sun May 12 20:53:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+111681+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+111681+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1700751763; cv=none; d=zohomail.com; s=zohoarc; b=jDpfx5JavKNxHdIj5tmv485u83Gth4biE/a4nL8DebJWKIO9BpXrH9Zmg7SFP+Gg9fkMw6PjrP+bIwqRCgAa+WAjYCEEM0LNNe5PJ1pgRAuOTfOm1gqsekrBk5KEpZQVr96vjejDdOglFcZYXTCB/EHDFOXNz4glvPqQBgPgVng= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700751763; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=qynSciGrV2cNEwsSS+M8D14TLErpb9v9x29+PH5hJPc=; b=aKWeU57+PZo7zSRGqx6MTyoKprcMWsgtLYybjlxzbQa7X0jp9amD0Fi3lqdzvnupWYZSLNAUX/JrauX1gCZinkHroV6BzJ35PYKa5RABsvfaQjXwSz2cbAkjIOTgpdwsXA+Tek5DQVYikRrZDjZUkVA9aldKgryKaQcM5Q5n6BY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+111681+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1700751763843293.24923948289234; Thu, 23 Nov 2023 07:02:43 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=TznzBIcFxa0UB2yS7ExdH+siQnwC564X2S2PBovD9JQ=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1700751763; v=1; b=ieL58WOyMwYNL3NSFLiW+NHuQ83JPMmz0v5CTXEk0Lyx7rKzgre1JON+yZrO3gP73jsoB6i7 zrcJTVcGBZLtOoPeGMhsnZt3hADYWVIZdjDngySCGCS1OpavTSYahhnv/cuoApHBy79oCL3sH6v f1/RrW7UYXoTkjy/hKhuizMU= X-Received: by 127.0.0.2 with SMTP id 52KTYY1788612xPXcV7WfaMM; Thu, 23 Nov 2023 07:02:43 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web11.93011.1700751762887294860 for ; Thu, 23 Nov 2023 07:02:43 -0800 X-Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-487-6K5covE4MOW4CvDzlMJFfQ-1; Thu, 23 Nov 2023 10:02:40 -0500 X-MC-Unique: 6K5covE4MOW4CvDzlMJFfQ-1 X-Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 929332825E9B for ; Thu, 23 Nov 2023 15:02:40 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.193.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3467910E45; Thu, 23 Nov 2023 15:02:40 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id E54171800DE0; Thu, 23 Nov 2023 16:02:34 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Oliver Steffen , =?UTF-8?q?L=C3=A1szl=C3=B3=20=C3=89rsek?= , Gerd Hoffmann Subject: [edk2-devel] [PATCH 6/7] OvmfPkg/VirtMmCommunicationDxe: add arm support Date: Thu, 23 Nov 2023 16:02:33 +0100 Message-ID: <20231123150234.117835-7-kraxel@redhat.com> In-Reply-To: <20231123150234.117835-1-kraxel@redhat.com> References: <20231123150234.117835-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,kraxel@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: sxoZhcWj5PCBxVgtFyUenEscx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1700751765291100021 Content-Type: text/plain; charset="utf-8"; x-default="true" Add support for arm. Lookup the "qemu-uefi-vars" device in the device tree, talk to it via mmio, otherwise identical to the x64 variant. Signed-off-by: Gerd Hoffmann --- .../VirtMmCommunication.inf | 15 ++ OvmfPkg/VirtMmCommunicationDxe/QemuFdt.c | 208 ++++++++++++++++++ 2 files changed, 223 insertions(+) create mode 100644 OvmfPkg/VirtMmCommunicationDxe/QemuFdt.c diff --git a/OvmfPkg/VirtMmCommunicationDxe/VirtMmCommunication.inf b/OvmfP= kg/VirtMmCommunicationDxe/VirtMmCommunication.inf index 08fadefa5275..48184207d909 100644 --- a/OvmfPkg/VirtMmCommunicationDxe/VirtMmCommunication.inf +++ b/OvmfPkg/VirtMmCommunicationDxe/VirtMmCommunication.inf @@ -20,11 +20,17 @@ [Sources] [Sources.X64] QemuX64.c =20 +[Sources.AARCH64, Sources.ARM] + QemuFdt.c + [Packages] MdePkg/MdePkg.dec MdeModulePkg/MdeModulePkg.dec OvmfPkg/OvmfPkg.dec =20 +[Packages.AARCH64, Packages.ARM] + EmbeddedPkg/EmbeddedPkg.dec + [LibraryClasses] BaseMemoryLib DebugLib @@ -33,6 +39,9 @@ [LibraryClasses] MemoryAllocationLib UefiDriverEntryPoint =20 +[LibraryClasses.AARCH64, LibraryClasses.ARM] + FdtLib + [FeaturePcd] gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache #= # CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdVariableCollectStatistics #= # CONSUMES @@ -42,6 +51,9 @@ [Protocols] gEfiMmCommunication2ProtocolGuid ## PRODUCES gEfiSmmVariableProtocolGuid ## PRODUCES =20 +[Protocols.AARCH64, Protocols.ARM] + gFdtClientProtocolGuid + [Guids] gEfiEndOfDxeEventGroupGuid gEfiEventExitBootServicesGuid @@ -50,3 +62,6 @@ [Guids] =20 [Depex] gEfiCpuArchProtocolGuid + +[Depex.AARCH64, Depex.ARM] + gFdtClientProtocolGuid diff --git a/OvmfPkg/VirtMmCommunicationDxe/QemuFdt.c b/OvmfPkg/VirtMmCommu= nicationDxe/QemuFdt.c new file mode 100644 index 000000000000..ae42d9671bea --- /dev/null +++ b/OvmfPkg/VirtMmCommunicationDxe/QemuFdt.c @@ -0,0 +1,208 @@ +/** @file + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include "VirtMmCommunication.h" + +STATIC UINT64 mUefiVarsAddr; + +STATIC +EFI_STATUS +EFIAPI +VirtMmHwFind ( + VOID + ) +{ + FDT_CLIENT_PROTOCOL *FdtClient; + EFI_STATUS Status; + CONST UINT64 *Reg; + UINT32 RegSize; + UINTN AddressCells, SizeCells; + + Status =3D gBS->LocateProtocol ( + &gFdtClientProtocolGuid, + NULL, + (VOID **)&FdtClient + ); + ASSERT_EFI_ERROR (Status); + + Status =3D FdtClient->FindCompatibleNodeReg ( + FdtClient, + UEFI_VARS_FDT_COMPAT, + (CONST VOID **)&Reg, + &AddressCells, + &SizeCells, + &RegSize + ); + + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "%a: node compatible=3D%a not found (%r)\n", + __func__, + UEFI_VARS_FDT_NODE, + Status + )); + return EFI_NOT_FOUND; + } + + ASSERT (AddressCells =3D=3D 2); + ASSERT (SizeCells =3D=3D 2); + ASSERT (RegSize =3D=3D 2 * sizeof (UINT64)); + + mUefiVarsAddr =3D SwapBytes64 (Reg[0]); + DEBUG ((DEBUG_VERBOSE, "%a: address: 0x%lx\n", __func__, mUefiVarsAddr)); + + return RETURN_SUCCESS; +} + +STATIC +EFI_STATUS +VirtMmHwMemAttr ( + ) +{ + EFI_STATUS Status; + + Status =3D gDS->AddMemorySpace ( + EfiGcdMemoryTypeMemoryMappedIo, + mUefiVarsAddr, + EFI_PAGE_SIZE, + EFI_MEMORY_UC | EFI_MEMORY_RUNTIME + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: AddMemorySpace failed: %r\n", __func__, Stat= us)); + return RETURN_UNSUPPORTED; + } + + Status =3D gDS->SetMemorySpaceAttributes ( + mUefiVarsAddr, + EFI_PAGE_SIZE, + EFI_MEMORY_UC | EFI_MEMORY_RUNTIME + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: SetMemorySpaceAttributes failed: %r\n", __fu= nc__, Status)); + return RETURN_UNSUPPORTED; + } + + return EFI_SUCCESS; +} + +STATIC +EFI_STATUS +EFIAPI +VirtMmHwCommand ( + UINT32 Cmd + ) +{ + UINT32 Count; + UINT32 Sts; + + MmioWrite16 (mUefiVarsAddr + UEFI_VARS_REG_CMD_STS, Cmd); + for (Count =3D 0; Count < 100; Count++) { + Sts =3D MmioRead16 (mUefiVarsAddr + UEFI_VARS_REG_CMD_STS); + DEBUG ((DEBUG_VERBOSE, "%a: Sts: 0x%x\n", __func__, Sts)); + switch (Sts) { + case UEFI_VARS_STS_SUCCESS: + return RETURN_SUCCESS; + case UEFI_VARS_STS_BUSY: + CpuPause (); + break; + case UEFI_VARS_STS_ERR_NOT_SUPPORTED: + return RETURN_UNSUPPORTED; + case UEFI_VARS_STS_ERR_BAD_BUFFER_SIZE: + return RETURN_BAD_BUFFER_SIZE; + default: + return RETURN_DEVICE_ERROR; + } + } + + return RETURN_TIMEOUT; +} + +EFI_STATUS +EFIAPI +VirtMmHwInit ( + VOID + ) +{ + UINT32 Magic, AddrLo, AddrHi; + EFI_STATUS Status; + + Status =3D VirtMmHwFind (); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: VirtMmHwFind() failed: %d\n", __func__, Stat= us)); + return Status; + } + + VirtMmHwMemAttr (); + + Magic =3D MmioRead16 (mUefiVarsAddr + UEFI_VARS_REG_MAGIC); + if (Magic !=3D UEFI_VARS_MAGIC_VALUE) { + DEBUG (( + DEBUG_ERROR, + "%a: Magic value mismatch (0x%x !=3D 0x%x)\n", + __func__, + Magic, + UEFI_VARS_MAGIC_VALUE + )); + return RETURN_DEVICE_ERROR; + } + + DEBUG ((DEBUG_INFO, "%a: Magic 0x%x, good\n", __func__, Magic)); + + Status =3D VirtMmHwCommand (UEFI_VARS_CMD_RESET); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Reset failed: %d\n", __func__, Status)); + return Status; + } + + AddrLo =3D (UINT32)mCommunicateBufferPhys; + AddrHi =3D (UINT32)RShiftU64 (mCommunicateBufferPhys, 32); + MmioWrite32 (mUefiVarsAddr + UEFI_VARS_REG_BUFFER_ADDR_LO, AddrLo); + MmioWrite32 (mUefiVarsAddr + UEFI_VARS_REG_BUFFER_ADDR_HI, AddrHi); + MmioWrite32 (mUefiVarsAddr + UEFI_VARS_REG_BUFFER_SIZE, MAX_BUFFER_SIZE); + + return RETURN_SUCCESS; +} + +EFI_STATUS +EFIAPI +VirtMmHwVirtMap ( + VOID + ) +{ + EFI_STATUS Status; + + DEBUG ((DEBUG_VERBOSE, "%a: << %lx\n", __func__, mUefiVarsAddr)); + Status =3D gRT->ConvertPointer (EFI_OPTIONAL_PTR, (VOID **)&mUefiVarsAdd= r); + DEBUG ((DEBUG_VERBOSE, "%a: >> %lx\n", __func__, mUefiVarsAddr)); + + return Status; +} + +EFI_STATUS +EFIAPI +VirtMmHwComm ( + VOID + ) +{ + EFI_STATUS Status; + + Status =3D VirtMmHwCommand (UEFI_VARS_CMD_MM); + DEBUG ((DEBUG_VERBOSE, "%a: Status: %r\n", __func__, Status)); + + return Status; +} --=20 2.42.0 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#111681): https://edk2.groups.io/g/devel/message/111681 Mute This Topic: https://groups.io/mt/102767939/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sun May 12 20:53:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+111682+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+111682+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1700751764; cv=none; d=zohomail.com; s=zohoarc; b=Dy1YqEm1LeGPn1FuXEQDHQoaq3FmDAjqvX/CNt9NpDBZAZdDLkKebjD//QfQApcbPix0fAC/CmFULvWVXa3SBBlTlsmbagP+EFoZF71KpEutk3dCkMzHuDVI+g76ykXPn9jxllJdnvTyQwQj7asHs+EijxPsK8BIPm7mfXeKZk8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700751764; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=mQgIryS1wrUSJuv0q7mLeD9939oXuZD+RzHfgQA6SIs=; b=bgDnAhhsWVt/ww8HouBJ+5WkXcNpeJysId+yINt4jmszWza/lTkPEigZNXWHNERclacpqzsWkYNmXPmluSrfayqOdB9D1zog3c/hJlbfPP81HRKHi2zMionqYFYiiBjrVR4xuRKihZe1W5M/H95gp1DOoop4hivIenWtsljYpA0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+111682+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1700751764419881.3065296663976; Thu, 23 Nov 2023 07:02:44 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=ziytigCv7DTeApWKniKeRazvKmw1KvsDtd+9VLgswkU=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1700751764; v=1; b=Hm8Q9yzq0jYPTFztqmMw8Rf/S9KETQht04X7yh19+mfJY/q65fYIbOCx0gV8r6ToxoCjGBU2 XPXZI3LvII8ct5OH5EGF9PLzFnfBr1L0WHQKnYOHkhLNCnIj7BdWEvva9Ea8jMP6EP4jkCcXwiW MEQPOmUf8Lk77rVEDMhIKybY= X-Received: by 127.0.0.2 with SMTP id ljKTYY1788612xIlqOgINPTu; Thu, 23 Nov 2023 07:02:44 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web10.92696.1700751762957969680 for ; Thu, 23 Nov 2023 07:02:43 -0800 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-489-J3Uj6s4qP-u_-FHEftdwBQ-1; Thu, 23 Nov 2023 10:02:40 -0500 X-MC-Unique: J3Uj6s4qP-u_-FHEftdwBQ-1 X-Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id AB38A101A54C for ; Thu, 23 Nov 2023 15:02:40 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.193.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5794A2166B26; Thu, 23 Nov 2023 15:02:40 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id E8DF91800DE1; Thu, 23 Nov 2023 16:02:34 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Oliver Steffen , =?UTF-8?q?L=C3=A1szl=C3=B3=20=C3=89rsek?= , Gerd Hoffmann Subject: [edk2-devel] [PATCH 7/7] ArmVirtPkg/ArmVirtQemu: add QEMU_VARS option Date: Thu, 23 Nov 2023 16:02:34 +0100 Message-ID: <20231123150234.117835-8-kraxel@redhat.com> In-Reply-To: <20231123150234.117835-1-kraxel@redhat.com> References: <20231123150234.117835-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,kraxel@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 2PDoyX95liNrma48XYPXPyPRx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1700751765338100022 Content-Type: text/plain; charset="utf-8"; x-default="true" Add config option to use qemu variable service, via VirtMmCommunicationDxe. Default is FALSE, build using '-D QEMU_VARS=3DTRUE' to enable. Signed-off-by: Gerd Hoffmann --- ArmVirtPkg/ArmVirt.dsc.inc | 3 +++ ArmVirtPkg/ArmVirtQemu.dsc | 11 +++++++++++ ArmVirtPkg/ArmVirtQemuKernel.dsc | 11 +++++++++++ OvmfPkg/OvmfPkgX64.dsc | 1 + ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc | 5 +++++ 5 files changed, 31 insertions(+) diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc index fe6488ee9910..077abc36ff42 100644 --- a/ArmVirtPkg/ArmVirt.dsc.inc +++ b/ArmVirtPkg/ArmVirt.dsc.inc @@ -175,6 +175,9 @@ [LibraryClasses.common] VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseV= ariableFlashInfoLib.inf VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyL= ib.inf VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/Var= iablePolicyHelperLib.inf +!if $(QEMU_VARS) =3D=3D TRUE + MmUnblockMemoryLib|MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibN= ull.inf +!endif UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManag= erLib.inf =20 ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseRepor= tStatusCodeLibNull.inf diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc index 30e3cfc8b9cc..bb1fd6324783 100644 --- a/ArmVirtPkg/ArmVirtQemu.dsc +++ b/ArmVirtPkg/ArmVirtQemu.dsc @@ -29,6 +29,7 @@ [Defines] # DEFINE TTY_TERMINAL =3D FALSE DEFINE SECURE_BOOT_ENABLE =3D FALSE + DEFINE QEMU_VARS =3D FALSE DEFINE TPM2_ENABLE =3D FALSE DEFINE TPM2_CONFIG_ENABLE =3D FALSE DEFINE CAVIUM_ERRATUM_27456 =3D FALSE @@ -149,6 +150,11 @@ [PcdsFeatureFlag.common] =20 gArmVirtTokenSpaceGuid.PcdTpm2SupportEnabled|$(TPM2_ENABLE) =20 +!if $(QEMU_VARS) =3D=3D TRUE + gUefiOvmfPkgTokenSpaceGuid.PcdQemuVarsRequire|TRUE + gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache|FALSE +!endif + [PcdsFixedAtBuild.common] !if $(ARCH) =3D=3D AARCH64 gArmTokenSpaceGuid.PcdVFPEnabled|1 @@ -385,6 +391,10 @@ [Components.common] # ArmPkg/Drivers/CpuDxe/CpuDxe.inf MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf +!if $(QEMU_VARS) =3D=3D TRUE + OvmfPkg/VirtMmCommunicationDxe/VirtMmCommunication.inf + MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf +!else MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf { NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf @@ -392,6 +402,7 @@ [Components.common] # don't use unaligned CopyMem () on the UEFI varstore NOR flash regi= on BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf } +!endif !if $(SECURE_BOOT_ENABLE) =3D=3D TRUE MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf { diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKerne= l.dsc index b50f8e84a39a..0cc81f46431a 100644 --- a/ArmVirtPkg/ArmVirtQemuKernel.dsc +++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc @@ -29,6 +29,7 @@ [Defines] # DEFINE TTY_TERMINAL =3D FALSE DEFINE SECURE_BOOT_ENABLE =3D FALSE + DEFINE QEMU_VARS =3D FALSE =20 # # Network definition @@ -115,6 +116,11 @@ [PcdsFeatureFlag.common] =20 gEfiMdeModulePkgTokenSpaceGuid.PcdTurnOffUsbLegacySupport|TRUE =20 +!if $(QEMU_VARS) =3D=3D TRUE + gUefiOvmfPkgTokenSpaceGuid.PcdQemuVarsRequire|TRUE + gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache|FALSE +!endif + [PcdsFixedAtBuild.common] !if $(ARCH) =3D=3D AARCH64 gArmTokenSpaceGuid.PcdVFPEnabled|1 @@ -293,6 +299,10 @@ [Components.common] # ArmPkg/Drivers/CpuDxe/CpuDxe.inf MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf +!if $(QEMU_VARS) =3D=3D TRUE + OvmfPkg/VirtMmCommunicationDxe/VirtMmCommunication.inf + MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf +!else MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf { NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf @@ -300,6 +310,7 @@ [Components.common] # don't use unaligned CopyMem () on the UEFI varstore NOR flash regi= on BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf } +!endif !if $(SECURE_BOOT_ENABLE) =3D=3D TRUE MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf { diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index a27ea95dedc5..c7690279be3e 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -31,6 +31,7 @@ [Defines] # DEFINE SECURE_BOOT_ENABLE =3D FALSE DEFINE SMM_REQUIRE =3D FALSE + DEFINE QEMU_VARS =3D FALSE DEFINE SOURCE_DEBUG_ENABLE =3D FALSE DEFINE CC_MEASUREMENT_ENABLE =3D FALSE =20 diff --git a/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc b/ArmVirtPkg/ArmVirtQemuF= vMain.fdf.inc index 9b3e37d5c998..61850eb2be9e 100644 --- a/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc +++ b/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc @@ -52,7 +52,12 @@ [FV.FvMain] INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.i= nf +!if $(QEMU_VARS) =3D=3D TRUE + INF OvmfPkg/VirtMmCommunicationDxe/VirtMmCommunication.inf + INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf +!else INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf +!endif !if $(SECURE_BOOT_ENABLE) =3D=3D TRUE INF SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConf= igDxe.inf !endif --=20 2.42.0 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#111682): https://edk2.groups.io/g/devel/message/111682 Mute This Topic: https://groups.io/mt/102767940/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-