From nobody Tue Feb 10 19:08:58 2026 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+81692+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+81692+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1633704406; cv=none; d=zohomail.com; s=zohoarc; b=mj3qqRm1uVwj8TQCVuK6101EUxlU8+UG0nTbCUEMt0K74j+/cvU+YHdtpTnEkS/zUtnXVRRocpibpvt3S+ijZnLBj8f3iB72HtfofuXSRLBoUvlV6NeX77c8nwU+f1D3QBXR29yAr2pLepx2LWvc1k4zZrbdn1rOG63773/RXko= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633704406; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=zr7YTJCSzahe/9aXgh+UIXlJsecudD6HKOYNPcByHtQ=; b=idGsL2xMhkuOevcoGXRxAzGQTct18pr1j7+bqrXSwoMpicCBGUIhAGuihk7rnLeUgNQljJjNcLy2HaPhj13RvoGrKHAMu53U8DdTKqJkTItKGQBxy5MVTJLGNaqGB3x6cVJJz16wUrpss4dc+q/HGQN5qahuN2jlfopXsnlzsvI= 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+81692+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 1633704406619713.1693502191782; Fri, 8 Oct 2021 07:46:46 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id xenVYY1788612xY4XSHNvmBW; Fri, 08 Oct 2021 07:46:46 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web09.10571.1633704405766240838 for ; Fri, 08 Oct 2021 07:46: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 5695C1063; Fri, 8 Oct 2021 07:46:45 -0700 (PDT) X-Received: from e120189.arm.com (unknown [10.57.73.60]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4CA523F66F; Fri, 8 Oct 2021 07:46:44 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com Subject: [edk2-devel] [PATCH v3 06/21] DynamicTablesPkg: Set EndTag's Checksum if RdList is modified Date: Fri, 8 Oct 2021 15:46:17 +0100 Message-Id: <20211008144632.31894-7-Pierre.Gondois@arm.com> In-Reply-To: <20211008144632.31894-1-Pierre.Gondois@arm.com> References: <20211008144632.31894-1-Pierre.Gondois@arm.com> 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,pierre.gondois@arm.com X-Gm-Message-State: syxEXSSJXwLsiP87CWQaX7umx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1633704406; bh=VspnJo5fgo3+r9ZIZ01QJUyOP6JWp+EPyxfx30Wratc=; h=Date:From:Reply-To:Subject:To; b=bdG1VA7swUXuvZT9RhdOaTHr83RV0ze1KWH4UyMxYJLWrmNfSNMDkMiSeWnap3Ddtwr 6Kki4OsrEP85m9sMyH2tbMmRGxp8zXqMQIDY6Twp9g7hWJONtNCVh1DXQbT6h/M/5n0QM OmXxjK2t4PAuzFlMZIbbVt4tn6IC7v1KC7Q= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1633704408304100002 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois ACPI 6.4, s6.4.2.9 "End Tag": "This checksum is generated such that adding it to the sum of all the data bytes will produce a zero sum." "If the checksum field is zero, the resource data is treated as if the checksum operation succeeded. Configuration proceeds normally." To avoid re-computing checksums, if a new resource data elements is added/removed/modified in a list of resource data elements, the AmlLib resets the checksum to 0. This patch also refactors the AmlAppendRdNode() function by getting the last Resource Data node directly instead of iterating over all the elements of the list of Resource Data node. Reviewed-by: Sami Mujawar Signed-off-by: Pierre Gondois --- .../Common/AmlLib/Tree/AmlNodeInterface.c | 7 ++ .../Library/Common/AmlLib/Tree/AmlTree.c | 72 +++++++------------ 2 files changed, 34 insertions(+), 45 deletions(-) diff --git a/DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlNodeInterface.c= b/DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlNodeInterface.c index 870346c40a5d..f91bc5fd55d2 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlNodeInterface.c +++ b/DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlNodeInterface.c @@ -513,6 +513,13 @@ AmlUpdateDataNode ( ASSERT (0); return EFI_INVALID_PARAMETER; } + + Status =3D AmlSetRdListCheckSum (ParentNode, 0); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + break; } case EAmlNodeDataTypeFieldPkgLen: diff --git a/DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlTree.c b/Dynami= cTablesPkg/Library/Common/AmlLib/Tree/AmlTree.c index 0931e751709e..2772e915f468 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlTree.c +++ b/DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlTree.c @@ -566,8 +566,7 @@ AmlAppendRdNode ( ) { EFI_STATUS Status; - AML_DATA_NODE * CurrRdNode; - AML_RD_HEADER RdDataType; + AML_DATA_NODE * LastRdNode; =20 if (!AmlNodeCompareOpCode (BufferOpNode, AML_BUFFER_OP, 0) || !IS_AML_DATA_NODE (NewRdNode) || @@ -576,56 +575,39 @@ AmlAppendRdNode ( return EFI_INVALID_PARAMETER; } =20 - // Get the first Resource data node in the variable list of - // argument of the BufferOp node. - CurrRdNode =3D (AML_DATA_NODE*)AmlGetNextVariableArgument ( + // To avoid re-computing checksums, if a new resource data elements is + // added/removed/modified in a list of resource data elements, the AmlLib + // resets the checksum to 0. + // It is possible to have only one Resource Data in a BufferOp with + // no EndTag, but it should not be possible to add a new Resource Data + // in the list in this case. + Status =3D AmlSetRdListCheckSum (BufferOpNode, 0); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + // Get the last Resource data node in the variable list of argument of t= he + // BufferOp node. This must be an EndTag, otherwise setting the checksum + // would have failed. + LastRdNode =3D (AML_DATA_NODE*)AmlGetPreviousVariableArgument ( (AML_NODE_HEADER*)BufferOpNode, NULL ); - if ((CurrRdNode =3D=3D NULL) || - !IS_AML_DATA_NODE (CurrRdNode) || - (CurrRdNode->DataType !=3D EAmlNodeDataTypeResourceData)) { + if ((LastRdNode =3D=3D NULL) || + !IS_AML_DATA_NODE (LastRdNode) || + (LastRdNode->DataType !=3D EAmlNodeDataTypeResourceData)) { ASSERT (0); return EFI_INVALID_PARAMETER; } =20 - // Iterate through the Resource Data nodes to find the End Tag. - while (TRUE) { - Status =3D AmlGetResourceDataType (CurrRdNode, &RdDataType); - if (EFI_ERROR (Status)) { - ASSERT (0); - return Status; - } - - // If the Resource Data is an End Tag, - // add the new node before and return. - if (AmlRdCompareDescId ( - &RdDataType, - AML_RD_BUILD_SMALL_DESC_ID (ACPI_SMALL_END_TAG_DESCRIPTOR_NAME))= ) { - Status =3D AmlVarListAddBefore ( - (AML_NODE_HEADER*)CurrRdNode, - (AML_NODE_HEADER*)NewRdNode) - ; - if (EFI_ERROR (Status)) { - ASSERT (0); - } - return Status; - } - - // Get the next Resource Data node. - // If this was the last node and no End Tag was found, return error. - // It is possible to have only one Resource Data in a BufferOp, - // but it should not be possible to add a new Resource Data in the list - // in this case. - CurrRdNode =3D (AML_DATA_NODE*)AmlGetSiblingVariableArgument ( - (AML_NODE_HEADER*)CurrRdNode - ); - if (!IS_AML_DATA_NODE (CurrRdNode) || - (CurrRdNode->DataType !=3D EAmlNodeDataTypeResourceData)) { - ASSERT (0); - return EFI_INVALID_PARAMETER; - } - } // while + // Add NewRdNode before the EndTag. + Status =3D AmlVarListAddBefore ( + (AML_NODE_HEADER*)LastRdNode, + (AML_NODE_HEADER*)NewRdNode) + ; + ASSERT_EFI_ERROR (Status); + return Status; } =20 /** Replace the fixed argument at the Index of the ParentNode with the New= Node. --=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 (#81692): https://edk2.groups.io/g/devel/message/81692 Mute This Topic: https://groups.io/mt/86172098/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-