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 EDEA0740032 for ; Fri, 6 Oct 2023 16:28:30 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=txU+5W62EY881UIeukNqopUDjcUB9EkmrfXEORhL73I=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:Received-SPF: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=1696609709; v=1; b=szuQ/QYeUZu+mvhw+U/Zr0eBIvocn6/ZNAnyKmmH9tVKP7roJpIioBX2JiVrs2LGzeWk1RnE Yvz2bEeKSBvW8tL1yEinkPZMU0+hUUsKANUVRtV1xeJd4MGPcnBZbvSVeaar5j9CXxA/hDI3YPu ed4rFFwQA1Kt/c7we4k0Xfkc= X-Received: by 127.0.0.2 with SMTP id pTAGYY7687511xmgZy45nCaC; Fri, 06 Oct 2023 09:28:29 -0700 X-Received: from NAM12-DM6-obe.outbound.protection.outlook.com (NAM12-DM6-obe.outbound.protection.outlook.com [40.107.243.54]) by mx.groups.io with SMTP id smtpd.web10.17503.1696609708875355063 for ; Fri, 06 Oct 2023 09:28:28 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mji3Osthb/+GojznsUmCl2B/yG+rZyrbaj9gQfykpSWeOtUhX8/K4o5kOAVnmi0dJPr/f/TbySxEP2PKGFFRkhBrkaRsQ0fBL8BOkuCUSW+nQd7P0VYvJF2lUueNg7wv9cp4t6s06plBGdY5tg5be6jIPui9Ou89ozd1D06qvhODq0CaCdQ/xYIizNJ9EndiH4MhJdoqAcl12TU/uzBe8F4PC+BJBeB6JyeKjUuCvV05oShPQBjP3HieglHnHAZymxNPV71BQ/z3usvpKF+M3zGJvM1qy5vhxQ6N17wNCd/KE/AH1GLpz66HpXtlboXNbJ3D3ILHBMOmKxJaStjS1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=AOyOl1IC+cw8x1IAygTfsKdixkzaf9Of8euNLuOPEts=; b=EsFqKdSZDhGRcSmNAJqkT4NqRObF/BQiscbHLiIN/tVGp1yik7AkIIj86ueQrQyFSc36H3zxiAtMDGNlHQHojiHMbsmvc3/HL37WcWQEYEE0IawFiy8sLRYGH3AntuyjZFuhzuPEglMMYRKMj3vejpADnDfE7slJNBb+CpEWdfKCYcu/XT0OjnpXRKc2Hee1StOScDq2EELdEfTKhJB7pahLDde2zVbRin2nBrd8VxtCeZ0sZwJuc9JOiPvFFw3DBipC1RmDeApVw/jeYvLdgYUYqogn3EiJTOMwX090v5rbfdvlcXIEqh2iap3qWuhzEzuvRi83vA6JPK8JfxeGeg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none X-Received: from BYAPR03CA0020.namprd03.prod.outlook.com (2603:10b6:a02:a8::33) by DM6PR12MB4353.namprd12.prod.outlook.com (2603:10b6:5:2a6::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.35; Fri, 6 Oct 2023 16:28:26 +0000 X-Received: from CO1PEPF000042AB.namprd03.prod.outlook.com (2603:10b6:a02:a8:cafe::c7) by BYAPR03CA0020.outlook.office365.com (2603:10b6:a02:a8::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.29 via Frontend Transport; Fri, 6 Oct 2023 16:28:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C X-Received: from mail.nvidia.com (216.228.117.160) by CO1PEPF000042AB.mail.protection.outlook.com (10.167.243.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.14 via Frontend Transport; Fri, 6 Oct 2023 16:28:26 +0000 X-Received: from rnnvmail203.nvidia.com (10.129.68.9) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 6 Oct 2023 09:28:15 -0700 X-Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 6 Oct 2023 09:28:15 -0700 X-Received: from localhost.localdomain (10.127.8.11) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Fri, 6 Oct 2023 09:28:15 -0700 From: "Jeshua Smith via groups.io" To: CC: , , Jeshua Smith Subject: [edk2-devel] [PATCH 2/2] DynamicTablesPkg/TableHelperLib: Enhance error handling Date: Fri, 6 Oct 2023 16:28:07 +0000 Message-ID: <3883194c96ec01f32932c484d0a9f64abbad3f46.1696608794.git.jeshuas@nvidia.com> In-Reply-To: References: MIME-Version: 1.0 X-NVConfidentiality: public X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000042AB:EE_|DM6PR12MB4353:EE_ X-MS-Office365-Filtering-Correlation-Id: cb811794-2ce5-4380-8f21-08dbc6894459 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: KpSmZXYk1DDC2OqFVMJfqTglsNEX5LDSA7aNRGxBji5Bjm1ocSZmOadP0uP9KFeeEEsCqOrEqggn39bvJ1r50/YxJ4MKoOM6v1YC8X4Qmq1G0KiNgk28OdKP/LNwu4tliGcm77TKErWuQ+S8jWx268ipMGN/7KiS3AleM/maC+d1J5xjkAE5bwCim6EgSguQFCE/EXATreYlqSqfs3AwnMj49JFIUR88jYHk6QcMRdhABRLB9BP6fWPTy+7DKG7OrBEZfW+ivI4+bUlnEi6ACxwmbHvWx7fCljxZEaA+pAIZ7bSjuL3Pmi+qJ0JlZLTPxSOV3nvYnlLwx7SVv+Nku/PLHjf6FYcPvXt6kj7axiNgI3evb01/P9clZfcoQE6vlEcAjvnKk2+1XXb8Ph31TE4uA97nfLrHqYoiiY3Fyn0ycct+Y1dOc6mP3sftj7c4dpCYqW7wZU9len5GoeqEmftm+xuEtNFT7JY7NF69ir3xaIJsuzxV87usRJ8ZlXXhujhCQtMwj6s6eaXzxeQdv7dM+2oF2q9db1aPwJnrmJKyTc7GixSn9NtZx3RMiq96nLjGQpu5X1JEQzYIZpk5MuQRm7cXHufeJqJsMOFenCrDh98lQRFRvX7qhyE1isj75oXXCQ65XUN60pwoqOVeKo881U8xKR/oT2zjZiMnqCtmXFsjccnFLQoQAhvYW6b+GZixOvVMiychdPvp8iPhdssCh6ik/JRINsYuEGZZtcLxvyyOlGgTG3HLpL6AYQdh X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Oct 2023 16:28:26.1658 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cb811794-2ce5-4380-8f21-08dbc6894459 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000042AB.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4353 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,jeshuas@nvidia.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 8fVAW50bF4jkgqBSBJKlWJfLx7686176AA= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b="szuQ/QYe"; dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}") 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. Signed-off-by: Jeshua Smith --- .../ConfigurationManagerObjectParser.c | 47 +++++++++++++------ 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationMa= nagerObjectParser.c b/DynamicTablesPkg/Library/Common/TableHelperLib/Config= urationManagerObjectParser.c index 92df1efee8..22b8fdb906 100644 --- a/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerOb= jectParser.c +++ b/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerOb= jectParser.c @@ -795,6 +795,7 @@ STATIC CONST CM_OBJ_PARSER_ARRAY StdNamespaceObjectPar= ser[] =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 StdNamespaceO= bjectParser 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 ArmNamespaceO= bjectParser 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 supported = 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); --=20 2.25.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 (#109364): https://edk2.groups.io/g/devel/message/109364 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-