From nobody Tue May 7 20:51:59 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+79742+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+79742+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1629783284; cv=none; d=zohomail.com; s=zohoarc; b=QNMj8GstIUdiVkOXQOzszFWvKrUwTWTyijSTaq9w+0renc0xE+uonSittzDJ2uwZg1HAg/zZdCQlT222AXRIEjXbvSIRZiPdyC3dD27QEUPetAtgewzRlZVtleL3rAZCau5uta1J07C0hq2IA22M7Bcr/cBh3WnxRi3hC4We0vQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629783284; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=qsd39a+mJ8DWY5ZxAREninkOkZFziZ4ezyen8OriiDQ=; b=bnki2ea6LjaZX6UZl/xK5FanYCUOS6Pyz9URcDG6fXfuqYI+qs4VnqNxOPBK7GGy6xbHz/cpIeN8j1Ch7xyF0CfUsI1DMJiinsfrwKaxPQECbHLaBMadus2NwiOlhwrxYMwJV16ZzzvDvT2VTy8y/jh3By3jQMVXXzyNkqT2/4I= 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+79742+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 1629783284772997.2673144574853; Mon, 23 Aug 2021 22:34:44 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id O898YY1788612xMLonLA9Q0k; Mon, 23 Aug 2021 22:34:44 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.35645.1629783283804698897 for ; Mon, 23 Aug 2021 22:34:43 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 687471042; Mon, 23 Aug 2021 22:34:43 -0700 (PDT) X-Received: from usa.arm.com (a077433.blr.arm.com [10.162.46.10]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E39513F766; Mon, 23 Aug 2021 22:34:41 -0700 (PDT) From: "Omkar Anand Kulkarni" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Sami Mujawar Subject: [edk2-devel] [edk2-platforms][PATCH v3 1/5] MdeModulePkg: Allow dynamic generation of HEST ACPI table Date: Tue, 24 Aug 2021 11:03:59 +0530 Message-Id: <20210824053403.24103-2-omkar.kulkarni@arm.com> In-Reply-To: <20210824053403.24103-1-omkar.kulkarni@arm.com> References: <20210824053403.24103-1-omkar.kulkarni@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,omkar.kulkarni@arm.com X-Gm-Message-State: 9OSx4KD05AWaQRu4fIBb06HJx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1629783284; bh=DwtpIqBo8yE0PQFkCnzPcDnjc0kysOB4aRa5FyX/ESg=; h=Cc:Date:From:Reply-To:Subject:To; b=gQ9JrOISNvJmk82v4u5WnF5Ws1Z+yrb9i9dbd8MWkHbW3rCAJ6ciM5jZwfOoba1eXwv PNv9eXy6gDvUCjO7YfxVPPSA43d/LkO3VY1q8uQcrnEM64dghT9Cz6GvrkxbeWQpTu55z 2HQm6HNkmscUA3Leshf3q50y+NRnSBrfJC8= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1629783285728100004 Content-Type: text/plain; charset="utf-8" Introduce the HEST table generation protocol that allows platforms to build the table with multiple error source descriptors and install the table. The protocol provides two interfaces. The first interface allows for adding multiple error source descriptors into the HEST table. The second interface can then be used to dynamically install the fully populated HEST table. This allows multiple drivers and/or libraries to dynamically register error source descriptors into the HEST table. Co-authored-by: Thomas Abraham Signed-off-by: Omkar Anand Kulkarni --- MdeModulePkg/MdeModulePkg.dec | 3 + MdeModulePkg/Universal/Apei/HestDxe/HestDxe.inf | 49 +++ MdeModulePkg/Include/Protocol/HestTable.h | 71 +++++ MdeModulePkg/Universal/Apei/HestDxe/HestDxe.c | 318 ++++++++++++++++++++ 4 files changed, 441 insertions(+) diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index ad84421cf3f7..2cb4ba69d6bf 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -663,6 +663,9 @@ ## Include/Protocol/VariablePolicy.h gEdkiiVariablePolicyProtocolGuid =3D { 0x81D1675C, 0x86F6, 0x48DF, { 0xB= D, 0x95, 0x9A, 0x6E, 0x4F, 0x09, 0x25, 0xC3 } } =20 + ## Arm Platform HEST table generation protocol + gHestTableProtocolGuid =3D { 0x705bdcd9, 0x8c47, 0x457e, { 0xad, 0x0d, 0= xf7, 0x86, 0xf3, 0x4a, 0x0d, 0x63 } } + [PcdsFeatureFlag] ## Indicates if the platform can support update capsule across a system = reset.

# TRUE - Supports update capsule across a system reset.
diff --git a/MdeModulePkg/Universal/Apei/HestDxe/HestDxe.inf b/MdeModulePkg= /Universal/Apei/HestDxe/HestDxe.inf new file mode 100644 index 000000000000..91c7385bf7ff --- /dev/null +++ b/MdeModulePkg/Universal/Apei/HestDxe/HestDxe.inf @@ -0,0 +1,49 @@ +## @file +# Dxe driver that creates and publishes the HEST table. +# +# This driver creates HEST header and provides protocol service to append +# and install the HEST table. +# +# Copyright (c) 2020 - 2021, ARM Limited. All rights reserved. +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x0001001A + BASE_NAME =3D HestDxe + FILE_GUID =3D 933099a2-ef71-4e00-82aa-a79b1e0a3b38 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D HestInitialize + +[Sources.Common] + HestDxe.c + +[Packages] + ArmPkg/ArmPkg.dec + ArmPlatformPkg/ArmPlatformPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + Platform/ARM/SgiPkg/SgiPlatform.dec + +[LibraryClasses] + ArmLib + BaseMemoryLib + DebugLib + UefiDriverEntryPoint + UefiLib + +[Protocols] + gEfiAcpiTableProtocolGuid ## PROTOCOL ALWAYS_CONSUMED + gHestTableProtocolGuid ## PRODUCES + +[FixedPcd] + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorId + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorRevision + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemId + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemRevision + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemTableId + +[Depex] + TRUE diff --git a/MdeModulePkg/Include/Protocol/HestTable.h b/MdeModulePkg/Inclu= de/Protocol/HestTable.h new file mode 100644 index 000000000000..3b2e1f7d9203 --- /dev/null +++ b/MdeModulePkg/Include/Protocol/HestTable.h @@ -0,0 +1,71 @@ +/** @file + Builds and installs the HEST ACPI table. + + Define the protocol interface that allows HEST ACPI table to be created, + populated with error record descriptions and installation of the HEST AC= PI + table. + + Copyright (c) 2020 - 2021, ARM Limited. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef HEST_TABLE_H_ +#define HEST_TABLE_H_ + +#define HEST_TABLE_PROTOCOL_GUID \ + { \ + 0x705bdcd9, 0x8c47, 0x457e, \ + { 0xad, 0x0d, 0xf7, 0x86, 0xf3, 0x4a, 0x0d, 0x63 } \ + } + +/** + Append HEST error source descriptor protocol service. + + Protocol service used to append newly collected error source descriptors= to + to an already created HEST table. + + @param[in] ErrorSourceDescriptorList List of Error Source Descript= ors. + @param[in] ErrorSourceDescriptorListSize Total Size of Error Source + Descriptors. + @param[in] ErrorSourceDescriptorCount Total count of error source + descriptors. + + @retval EFI_SUCCESS Appending the error source descriptors + successful. + @retval EFI_OUT_OF_RESOURCES Buffer reallocation failed for the Hest + table. + @retval EFI_INVALID_PARAMETER Null ErrorSourceDescriptorList param or +**/ +typedef +EFI_STATUS +(EFIAPI *APPEND_ERROR_SOURCE_DESCRIPTOR) ( + IN CONST VOID *ErrorSourceDescriptorList, + IN UINTN ErrorSourceDescriptorListSize, + IN UINTN ErrorSourceDescriptorCount + ); + +/** + Install HEST table protocol service. + + Installs the HEST table that has been appended with the error source + descriptors. The checksum of this table is calculated and updated in + the table header. The HEST table is then installed. + + @retval EFI_SUCCESS HEST table is installed successfully. + @retval EFI_ABORTED HEST table is NULL. + @retval Other Install service call failed. +**/ +typedef +EFI_STATUS +(EFIAPI *INSTALL_HEST_TABLE) (VOID); + +// +// HEST_TABLE_PROTOCOL enables creation and installation of HEST table +// +typedef struct { + APPEND_ERROR_SOURCE_DESCRIPTOR AppendErrorSourceDescriptors; + INSTALL_HEST_TABLE InstallHestTable; +} HEST_TABLE_PROTOCOL; + +extern EFI_GUID gHestTableProtocolGuid; +#endif // HEST_TABLE_H_ diff --git a/MdeModulePkg/Universal/Apei/HestDxe/HestDxe.c b/MdeModulePkg/U= niversal/Apei/HestDxe/HestDxe.c new file mode 100644 index 000000000000..87f21acf61f4 --- /dev/null +++ b/MdeModulePkg/Universal/Apei/HestDxe/HestDxe.c @@ -0,0 +1,318 @@ +/** @file + Builds and installs the HEST ACPI table. + + This driver installs a protocol that can be used to create and install a= HEST + ACPI table. The protocol allows one or more error source producers to ad= d the + error source descriptors into the HEST table. It also allows the resulti= ng + HEST table to be installed. + + Copyright (c) 2020 - 2021, ARM Limited. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Specification Reference: + - ACPI 6.3, Table 18-382, Hardware Error Source Table +**/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef struct { + VOID *HestTable; /// Pointer to HEST table. + UINT32 CurrentTableSize; /// Current size of HEST table. +} HEST_DXE_DRIVER_DATA; + +STATIC EFI_ACPI_TABLE_PROTOCOL *mAcpiTableProtocol =3D NULL; +STATIC HEST_DXE_DRIVER_DATA mHestDriverData; + +/** + Allocate memory for the HEST table header and populate it. + + Helper function for this driver, populates the HEST table header. Called= once + in the beginning on first invocation of append error source descriptor + protocol service. + + @retval EFI_SUCCESS On successful creation of HEST header. + @retval EFI_OUT_OF_RESOURCES If system is out of memory recources. +**/ +STATIC +EFI_STATUS +BuildHestHeader ( + VOID + ) +{ + EFI_ACPI_6_3_HARDWARE_ERROR_SOURCE_TABLE_HEADER *HestHeader; + + // + // Allocate memory for the HEST table header. + // + mHestDriverData.HestTable =3D + AllocateZeroPool (sizeof (EFI_ACPI_6_3_HARDWARE_ERROR_SOURCE_TABLE_HEA= DER)); + if (mHestDriverData.HestTable =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + mHestDriverData.CurrentTableSize =3D + sizeof (EFI_ACPI_6_3_HARDWARE_ERROR_SOURCE_TABLE_HEADER); + + HestHeader =3D (EFI_ACPI_6_3_HARDWARE_ERROR_SOURCE_TABLE_HEADER *) + mHestDriverData.HestTable; + + // + // Populate the values of the HEST table header. + // + HestHeader->Header.Signature =3D + EFI_ACPI_6_3_HARDWARE_ERROR_SOURCE_TABLE_SIGNATURE; + HestHeader->Header.Revision =3D + EFI_ACPI_6_3_HARDWARE_ERROR_SOURCE_TABLE_REVISION; + CopyMem ( + &HestHeader->Header.OemId, + FixedPcdGetPtr (PcdAcpiDefaultOemId), + sizeof (HestHeader->Header.OemId) + ); + HestHeader->Header.OemTableId =3D FixedPcdGet64 (PcdAcpiDefaultOemTableI= d); + HestHeader->Header.OemRevision =3D PcdGet32 (PcdAcpiDefaultOemRevision); + HestHeader->Header.CreatorId =3D PcdGet32 (PcdAcpiDefaultCreatorId); + HestHeader->Header.CreatorRevision =3D PcdGet32 (PcdAcpiDefaultCreatorRe= vision); + HestHeader->ErrorSourceCount =3D 0; + + return EFI_SUCCESS; +} + +/** + Append HEST error source descriptor protocol service. + + Protocol service used to append newly collected error source descriptors= to + to an already created HEST table. + + @param[in] ErrorSourceDescriptorList List of Error Source Descript= ors. + @param[in] ErrorSourceDescriptorListSize Total Size of Error Source + Descriptors. + @param[in] ErrorSourceDescriptorCount Total count of error source + descriptors. + + @retval EFI_SUCCESS Appending the error source descriptors + successful. + @retval EFI_OUT_OF_RESOURCES Buffer reallocation failed for the Hest + table. + @retval EFI_INVALID_PARAMETER Null ErrorSourceDescriptorList param or +**/ +STATIC +EFI_STATUS +EFIAPI +AppendErrorSourceDescriptor ( + IN CONST VOID *ErrorSourceDescriptorList, + IN UINTN ErrorSourceDescriptorListSize, + IN UINTN ErrorSourceDescriptorCount + ) +{ + EFI_ACPI_6_3_HARDWARE_ERROR_SOURCE_TABLE_HEADER *HestHeaderPtr; + EFI_STATUS Status; + UINT32 NewTableSize; + VOID *ErrorDescriptorPtr; + + if ((ErrorSourceDescriptorList =3D=3D NULL) || + (ErrorSourceDescriptorListSize =3D=3D 0)) { + return EFI_INVALID_PARAMETER; + } + + // + // Create a HEST table header if not already created. + // + if (mHestDriverData.HestTable =3D=3D NULL) { + Status =3D BuildHestHeader (); + if (Status =3D=3D EFI_OUT_OF_RESOURCES) { + DEBUG (( + DEBUG_ERROR, + "%a: Failed to build HEST header, status: %r\n", + __FUNCTION__, + Status + )); + return Status; + } + } + + // + // Resize the existing HEST table buffer to accommodate the incoming err= or + // source descriptors. + // + NewTableSize =3D mHestDriverData.CurrentTableSize + + ErrorSourceDescriptorListSize; + mHestDriverData.HestTable =3D ReallocatePool ( + mHestDriverData.CurrentTableSize, + NewTableSize, + mHestDriverData.HestTable + ); + if (mHestDriverData.HestTable =3D=3D NULL) { + DEBUG (( + DEBUG_ERROR, + "%a: Failed to reallocate memory for HEST table\n", + __FUNCTION__ + )); + return EFI_OUT_OF_RESOURCES; + } + + // + // Copy the incoming error source descriptors into HEST table. + // + ErrorDescriptorPtr =3D (VOID *)mHestDriverData.HestTable + + mHestDriverData.CurrentTableSize; + HestHeaderPtr =3D (EFI_ACPI_6_3_HARDWARE_ERROR_SOURCE_TABLE_HEADER *) + mHestDriverData.HestTable; + CopyMem ( + ErrorDescriptorPtr, + ErrorSourceDescriptorList, + ErrorSourceDescriptorListSize + ); + mHestDriverData.CurrentTableSize =3D NewTableSize; + HestHeaderPtr->Header.Length =3D mHestDriverData.CurrentTableSize; + HestHeaderPtr->ErrorSourceCount +=3D ErrorSourceDescriptorCount; + + DEBUG (( + DEBUG_INFO, + "HestDxe: %d Error source descriptor(s) added \n", + ErrorSourceDescriptorCount + )); + return EFI_SUCCESS; +} + +/** + Install HEST table protocol service. + + Installs the HEST table that has been appended with the error source + descriptors. The checksum of this table is calculated and updated in + the table header. The HEST table is then installed. + + @retval EFI_SUCCESS HEST table is installed successfully. + @retval EFI_ABORTED HEST table is NULL. + @retval Other Install service call failed. +**/ +STATIC +EFI_STATUS +EFIAPI +InstallHestAcpiTable ( + VOID + ) +{ + EFI_ACPI_6_3_HARDWARE_ERROR_SOURCE_TABLE_HEADER *HestHeader; + EFI_STATUS Status; + UINTN AcpiTableHandle; + + // + // Check if we have valid HEST table data. If not, there no hardware err= or + // sources supported by the platform and no HEST table to publish, retur= n. + // + if (mHestDriverData.HestTable =3D=3D NULL) { + DEBUG (( + DEBUG_INFO, + "HestDxe: No data available to generate HEST table\n" + )); + return EFI_NOT_FOUND; + } + + // + // Valid data for HEST table found. Update the header checksum and insta= ll the + // HEST table. + // + HestHeader =3D (EFI_ACPI_6_3_HARDWARE_ERROR_SOURCE_TABLE_HEADER *) + mHestDriverData.HestTable; + + Status =3D mAcpiTableProtocol->InstallAcpiTable ( + mAcpiTableProtocol, + HestHeader, + HestHeader->Header.Length, + &AcpiTableHandle + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "%a: HEST table installation failed, status: %r\n", + __FUNCTION__, + Status + )); + return Status; + } + + // + // Free the HEST table buffer. + // + FreePool (mHestDriverData.HestTable); + DEBUG (( + DEBUG_INFO, + "HestDxe: Installed HEST table \n" + )); + return Status; +} + +// +// HEST table generation protocol instance. +// +STATIC HEST_TABLE_PROTOCOL mHestProtocol =3D { + AppendErrorSourceDescriptor, + InstallHestAcpiTable +}; + +/** + The Entry Point for HEST Dxe driver. + + This function installs the HEST table creation and installation protocol + services. + + @param[in] ImageHandle Handle to the Efi image. + @param[in] SystemTable A pointer to the Efi System Table. + + @retval EFI_SUCCESS On successful installation of protocol services a= nd + location the ACPI table protocol. + @retval Other On Failure to locate ACPI table protocol or insta= ll + of HEST table generation protocol. +**/ +EFI_STATUS +EFIAPI +HestInitialize ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_HANDLE Handle =3D NULL; + EFI_STATUS Status; + + Status =3D gBS->LocateProtocol ( + &gEfiAcpiTableProtocolGuid, + NULL, + (VOID **)&mAcpiTableProtocol + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "%a: Failed to locate ACPI table protocol, status: %r\n", + __FUNCTION__, + Status + )); + return Status; + } + + Status =3D gBS->InstallProtocolInterface ( + &Handle, + &gHestTableProtocolGuid, + EFI_NATIVE_INTERFACE, + &mHestProtocol + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "%a: Failed to install HEST table generation protocol status: %r\n", + __FUNCTION__, + Status + )); + return Status; + } + + return Status; +} --=20 2.17.1 -=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 (#79742): https://edk2.groups.io/g/devel/message/79742 Mute This Topic: https://groups.io/mt/85104605/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 Tue May 7 20:51:59 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+79743+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+79743+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1629783286; cv=none; d=zohomail.com; s=zohoarc; b=jomret1Cq82aJAYGOZ2hAVjVX9k7awF5wB7ZJEBWGAuQXSnLGpaoGD1aES6RjWCo7GZJCimDRFMcUefHCKtpLfxONGykNfKGoIf/ihWF1DSXMT2DNk2Mj5uO/0IiABl7phl5t1s8dw1xfDzytL0nRYf6u/lr0CtkPArNq9lJj3U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629783286; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=gteQtk0AtwROALf2HFfoR32MXpSQsXKyP8Iw5xMuABc=; b=Kpec5PPoqJKJcnN5ncwYpsbwReVD3GkxUfK2NTtfRsEq7kJGZ4Pl/Lg5tvpPgawmES76UOobl9mdAqv60lJJBC3qa5AIWQn0xaCQlP2wkZ6tLscjSlRzOl8q62lLMeO/dOaEH4hnXoEFBjcMdeevV96cdEWxUqwoD4IBHz4cLjA= 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+79743+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 1629783286438198.16757015979624; Mon, 23 Aug 2021 22:34:46 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id XTsoYY1788612xqmcpUWyaXF; Mon, 23 Aug 2021 22:34:46 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web12.35400.1629783285445206171 for ; Mon, 23 Aug 2021 22:34:45 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1A1DE1042; Mon, 23 Aug 2021 22:34:45 -0700 (PDT) X-Received: from usa.arm.com (a077433.blr.arm.com [10.162.46.10]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id DADA93F766; Mon, 23 Aug 2021 22:34:43 -0700 (PDT) From: "Omkar Anand Kulkarni" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Sami Mujawar Subject: [edk2-devel] [edk2-platforms][PATCH v3 2/5] ArmPlatformPkg: add definition for MM_HEST_ERROR_SOURCE_DESC_PROTOCOL Date: Tue, 24 Aug 2021 11:04:00 +0530 Message-Id: <20210824053403.24103-3-omkar.kulkarni@arm.com> In-Reply-To: <20210824053403.24103-1-omkar.kulkarni@arm.com> References: <20210824053403.24103-1-omkar.kulkarni@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,omkar.kulkarni@arm.com X-Gm-Message-State: TswrU8lO4YC2OCElJ0OTpmhyx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1629783286; bh=B2yCrFXsddjxWzeCosQzBXxTe7ipgCzucuXpj9hzr8w=; h=Cc:Date:From:Reply-To:Subject:To; b=ZJCf26VLeXJbGPclcMvaMwL0Jmh3EbkMJX9mn2IiP7+N1Mw4m1Z9KCzj5kwvHha/7co XNnp6sahst3bj4jvyB+q3UBCoWktVe4Qs9k6Yd+YNj/6Wbs9AVv3+BWu509Ne6QrxKQkx 2OzeNvr+zUBsZNDkQ1BvHxpVGA3thrVi/P8= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1629783287787100010 Content-Type: text/plain; charset="utf-8" Add the protocol definition of the MM_HEST_ERROR_SOURCE_DESC_PROTOCOL protocol. This protocol can be implemented by MM drivers to publish error source descriptors that have to be populated into HEST table. Co-authored-by: Thomas Abraham Signed-off-by: Omkar Anand Kulkarni --- ArmPlatformPkg/ArmPlatformPkg.dec | 3 + ArmPlatformPkg/Include/Protocol/HestErrorSourceInfo.h | 64 +++++++++++++++= +++++ 2 files changed, 67 insertions(+) diff --git a/ArmPlatformPkg/ArmPlatformPkg.dec b/ArmPlatformPkg/ArmPlatform= Pkg.dec index 3a25ddcdc8ca..446d93b880f9 100644 --- a/ArmPlatformPkg/ArmPlatformPkg.dec +++ b/ArmPlatformPkg/ArmPlatformPkg.dec @@ -127,3 +127,6 @@ gArmPlatformTokenSpaceGuid.PcdPL031RtcPpmAccuracy|300000000|UINT32|0x000= 00022 =20 gArmPlatformTokenSpaceGuid.PcdWatchdogCount|0x0|UINT32|0x00000033 + +[Protocols.common] + gMmHestErrorSourceDescProtocolGuid =3D { 0x560bf236, 0xa4a8, 0x4d69, { 0= xbc, 0xf6, 0xc2, 0x97, 0x24, 0x10, 0x9d, 0x91 } } diff --git a/ArmPlatformPkg/Include/Protocol/HestErrorSourceInfo.h b/ArmPla= tformPkg/Include/Protocol/HestErrorSourceInfo.h new file mode 100644 index 000000000000..86662ea7af57 --- /dev/null +++ b/ArmPlatformPkg/Include/Protocol/HestErrorSourceInfo.h @@ -0,0 +1,64 @@ +/** @file + MM protocol to get the secure error source descriptor information. + + MM Drivers must implement this protocol in order to publish secure side + error source descriptor information to OSPM through the HEST ACPI table. + + Copyright (c) 2020 - 2021, ARM Limited. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef MM_HEST_ERROR_SOURCE_DESC_ +#define MM_HEST_ERROR_SOURCE_DESC_ + +#define MM_HEST_ERROR_SOURCE_DESC_PROTOCOL_GUID \ + { \ + 0x560bf236, 0xa4a8, 0x4d69, { 0xbc, 0xf6, 0xc2, 0x97, 0x24, 0x10, 0x9d= , 0x91 } \ + } + +typedef struct MmHestErrorSourceDescProtocol + MM_HEST_ERROR_SOURCE_DESC_PROTOCOL; + +/** + Get HEST Secure Error Source Descriptors. + + The MM drivers implementing this protocol must convey the total count and + total length of the error sources the driver has along with the actual e= rror + source descriptor(s). + + Passing NULL as Buffer parameter shall return EFI_INVALID_PARAMETR with = the + total length and count of the error source descriptor(s) it supports. + + @param[in] This MM_HEST_ERROR_SOURCE_DESC_PROTOCOL inst= ance. + @param[out] Buffer Buffer to be appended with the error + source descriptors information. + @param[out] ErrorSourcesLength Total length of all the error source + descriptors. + @param[out] ErrorSourceCount Count of total error source descriptors + supported by the driver. + + retval EFI_SUCCESS If the Buffer is valid and is filled with = valid + Error Source descriptor data. + retval EFI_INVALID_PARAMTER Buffer is NULL. + retval Other If no error source descriptor information = is + available. +**/ +typedef +EFI_STATUS +(EFIAPI *MM_HEST_GET_ERROR_SOURCE_DESCRIPTORS) ( + IN MM_HEST_ERROR_SOURCE_DESC_PROTOCOL *This, + OUT VOID **Buffer, + OUT UINTN *ErrorSourcesLength, + OUT UINTN *ErrorSourcesCount + ); + +// +// Protocol declaration +// +struct MmHestErrorSourceDescProtocol { + MM_HEST_GET_ERROR_SOURCE_DESCRIPTORS GetHestErrorSourceDescriptors; +}; + +extern EFI_GUID gMmHestErrorSourceDescProtocolGuid; + +#endif // MM_HEST_ERROR_SOURCE_DESC_ --=20 2.17.1 -=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 (#79743): https://edk2.groups.io/g/devel/message/79743 Mute This Topic: https://groups.io/mt/85104606/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 Tue May 7 20:51:59 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+79744+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+79744+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1629783288; cv=none; d=zohomail.com; s=zohoarc; b=n0kZLSmgpw4bNOdc7LTwzt3UBSHPcYnJkHKU87NyDRf1sdVz6kQT6z0Ok2TlrrpeUNljSlXK41ucAuhw6lRVgzNwycjfhlbcF2DHPHBlfSoli5BB9PeTTio6LmZbzgAfsOFWt2tmOl8mwLLNlyL5hqESABo6Q9P5GtHa3mLGKjE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629783288; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=ReEIe6tZnotbPRuGzG9m1IMmQrFWgwkiLuV1YLrcJ1o=; b=QJJTXSSYmlDW7MEVSr2mTUeVX+ZIs7Hg4u8zT92alqPzjQub14mmOz+yJ0oMnHLxkfpVqd09JhxIch0C/VujTlzpC64cIaN5t+gOUWQ99e37uBQvBUcbawgbV+4xZMJP1XR3SsPsLpgW4GkyQG+dmo+ugKYeGmWcTEtDk0yMoPQ= 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+79744+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 1629783288555858.1936096674159; Mon, 23 Aug 2021 22:34:48 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id rLNDYY1788612xtqVy4DZiuB; Mon, 23 Aug 2021 22:34:48 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web09.35513.1629783287365011497 for ; Mon, 23 Aug 2021 22:34:47 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0575C1042; Mon, 23 Aug 2021 22:34:47 -0700 (PDT) X-Received: from usa.arm.com (a077433.blr.arm.com [10.162.46.10]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8BF293F766; Mon, 23 Aug 2021 22:34:45 -0700 (PDT) From: "Omkar Anand Kulkarni" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Sami Mujawar Subject: [edk2-devel] [edk2-platforms][PATCH v3 3/5] ArmPlatformPkg: retreive error source descriptors from MM Date: Tue, 24 Aug 2021 11:04:01 +0530 Message-Id: <20210824053403.24103-4-omkar.kulkarni@arm.com> In-Reply-To: <20210824053403.24103-1-omkar.kulkarni@arm.com> References: <20210824053403.24103-1-omkar.kulkarni@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,omkar.kulkarni@arm.com X-Gm-Message-State: yiNxWkoyg8QpaHEJ8IK6Tuoox1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1629783288; bh=C633TWrooQvZ6+7hxt79/DKudSR09GilfEvfMy9wMSM=; h=Cc:Date:From:Reply-To:Subject:To; b=i8Kxhg6sTon5Le6fTOxYIcDnwn+AFb1Wzjj2xEc6h7V8+AN4lnKjo8+F4xqmrJragJt W0qYxwwkuKSKBFILJHS3Qn4ze7/vFAabxo5FV3p5EsN8nEqhkvkTSisDhjL1z/XtCJXA4 eUk63GywJnfjalyVIWWNM8QD1JqcLPQP1kM= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1629783289946100002 Content-Type: text/plain; charset="utf-8" Add a driver that retreives error source descriptors from MM and populates those into the HEST ACPI table. The error source descriptors that are available from the MM side are retreived using MM Communicate 2 protocol. The first call into the MM returns the size of MM Communicate buffer required to hold all error source descriptor info. The communication buffer of that size is then allocated and the second call into MM returns the error source descriptors in the communication buffer. The retreived error source descriptors are then appended to the HEST table. Co-authored-by: Thomas Abraham Signed-off-by: Omkar Anand Kulkarni --- ArmPlatformPkg/ArmPlatformPkg.dec = | 7 + ArmPlatformPkg/Drivers/HestMmErrorSources/HestErrorSourceDxe.inf = | 45 +++ ArmPlatformPkg/Drivers/HestMmErrorSources/HestErrorSourceStandaloneMm.inf = | 51 ++++ ArmPlatformPkg/Drivers/HestMmErrorSources/HestMmErrorSourceCommon.h = | 37 +++ MdePkg/Include/Protocol/MmCommunication.h = | 2 + ArmPlatformPkg/Drivers/HestMmErrorSources/HestErrorSourceDxe.c = | 309 +++++++++++++++++++ ArmPlatformPkg/Drivers/HestMmErrorSources/HestErrorSourceStandaloneMm.c = | 312 ++++++++++++++++++++ 7 files changed, 763 insertions(+) diff --git a/ArmPlatformPkg/ArmPlatformPkg.dec b/ArmPlatformPkg/ArmPlatform= Pkg.dec index 446d93b880f9..a400f175726e 100644 --- a/ArmPlatformPkg/ArmPlatformPkg.dec +++ b/ArmPlatformPkg/ArmPlatformPkg.dec @@ -52,6 +52,8 @@ =20 [Guids.common] gArmPlatformTokenSpaceGuid =3D { 0x9c0aaed4, 0x74c5, 0x4043, { 0xb4, 0= x17, 0xa3, 0x22, 0x38, 0x14, 0xce, 0x76 } } + gArmPlatformHestErrorSourcesGuid =3D { 0x76b8ab43, 0x822d, 0x4b00, { 0x9= f, 0xd0, 0xf4, 0xa5, 0x35, 0x82, 0x47, 0x0a } } + gMmHestGetErrorSourceInfoGuid =3D { 0x7d602951, 0x678e, 0x4cc4, { 0x98, = 0xd9, 0xe3, 0x76, 0x04, 0xf6, 0x93, 0x0d } } =20 [PcdsFeatureFlag.common] gArmPlatformTokenSpaceGuid.PcdSendSgiToBringUpSecondaryCores|FALSE|BOOLE= AN|0x00000004 @@ -128,5 +130,10 @@ =20 gArmPlatformTokenSpaceGuid.PcdWatchdogCount|0x0|UINT32|0x00000033 =20 +[PcdsFixedAtBuild, PcdsPatchableInModule] + ## ACPI CPER memory space + gArmPlatformTokenSpaceGuid.PcdGhesGenericErrorDataMmBufferBase|0x0000000= 0|UINT64|0x00000046 + gArmPlatformTokenSpaceGuid.PcdGhesGenericErrorDataMmBufferSize|0x0000000= 0|UINT64|0x00000047 + [Protocols.common] gMmHestErrorSourceDescProtocolGuid =3D { 0x560bf236, 0xa4a8, 0x4d69, { 0= xbc, 0xf6, 0xc2, 0x97, 0x24, 0x10, 0x9d, 0x91 } } diff --git a/ArmPlatformPkg/Drivers/HestMmErrorSources/HestErrorSourceDxe.i= nf b/ArmPlatformPkg/Drivers/HestMmErrorSources/HestErrorSourceDxe.inf new file mode 100644 index 000000000000..b16ff2353aa5 --- /dev/null +++ b/ArmPlatformPkg/Drivers/HestMmErrorSources/HestErrorSourceDxe.inf @@ -0,0 +1,45 @@ +## @file +# DXE driver to get secure error sources. +# +# DXE driver to retrieve the error source descriptors from Standalone MM = and +# append those to the HEST table. +# +# Copyright (c) 2020 - 2021, ARM Limited. All rights reserved. +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x0001001A + BASE_NAME =3D HestMmErrorSourceDxe + FILE_GUID =3D 76b8ab43-822d-4b00-9fd0-f4a53582470a + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D HestErrorSourceInitialize + +[Sources.common] + HestErrorSourceDxe.c + +[Packages] + ArmPkg/ArmPkg.dec + ArmPlatformPkg/ArmPlatformPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + StandaloneMmPkg/StandaloneMmPkg.dec + +[LibraryClasses] + BaseMemoryLib + DebugLib + DxeServicesTableLib + UefiDriverEntryPoint + UefiLib + +[Guids] + gMmHestGetErrorSourceInfoGuid ## PRODUCES + +[Protocols] + gHestTableProtocolGuid ## CONSUMES + gEfiMmCommunication2ProtocolGuid + +[Depex] + gHestTableProtocolGuid AND gEfiMmCommunication2ProtocolGuid diff --git a/ArmPlatformPkg/Drivers/HestMmErrorSources/HestErrorSourceStand= aloneMm.inf b/ArmPlatformPkg/Drivers/HestMmErrorSources/HestErrorSourceStan= daloneMm.inf new file mode 100644 index 000000000000..9d566de9bec3 --- /dev/null +++ b/ArmPlatformPkg/Drivers/HestMmErrorSources/HestErrorSourceStandaloneMm= .inf @@ -0,0 +1,51 @@ +## @file +# HEST error source gateway Standalone MM driver. +# +# Collects HEST error source descriptors,by communicating with all the MM +# drivers implementing the HEST error source descriptor protocol. +# +# Copyright (c) 2020 - 2021, ARM Limited. All rights reserved. +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x0001001A + BASE_NAME =3D HestErrorSourceStandaloneMm + FILE_GUID =3D 3ddbebcc-9841-4ef8-87fa-305843c1922d + MODULE_TYPE =3D MM_STANDALONE + VERSION_STRING =3D 1.0 + PI_SPECIFICATION_VERSION =3D 0x00010032 + ENTRY_POINT =3D StandaloneMmHestErrorSourceInitialize + +[Sources] + HestErrorSourceStandaloneMm.c + +[Packages] + ArmPkg/ArmPkg.dec + ArmPlatformPkg/ArmPlatformPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + StandaloneMmPkg/StandaloneMmPkg.dec + +[LibraryClasses] + ArmLib + ArmSvcLib + BaseMemoryLib + DebugLib + MemoryAllocationLib + StandaloneMmDriverEntryPoint + +[Protocols] + gMmHestErrorSourceDescProtocolGuid + +[Guids] + gMmHestGetErrorSourceInfoGuid ##PRODUCES + gEfiStandaloneMmNonSecureBufferGuid + +[FixedPcd] + gArmPlatformTokenSpaceGuid.PcdGhesGenericErrorDataMmBufferBase + gArmPlatformTokenSpaceGuid.PcdGhesGenericErrorDataMmBufferSize + +[Depex] + TRUE diff --git a/ArmPlatformPkg/Drivers/HestMmErrorSources/HestMmErrorSourceCom= mon.h b/ArmPlatformPkg/Drivers/HestMmErrorSources/HestMmErrorSourceCommon.h new file mode 100644 index 000000000000..6ddc6bd21922 --- /dev/null +++ b/ArmPlatformPkg/Drivers/HestMmErrorSources/HestMmErrorSourceCommon.h @@ -0,0 +1,37 @@ +/** @file + Data structures for error source descriptor information. + + This data structure forms the CommBuffer part of the MM Communication + protocol used for communicating the Hardware Error sources form MM to + Non-MM environment. + + Copyright (c) 2020 - 2021, ARM Limited. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef HEST_ERROR_SOURCE_DESCRIPTOR_H_ +#define HEST_ERROR_SOURCE_DESCRIPTOR_H_ + +#define HEST_ERROR_SOURCE_DESC_INFO_SIZE \ + (OFFSET_OF (HEST_ERROR_SOURCE_DESC_INFO, ErrSourceDescList)) + +// +// Data Structure to communicate the error source descriptor information f= rom +// Standalone MM. +// +typedef struct { + // + // Total count of error source descriptors. + // + UINTN ErrSourceDescCount; + // + // Total size of all the error source descriptors. + // + UINTN ErrSourceDescSize; + // + // Array of error source descriptors that is ErrSourceDescSize in size. + // + UINT8 ErrSourceDescList[1]; +} HEST_ERROR_SOURCE_DESC_INFO; + +#endif // HEST_ERROR_SOURCE_DESCRIPTOR_H_ diff --git a/MdePkg/Include/Protocol/MmCommunication.h b/MdePkg/Include/Pro= tocol/MmCommunication.h index 34c3e2b5a9e3..acde54971fd9 100644 --- a/MdePkg/Include/Protocol/MmCommunication.h +++ b/MdePkg/Include/Protocol/MmCommunication.h @@ -12,6 +12,8 @@ #ifndef _MM_COMMUNICATION_H_ #define _MM_COMMUNICATION_H_ =20 +#define MM_COMMUNICATE_HEADER_SIZE (OFFSET_OF (EFI_MM_COMMUNICATE_HEADER, = Data)) + #pragma pack(1) =20 /// diff --git a/ArmPlatformPkg/Drivers/HestMmErrorSources/HestErrorSourceDxe.c= b/ArmPlatformPkg/Drivers/HestMmErrorSources/HestErrorSourceDxe.c new file mode 100644 index 000000000000..28de8daf2f5e --- /dev/null +++ b/ArmPlatformPkg/Drivers/HestMmErrorSources/HestErrorSourceDxe.c @@ -0,0 +1,309 @@ +/** @file + Collects and appends the HEST error source descriptors from the MM drive= rs. + + The drivers entry point locates the MM Communication protocol and calls = into + Standalone MM to get the HEST error sources length and count. It also + retrieves descriptor information. The information is then used to build = the + HEST table using the HEST table generation protocol. + + This driver collects the secure error source descriptor information from= the + MM drviers that implement HEST error source protocol. Instead of directly + communicating with the individual MM drivers, it calls into + HestErrorSourceStandaloneMM driver which is a gatway MM driver. This MM = driver + in-turn communicates with individual MM drivers collecting the error sou= rce + descriptor information. + + Once all the error source descriptor information is retrieved the driver + appends the descriptors to HEST table using the HestDxe driver. + + Copyright (c) 2020 - 2021, ARM Limited. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "HestMmErrorSourceCommon.h" + +STATIC HEST_TABLE_PROTOCOL *mHestProtocol; +STATIC EFI_MM_COMMUNICATION2_PROTOCOL *mMmCommunication2; + +/** + Retrieve the error source descriptors from Standalone MM. + + Initialize the MM comminication buffer by assigning the MM service to + invoke as gMmHestGetErrorSourceInfoGuid. Use the MM communication + protocol to retrieve the error source descriptors. + + @param[in] CommBuffSize Size of communicate buffer. + @param[in, out] CommBuffer The communicate buffer. + + @retval EFI_SUCCESS MM Communicate protocol call successful. + @retval Other MM Communicate protocol call failed. +**/ +STATIC +EFI_STATUS +GetErrorSourceDescriptors ( + IN UINTN CommBuffSize, + IN OUT EFI_MM_COMMUNICATE_HEADER **CommBuffer + ) +{ + EFI_STATUS Status; + + // + // Initialize the CommBuffer with MM Communicate metadata. + // + CopyGuid (&(*CommBuffer)->HeaderGuid, &gMmHestGetErrorSourceInfoGuid); + (*CommBuffer)->MessageLength =3D + CommBuffSize - + sizeof ((*CommBuffer)->HeaderGuid) - + sizeof ((*CommBuffer)->MessageLength); + + // + // Call into the Standalone MM using the MM Communicate protocol. + // + Status =3D mMmCommunication2->Communicate ( + mMmCommunication2, + NULL, + (VOID *)*CommBuffer, + NULL + ); + + return Status; +} + +/** + Collect HEST error source descriptors from all Standalone MM drivers and + append them to the HEST table. + + Use MM Communication Protocol to communicate and collect the error source + descriptor information from Standalone MM. Check for the required buffer= size + returned by the MM driver. Allocate buffer of adequate size and call aga= in + into MM. + + @retval EFI_SUCCESS Successful to collect and append the error + source. + descriptors to HEST table. + @retval EFI_OUT_OF_RESOURCES Memory allocation failure. + @retval Other For any other error. +**/ +STATIC +EFI_STATUS +AppendMmErrorSources ( + VOID + ) +{ + EFI_MM_COMMUNICATE_HEADER *CommunicationHeader =3D NULL; + HEST_ERROR_SOURCE_DESC_INFO *ErrorSourceDescInfo; + EFI_STATUS Status; + UINTN CommBufferSize; + + // + // Retrieve the count, length and the actual eror source descriptors from + // the MM drivers. Do this by performing two MM Communicate calls, in the + // first call pass CommBuffer which is atleast of the size of error sour= ce + // descriptor info structure. Followed by another communicate call with + // CommBuffer allocated to required buffer size to hold all descriptors. + // + // Allocate CommBuffer atleast the size of error source descriptor info + // structure. + CommBufferSize =3D + MM_COMMUNICATE_HEADER_SIZE + HEST_ERROR_SOURCE_DESC_INFO_SIZE; + CommunicationHeader =3D AllocateZeroPool (CommBufferSize); + if (CommunicationHeader =3D=3D NULL) { + DEBUG (( + DEBUG_ERROR, + "%a: Failed to allocate memory for CommunicationHeader\n", + __FUNCTION__ + )); + return EFI_OUT_OF_RESOURCES; + } + + // + // Make the first MM Communicate call to HestErrorSourceStandaloneMM gat= eway + // driver, which returns the required buffer size adequate to hold all t= he + // desctriptor information. + // + Status =3D GetErrorSourceDescriptors (CommBufferSize, &CommunicationHead= er); + if ((EFI_ERROR (Status)) && + (Status !=3D EFI_BUFFER_TOO_SMALL)) { + DEBUG (( + DEBUG_ERROR, + "%a: MM Communicate protocol call failed, status: %r\n", + __FUNCTION__, + Status + )); + FreePool (CommunicationHeader); + return Status; + } + + // Check for the length of Error Source descriptors. + ErrorSourceDescInfo =3D + (HEST_ERROR_SOURCE_DESC_INFO *)(CommunicationHeader->Data); + if ((ErrorSourceDescInfo->ErrSourceDescSize =3D=3D 0) || + (ErrorSourceDescInfo->ErrSourceDescCount =3D=3D 0)) { + DEBUG (( + DEBUG_INFO, + "HesErrorSourceDxe: HEST error source(s) not found\n" + )); + FreePool (CommunicationHeader); + return EFI_NOT_FOUND; + } + + // + // Allocate CommBuffer of required size to accomodate all the error sour= ce + // descriptors. Required size of communication buffer =3D + // MM communicate metadata. + (error source desc info struct + error sou= rce + // descriptor size). + // + + CommBufferSize =3D + MM_COMMUNICATE_HEADER_SIZE + + HEST_ERROR_SOURCE_DESC_INFO_SIZE + + ErrorSourceDescInfo->ErrSourceDescSize; + + // Free old MM Communicate buffer and allocate a new buffer of required = size. + FreePool (CommunicationHeader); + CommunicationHeader =3D AllocateZeroPool (CommBufferSize); + if (CommunicationHeader =3D=3D NULL) { + DEBUG (( + DEBUG_ERROR, + "%a: Failed to allocate memory for CommunicationHeader\n", + __FUNCTION__ + )); + return EFI_OUT_OF_RESOURCES; + } + + // + // Make second MM Communicate call to HestErrorSourceStandaloneMM driver= to + // get the error source descriptors from the MM drivers. + // + Status =3D GetErrorSourceDescriptors (CommBufferSize, &CommunicationHead= er); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "%a: MM Communicate protocol failed, status: %r\n", + __FUNCTION__, + Status + )); + FreePool (CommunicationHeader); + return Status; + } + + // + // Retrieve the HEST error source descriptor information. Ensure that th= ere + // is a valid list of error source descriptors. + // + ErrorSourceDescInfo =3D + (HEST_ERROR_SOURCE_DESC_INFO *)(CommunicationHeader->Data); + if (ErrorSourceDescInfo->ErrSourceDescList =3D=3D NULL) { + DEBUG (( + DEBUG_INFO, + "HestErrorSourceDxe: Error source descriptor list is empty" + )); + FreePool (CommunicationHeader); + return EFI_NOT_FOUND; + } + + DEBUG (( + DEBUG_INFO, + "HestErrorSourceDxe: ErrorSources: TotalCount =3D %d TotalLength =3D %= d \n", + ErrorSourceDescInfo->ErrSourceDescCount, + ErrorSourceDescInfo->ErrSourceDescSize + )); + + // + // Append the error source descriptors to HEST table using the HEST table + // generation protocol. + // + Status =3D mHestProtocol->AppendErrorSourceDescriptors ( + ErrorSourceDescInfo->ErrSourceDescList, + ErrorSourceDescInfo->ErrSourceDescSize, + ErrorSourceDescInfo->ErrSourceDescCount + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "%a: Failed to append error source(s), status: %r\n", + __FUNCTION__, + Status + )); + } + + FreePool (CommunicationHeader); + return Status; +} + +/** + The Entry Point for HEST Error Source Dxe driver. + + Locates the HEST Table generation and MM Communication2 protocols. Using= the + MM Communication2, the driver collects the Error Source Descriptor(s) fr= om + Standalone MM. It then appends those Error Source Descriptor(s) to the H= est + table using the HEST Table generation protocol. + + @param[in] ImageHandle The firmware allocated handle for the Efi image. + @param[in] 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 poin= t. +**/ +EFI_STATUS +EFIAPI +HestErrorSourceInitialize ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + Status =3D gBS->LocateProtocol ( + &gHestTableProtocolGuid, + NULL, + (VOID **)&mHestProtocol + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "%a: Failed to locate HEST table generation protocol, status:%r\n", + __FUNCTION__, + Status + )); + return Status; + } + + Status =3D gBS->LocateProtocol ( + &gEfiMmCommunication2ProtocolGuid, + NULL, + (VOID **)&mMmCommunication2 + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "%a: Failed to locate MMCommunication2 driver protocol, status:%r\n", + __FUNCTION__, + Status + )); + return Status; + } + + // + // Append HEST error sources retrieved from StandaloneMM, if any, into t= he + // HEST ACPI table. + // + Status =3D AppendMmErrorSources (); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "%a: Failed appending error source desc to HEST table, status:%r\n", + __FUNCTION__, + Status + )); + } + return EFI_SUCCESS; +} diff --git a/ArmPlatformPkg/Drivers/HestMmErrorSources/HestErrorSourceStand= aloneMm.c b/ArmPlatformPkg/Drivers/HestMmErrorSources/HestErrorSourceStanda= loneMm.c new file mode 100644 index 000000000000..75dc31438180 --- /dev/null +++ b/ArmPlatformPkg/Drivers/HestMmErrorSources/HestErrorSourceStandaloneMm= .c @@ -0,0 +1,312 @@ +/** @file + MM HEST error source gateway driver. + + This MM driver installs a handler which can be used to retrieve the error + source descriptors from the all MM drivers implementing the HEST error s= ource + descriptor protocol. + + The MM driver acts as a single point of contact to collect secure hardwa= re + error sources from the MM drivers. It loops over all the MM drivers that + implement HEST error source descriptor protocol and collects error source + descriptor information along with the error source count and length. + + Copyright (c) 2020 - 2021, ARM Limited. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include +#include +#include +#include +#include + +#include "HestMmErrorSourceCommon.h" + +STATIC EFI_MM_SYSTEM_TABLE *mMmst =3D NULL; + +/** + Returns an array of handles that implement the HEST error source descrip= tor + protocol. + + Passing HandleBuffer as NULL will return the actual size of the buffer + required to hold the array of handles implementing the protocol. + + @param[in, out] HandleBufferSize The size of the HandleBuffer. + @param[out] HandleBuffer A pointer to the buffer containing th= e list + of handles. + + @retval EFI_SUCCESS The array of handles returned in HandleBuffer. + @retval EFI_NOT_FOUND No implementation present for the protocol. + @retval Other For any other error. +**/ +STATIC +EFI_STATUS +GetHestErrorSourceProtocolHandles ( + IN OUT UINTN *HandleBufferSize, + OUT EFI_HANDLE **HandleBuffer + ) +{ + EFI_STATUS Status; + + Status =3D mMmst->MmLocateHandle ( + ByProtocol, + &gMmHestErrorSourceDescProtocolGuid, + NULL, + HandleBufferSize, + *HandleBuffer + ); + if ((EFI_ERROR (Status)) && + (Status !=3D EFI_BUFFER_TOO_SMALL)) + { + DEBUG (( + DEBUG_ERROR, + "%a: No implementation of MmHestErrorSourceDescProtocol found, \ + Status:%r\n", + __FUNCTION__, + Status + )); + return EFI_NOT_FOUND; + } + + return Status; +} + +/** + Mmi handler to retrieve HEST error source descriptor information. + + Handler for Mmi service that returns the supported HEST error source + descriptors in MM. This handler populates the CommBuffer with the + list of all error source descriptors, prepended with the length and + the number of descriptors populated into CommBuffer. + + @param[in] DispatchHandle The unique handle assigned to this hand= ler by + MmiHandlerRegister(). + @param[in] Context Points to an optional handler context t= hat + is specified when the handler was regis= tered. + @param[in, out] CommBuffer Buffer used for communication of HEST e= rror + source descriptors. + @param[in, out] CommBufferSize The size of the CommBuffer. + + @retval EFI_SUCCESS CommBuffer has valid data. + @retval EFI_BAD_BUFFER_SIZE CommBufferSize not adequate. + @retval EFI_OUT_OF_RESOURCES System out of memory resources. + @retval EFI_INVALID_PARAMETER Invalid CommBufferSize recieved. + @retval Other For any other error. +**/ +STATIC +EFI_STATUS +EFIAPI +HestErrorSourcesInfoMmiHandler ( + IN EFI_HANDLE DispatchHandle, + IN CONST VOID *Context, OPTIONAL + IN OUT VOID *CommBuffer, OPTIONAL + IN UINTN *CommBufferSize OPTIONAL + ) +{ + MM_HEST_ERROR_SOURCE_DESC_PROTOCOL *HestErrSourceDescProtocolHandle; + HEST_ERROR_SOURCE_DESC_INFO *ErrorSourceInfoList; + EFI_HANDLE *HandleBuffer; + EFI_STATUS Status; + UINTN HandleCount; + UINTN HandleBufferSize; + UINTN Index; + UINTN SourceCount =3D 0; + UINTN SourceLength =3D 0; + VOID *ErrorSourcePtr; + UINTN TotalSourceLength =3D 0; + UINTN TotalSourceCount =3D 0; + + if (*CommBufferSize < HEST_ERROR_SOURCE_DESC_INFO_SIZE) { + // + // Ensures that the communication buffer has enough space to atleast h= old + // the ErrSourceDescCount and ErrSourceDescSize elements of the + // HEST_ERROR_SOURCE_DESC_INFO structure. + // + DEBUG (( + DEBUG_ERROR, + "%a: Invalid CommBufferSize parameter\n", + __FUNCTION__ + )); + return EFI_INVALID_PARAMETER; + } + + // + // Get all handles that implement the HEST error source descriptor proto= col. + // Get the buffer size required to store list of handles for the protoco= l. + // + HandleBuffer =3D NULL; + HandleBufferSize =3D 0; + Status =3D GetHestErrorSourceProtocolHandles (&HandleBufferSize, &Handle= Buffer); + if ((Status =3D=3D EFI_NOT_FOUND) || + (HandleBufferSize =3D=3D 0)) + { + return Status; + } + + // Allocate memory for HandleBuffer of size HandleBufferSize. + HandleBuffer =3D AllocateZeroPool (HandleBufferSize); + if (HandleBuffer =3D=3D NULL) { + DEBUG (( + DEBUG_ERROR, + "%a: Failed to allocate memory for HandleBuffer\n", + __FUNCTION__ + )); + return EFI_OUT_OF_RESOURCES; + } + + // Get the list of handles. + Status =3D GetHestErrorSourceProtocolHandles (&HandleBufferSize, &Handle= Buffer); + if ((EFI_ERROR (Status)) || + (HandleBuffer =3D=3D NULL)) + { + FreePool (HandleBuffer); + return Status; + } + + // Count of handles for the protocol. + HandleCount =3D HandleBufferSize / sizeof (EFI_HANDLE); + + // + // Loop to get the count and length of the error source descriptors. + // + // This loop collects and adds the length of error source descriptors and + // its count from all the the MM drivers implementing HEST error source. + // descriptor protocol. The total length and count values retrieved help + // to determine weather the CommBuffer is big enough to hold the descrip= tor + // information. + // As mentioned in the HEST error source descriptor protocol definition, + // Buffer parameter set to NULL ensures only length and the count values + // are returned from the driver and no error source information is copie= d to + // Buffer. + // + for (Index =3D 0; Index < HandleCount; ++Index) { + Status =3D mMmst->MmHandleProtocol ( + HandleBuffer[Index], + &gMmHestErrorSourceDescProtocolGuid, + (VOID **)&HestErrSourceDescProtocolHandle + ); + if (EFI_ERROR (Status)) { + continue; + } + + // + // Protocol called with Buffer parameter passed as NULL, must return + // error source length and error count for that driver. + // + Status =3D HestErrSourceDescProtocolHandle->GetHestErrorSourceDescript= ors ( + HestErrSourceDescProtocolH= andle, + NULL, + &SourceLength, + &SourceCount + ); + if (Status =3D=3D EFI_INVALID_PARAMETER) { + TotalSourceLength +=3D SourceLength; + TotalSourceCount +=3D SourceCount; + } + } + + // Set the count and length in the error source descriptor. + ErrorSourceInfoList =3D (HEST_ERROR_SOURCE_DESC_INFO *)(CommBuffer); + ErrorSourceInfoList->ErrSourceDescCount =3D TotalSourceCount; + ErrorSourceInfoList->ErrSourceDescSize =3D TotalSourceLength; + + // + // Check the size of CommBuffer, it should atleast be of size + // TotalSourceLength + HEST_ERROR_SOURCE_DESC_INFO_SIZE. + // + TotalSourceLength =3D TotalSourceLength + HEST_ERROR_SOURCE_DESC_INFO_SI= ZE; + if ((*CommBufferSize) < TotalSourceLength) { + DEBUG (( + DEBUG_ERROR, + "%a: Invalid CommBufferSize parameter\n", + __FUNCTION__ + )); + FreePool (HandleBuffer); + return EFI_BUFFER_TOO_SMALL; + } + + // + // CommBuffer size is adequate to return all the error source descriptor= s. + // So go ahead and populate it with the error source descriptor informat= ion. + // + + // Buffer pointer to append the Error Descriptors data. + ErrorSourcePtr =3D ErrorSourceInfoList->ErrSourceDescList; + + // + // Loop to retrieve error source descriptors information. + // + // Calls into each MM driver that implement the HEST error source descri= ptor + // protocol. Here the Buffer parameter passed to the protocol service is + // valid. So the MM driver when called copies the descriptor information. + // + for (Index =3D 0; Index < HandleCount; ++Index) { + Status =3D mMmst->MmHandleProtocol ( + HandleBuffer[Index], + &gMmHestErrorSourceDescProtocolGuid, + (VOID **)&HestErrSourceDescProtocolHandle + ); + if (EFI_ERROR (Status)) { + continue; + } + + Status =3D HestErrSourceDescProtocolHandle->GetHestErrorSourceDescript= ors ( + HestErrSourceDescProtocolH= andle, + (VOID **)&ErrorSourcePtr, + &SourceLength, + &SourceCount + ); + if (Status =3D=3D EFI_SUCCESS) { + ErrorSourcePtr +=3D SourceLength; + } + } + + // Free the buffer holding all the protocol handles. + FreePool (HandleBuffer); + + return Status; +} + +/** + Entry point for this Stanalone MM driver. + + Registers an Mmi handler that retrieves the error source descriptors fro= m all + the MM drivers implementing the MM_HEST_ERROR_SOURCE_DESC_PROTOCOL. + + @param[in] ImageHandle The firmware allocated handle for the EFI image. + @param[in] SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The entry point registered handler successfully. + @retval Other Some error occurred when executing this entry poin= t. +**/ +EFI_STATUS +EFIAPI +StandaloneMmHestErrorSourceInitialize ( + IN EFI_HANDLE ImageHandle, + IN EFI_MM_SYSTEM_TABLE *SystemTable + ) +{ + EFI_HANDLE DispatchHandle; + EFI_STATUS Status; + + ASSERT (SystemTable !=3D NULL); + mMmst =3D SystemTable; + + Status =3D mMmst->MmiHandlerRegister ( + HestErrorSourcesInfoMmiHandler, + &gMmHestGetErrorSourceInfoGuid, + &DispatchHandle + ); + if (EFI_ERROR(Status)) { + DEBUG (( + DEBUG_ERROR, + "%a: Mmi handler registration failed with status : %r\n", + __FUNCTION__, + Status + )); + return Status; + } + + return Status; +} --=20 2.17.1 -=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 (#79744): https://edk2.groups.io/g/devel/message/79744 Mute This Topic: https://groups.io/mt/85104607/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 Tue May 7 20:51:59 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+79745+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+79745+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1629783289; cv=none; d=zohomail.com; s=zohoarc; b=FtuNZyH1QiAcEs4HSsncURPAg6LMgnmR1ZIS9teH8ULKz+U/VgRDwZAquf2P8qFjq8WbJabyeZIRtDBnC8oNinqLEqvZmuJ1Rm5guB+QGYfobUtHzDk0tAbNlEzzq4EblouMOpA9xya23AbQpvRihFPzxy2a5tpDTG7e97RJhnM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629783289; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=js47UnKHpLVIDeZMM6TzHwWdm6L6hRllOvh6ObjpC94=; b=Iy8vrmwCC9E48LVPCXiW9Dp9oB5ssCJDIQoQdXkab9RHmk3FGm9Gr6gdUeVzaCw8yRNdVfMiJVeKgoSNeom++VpCvnRLZqJpwObU7N8mFXlM6ukitiuZNbRJOgLL807aKtzRzL34nzruI7JrbS9ooOvuydWch/M6pcdvnFIxEdM= 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+79745+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 1629783289816365.02502984581963; Mon, 23 Aug 2021 22:34:49 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id amQTYY1788612xUtPK5v8Bkn; Mon, 23 Aug 2021 22:34:49 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.35646.1629783288968603943 for ; Mon, 23 Aug 2021 22:34:49 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AAF601042; Mon, 23 Aug 2021 22:34:48 -0700 (PDT) X-Received: from usa.arm.com (a077433.blr.arm.com [10.162.46.10]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7774F3F766; Mon, 23 Aug 2021 22:34:47 -0700 (PDT) From: "Omkar Anand Kulkarni" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Sami Mujawar Subject: [edk2-devel] [edk2-platforms][PATCH v3 4/5] EmbeddedPkg: Add helpers for HEST table generation Date: Tue, 24 Aug 2021 11:04:02 +0530 Message-Id: <20210824053403.24103-5-omkar.kulkarni@arm.com> In-Reply-To: <20210824053403.24103-1-omkar.kulkarni@arm.com> References: <20210824053403.24103-1-omkar.kulkarni@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,omkar.kulkarni@arm.com X-Gm-Message-State: 28ZCm6qoQRkYVoUFddQB5u6Zx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1629783289; bh=CwflYvNW7AADgPyfyK+iTm2xwJQOhRBSazsUE4onbLI=; h=Cc:Date:From:Reply-To:Subject:To; b=rNkpL7oAeXc9EBE5fS8UT/qzWqQN27E53BwYZtcLgUJxM+lxxRZZvJj7eOSUZZax2qp IFamu2OLKWyCxlzHB8QNuPG0CHPDGcO5Unl7YFOkdRyW81HUTBz78tFa7JqC3WmU6OjCh NP+l9U9jsX0VkCcZPaXPqb2GvsoshWLu7fI= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1629783291964100008 Content-Type: text/plain; charset="utf-8" Add helper macros for the generation of the HEST ACPI table. Macros to initialize the HEST GHESv2 Notification Structure and Error Status Structure are introduced. Signed-off-by: Omkar Anand Kulkarni Reviewed-by: Sami Mujawar --- EmbeddedPkg/Include/Library/AcpiLib.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/EmbeddedPkg/Include/Library/AcpiLib.h b/EmbeddedPkg/Include/Li= brary/AcpiLib.h index c142446d9d59..6de067823011 100644 --- a/EmbeddedPkg/Include/Library/AcpiLib.h +++ b/EmbeddedPkg/Include/Library/AcpiLib.h @@ -22,6 +22,7 @@ #define ARM_GAS16(Address) { EFI_ACPI_5_0_SYSTEM_MEMORY, 16, 0, EFI_AC= PI_5_0_WORD, Address } #define ARM_GAS32(Address) { EFI_ACPI_5_0_SYSTEM_MEMORY, 32, 0, EFI_AC= PI_5_0_DWORD, Address } #define ARM_GASN(Address) { EFI_ACPI_5_0_SYSTEM_MEMORY, 0, 0, EFI_AC= PI_5_0_DWORD, Address } +#define ARM_GAS64(Address) { EFI_ACPI_6_3_SYSTEM_MEMORY, 64, 0, EFI_AC= PI_6_3_QWORD, Address } =20 // // Macros for the Multiple APIC Description Table (MADT) @@ -89,6 +90,25 @@ WatchdogTimerGSIV, WatchdogTimerFlags = \ } =20 +// +// HEST table GHESv2 type related structure. +// Helper Macro to initialize the HEST GHESv2 Notification Structure. +// Refer Table 18-394 in ACPI Specification, Version 6.3. +// +#define EFI_ACPI_6_3_HARDWARE_ERROR_NOTIFICATION_STRUCTURE_INIT(Type, = \ + PollInterval, EventId) = \ + { = \ + Type, = \ + sizeof (EFI_ACPI_6_3_HARDWARE_ERROR_NOTIFICATION_STRUCTURE), = \ + {0, 0, 0, 0, 0, 0, 0}, /* ConfigurationWriteEnable */ = \ + PollInterval, = \ + EventId, = \ + 0, /* Poll Interval Threshold Value */ = \ + 0, /* Poll Interval Threshold Window */ = \ + 0, /* Error Threshold Value */ = \ + 0 /* Error Threshold Window */ = \ + } + typedef BOOLEAN (EFIAPI *EFI_LOCATE_ACPI_CHECK) ( --=20 2.17.1 -=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 (#79745): https://edk2.groups.io/g/devel/message/79745 Mute This Topic: https://groups.io/mt/85104608/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 Tue May 7 20:51:59 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+79746+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+79746+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1629783291; cv=none; d=zohomail.com; s=zohoarc; b=SR4P57H5+Ly/22tj5hphwryRJJ6Y6E2nHXvMq/sN9osUPchNFMut8CA7CEn6uvGif8sbh6hPuAvV9qTHZufIrDkWUKm/t53Kdl5yQuq0HXZqwxDLwunQYiaFYXOe1sWFKVLx5UUYrIE9mLWsTZdDoClF9G8VdgOLbOMMjJWK7hE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629783291; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=hkXk2xgQ4TMEUewdObLcgQ2ar2+2BFeA0oYF1FXrhR4=; b=KkfQ2UvT6xQ5zUvUQAFv4N/wy1L+uT+6Hg8n9TD1KFj4qwpBNIEkg8DXpgTedkccDKoedxUUc1J0SfVnZZNMIFp1n7JXv5EpCGJJMGqmOoYGEvbT607uN5r4nb91w4hYgprQndTBjwhw9JOiRy3nGAE6J7WDDZqzKRH0p3uxtBI= 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+79746+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 1629783291724595.8841877366227; Mon, 23 Aug 2021 22:34:51 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id xRaCYY1788612xaNnpXKlGNo; Mon, 23 Aug 2021 22:34:51 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web09.35515.1629783290696064299 for ; Mon, 23 Aug 2021 22:34:50 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 605F51042; Mon, 23 Aug 2021 22:34:50 -0700 (PDT) X-Received: from usa.arm.com (a077433.blr.arm.com [10.162.46.10]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2B0B73F766; Mon, 23 Aug 2021 22:34:48 -0700 (PDT) From: "Omkar Anand Kulkarni" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Sami Mujawar Subject: [edk2-devel] [edk2-platforms][PATCH v3 5/5] ArmPlatformPkg: Add Readme file Date: Tue, 24 Aug 2021 11:04:03 +0530 Message-Id: <20210824053403.24103-6-omkar.kulkarni@arm.com> In-Reply-To: <20210824053403.24103-1-omkar.kulkarni@arm.com> References: <20210824053403.24103-1-omkar.kulkarni@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,omkar.kulkarni@arm.com X-Gm-Message-State: UwKskdZiIyHeAIdHhXtk0Hmhx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1629783291; bh=BPeBK8tIDNKLXFkg2OllRtp1ZHXNeFo0buskC3n6wo4=; h=Cc:Date:From:Reply-To:Subject:To; b=GOUtZgH/RcXWj1nZR8HEQWeheUvOtDwslLePBecmqwQzFsz5cr9T17YQDys2EqbJnnK gtXMuiAX0Q41BLkzLRub2t0QSC97MDBM4iaWzvFWVfYC9rO9S3YM0Mhx2uBzTyv22ANJ2 AvCSHXZz3x8Evq1lKzvTilrVjMlD/k2v4x8= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1629783292231100010 Content-Type: text/plain; charset="utf-8" Added a readme file that explains the software framework for dynamic generation of HEST table. Signed-off-by: Omkar Anand Kulkarni Reviewed-by: Sami Mujawar --- ArmPlatformPkg/Drivers/HestMmErrorSources/Readme.md | 66 +++++++++++++++++= +++ 1 file changed, 66 insertions(+) diff --git a/ArmPlatformPkg/Drivers/HestMmErrorSources/Readme.md b/ArmPlatf= ormPkg/Drivers/HestMmErrorSources/Readme.md new file mode 100644 index 000000000000..1b6f0713cb9a --- /dev/null +++ b/ArmPlatformPkg/Drivers/HestMmErrorSources/Readme.md @@ -0,0 +1,66 @@ +Hardware Error Source Table (HEST)[1] and Software Delegated Exception Int= erface +(SDEI)[2] ACPI tables are used to acomplish firmware first error handling.= This +patch series introduces a framework to build and install the HEST ACPI tab= le +dynamically. + +The following figure illustrates the possible usage of the dyanamic +generation of HEST ACPI table. + + NS | S ++--------------------------------------+----------------------------------= ----+ +| | = | +|+-------------------------------------+---------------------+ = | +|| +---------------------+--------------------+| = | +|| | | || = | +|| +-----------+ |+------------------+ | +-----------------+|| +----------= ---+| +|| |HestTable | || HestErrorSource | | | HestErrorSource ||| | DMC-620 = || +|| | DXE | || DXE | | | StandaloneMM ||| |Standalone= MM|| +|| +-----------+ |+------------------+ | +-----------------+|| +----------= ---+| +|| |GHESv2 | || = | +|| +---------------------+--------------------+| = | +|| +--------------------+ | | = | +|| |PlatformErrorHandler| | | = | +|| | DXE | | | = | +|| +--------------------+ | | = | +||FF FWK | | = | +|+-------------------------------------+---------------------+ = | +| | = | ++--------------------------------------+----------------------------------= ----+ + | + Figure: Dynamic Hest Table Generation. + +All the hardware error sources are added to HEST table as GHESv2[3] error = source +descriptors. The framework comprises of following DXE and MM drivers: + +- HestTableDxe: + Builds HEST table header and allows appending error source descriptors t= o the + HEST table. Also provides protocol interface to install the built HEST t= able. + +- HestErrorSourceDxe & HestErrorSourceStandaloneMM: + These two drivers together retrieve all possible error source descriptor= s of + type GHESv2 from the MM drivers implementing HEST Error Source Descriptor + protocol. Once all the descriptors are collected HestErrorSourceDxe appe= nds + it to HEST table using HestTableDxe driver. + +- PlatformErrorHandlerDxe: + Builds and installs SDEI ACPI table. This driver does not initialize(loa= d) + until HestErrorSourceDxe driver has finished appending all possible GHES= v2 + error source descriptors to the HEST table. Once that is complete using = the + HestTableDxe driver it installs the HEST table. + +This patch series provides reference implementation for DMC-620 Dynamic Me= mory +Controller[4] that has RAS feature enabled. This is platform code +implemented as Standalone MM driver in edk2-platforms. + +References: +[1] : ACPI 6.3, Table 18-382, Hardware Error Source Table +[2] : SDEI Platform Design Document, revision b, 10 Appendix C, ACPI table + definitions for SDEI +[3] : ACPI Reference Specification 6.3, Table 18-393 GHESv2 Structure +[4] : DMC620 Dynamic Memory Controller, revision r1p0 +[5] : UEFI Reference Specification 2.8, Appendix N - Common Platform Error + Record +[6] : UEFI Reference Specification 2.8, Section N.2.5 Memory Error Section + +Link to github branch with the patches in this series - +https://github.com/omkkul01/edk2/tree/ras_firmware_first_edk2 --=20 2.17.1 -=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 (#79746): https://edk2.groups.io/g/devel/message/79746 Mute This Topic: https://groups.io/mt/85104610/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-