From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 432B7D8026F for ; Tue, 10 Oct 2023 10:13:52 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=j+agRVQtGCJELV8cYgWnU90+4l5rcdTBZKMzVKNGK6Q=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1696932831; v=1; b=U+xlObLY2sYn1jzf4Y0/A4oQ3L2zt45u5Cz+A35PHPIjj2NWw+BCNyQAseOlGEatzSH/CGc4 j/kHUX7AzYCQsbnD9Iby0l7prVA1M2neCjUo7Zj/Kqlgtk6jx5XJ9NLhE6IXA0dWqNipP3n3dRb 1PYELypun2pJUAYOn8u+HTpo= X-Received: by 127.0.0.2 with SMTP id PagKYY7687511xeTPZy6FhUt; Tue, 10 Oct 2023 03:13:51 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.87893.1696932830157957656 for ; Tue, 10 Oct 2023 03:13: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 642D01FB; Tue, 10 Oct 2023 03:14:30 -0700 (PDT) X-Received: from [10.34.100.114] (e126645.nice.arm.com [10.34.100.114]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1CF5D3F762; Tue, 10 Oct 2023 03:13:48 -0700 (PDT) Message-ID: Date: Tue, 10 Oct 2023 12:13:47 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [edk2-devel] [PATCH 2/2] DynamicTablesPkg/TableHelperLib: Enhance error handling To: Jeshua Smith , devel@edk2.groups.io Cc: Sami.Mujawar@arm.com References: <3883194c96ec01f32932c484d0a9f64abbad3f46.1696608794.git.jeshuas@nvidia.com> From: "PierreGondois" In-Reply-To: <3883194c96ec01f32932c484d0a9f64abbad3f46.1696608794.git.jeshuas@nvidia.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,pierre.gondois@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: pJRDiE8nRIrYv02XXh2jP10Yx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=U+xlObLY; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=arm.com (policy=none) Hello Jeshua, On 10/6/23 18:28, Jeshua Smith wrote: > This patch enhances error handling and reporting in the CM ObjectParser. > Specifically: > 1. ObjectIDs used as array indexes are checked for being out of bounds, > and if so an error message is printed before the assert. > 2. An error message is printed for unsupported NameSpaceIDs. > 3. Adds support for unimplemented parsers by allowing IDs to list a > NULL parser, resulting in an unimplemented message being printed. I am not sure I see in which context 3. would be used/necessary. Is it poss= ible to detail ? (Code-wise everything looks good to me) Regards, Pierre >=20 > Signed-off-by: Jeshua Smith > --- > .../ConfigurationManagerObjectParser.c | 47 +++++++++++++------ > 1 file changed, 33 insertions(+), 14 deletions(-) >=20 > diff --git a/DynamicTablesPkg/Library/Common/TableHelperLib/Configuration= ManagerObjectParser.c b/DynamicTablesPkg/Library/Common/TableHelperLib/Conf= igurationManagerObjectParser.c > index 92df1efee8..22b8fdb906 100644 > --- a/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManager= ObjectParser.c > +++ b/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManager= ObjectParser.c > @@ -795,6 +795,7 @@ STATIC CONST CM_OBJ_PARSER_ARRAY StdNamespaceObjectP= arser[] =3D { > ARRAY_SIZE (StdObjAcpiTableInfoParser) }, > { "EStdObjSmbiosTableList", StdObjSmbiosTableInfoParser, > ARRAY_SIZE (StdObjSmbiosTableInfoParser) }, > + { "EStdObjMax", NULL, 0} > }; > =20 > /** Print string data. > @@ -1066,6 +1067,12 @@ ParseCmObjDesc ( > return; > } > =20 > + if (ObjId >=3D ARRAY_SIZE (StdNamespaceObjectParser)) { > + DEBUG ((DEBUG_ERROR, "ObjId 0x%x is missing from the StdNamespac= eObjectParser array\n", ObjId)); > + ASSERT (0); > + return; > + } > + > ParserArray =3D &StdNamespaceObjectParser[ObjId]; > break; > case EObjNameSpaceArm: > @@ -1074,10 +1081,17 @@ ParseCmObjDesc ( > return; > } > =20 > + if (ObjId >=3D ARRAY_SIZE (ArmNamespaceObjectParser)) { > + DEBUG ((DEBUG_ERROR, "ObjId 0x%x is missing from the ArmNamespac= eObjectParser array\n", ObjId)); > + ASSERT (0); > + return; > + } > + > ParserArray =3D &ArmNamespaceObjectParser[ObjId]; > break; > default: > // Not supported > + DEBUG ((DEBUG_ERROR, "NameSpaceId 0x%x, ObjId 0x%x is not supporte= d by the parser\n", NameSpaceId, ObjId)); > ASSERT (0); > return; > } // switch > @@ -1095,21 +1109,26 @@ ParseCmObjDesc ( > ObjIndex + 1, > ObjectCount > )); > - PrintCmObjDesc ( > - (VOID *)((UINTN)CmObjDesc->Data + Offset), > - ParserArray->Parser, > - ParserArray->ItemCount, > - &RemainingSize, > - 1 > - ); > - if ((RemainingSize > CmObjDesc->Size) || > - (RemainingSize < 0)) > - { > - ASSERT (0); > - return; > - } > + if (ParserArray->Parser =3D=3D NULL) { > + DEBUG ((DEBUG_ERROR, "Parser not implemented\n")); > + RemainingSize =3D 0; > + } else { > + PrintCmObjDesc ( > + (VOID *)((UINTN)CmObjDesc->Data + Offset), > + ParserArray->Parser, > + ParserArray->ItemCount, > + &RemainingSize, > + 1 > + ); > + if ((RemainingSize > CmObjDesc->Size) || > + (RemainingSize < 0)) > + { > + ASSERT (0); > + return; > + } > =20 > - Offset =3D CmObjDesc->Size - RemainingSize; > + Offset =3D CmObjDesc->Size - RemainingSize; > + } > } // for > =20 > ASSERT (RemainingSize =3D=3D 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 (#109486): https://edk2.groups.io/g/devel/message/109486 Mute This Topic: https://groups.io/mt/101801385/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-