From nobody Sat May 18 14:25:17 2024 Delivered-To: importer@patchew.org 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+109365+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1696609715085261.797665832658; Fri, 6 Oct 2023 09:28:35 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=8TcgCpwYPbi+SryzGP5ZiFUXLpgO4ul1bpqV4whKEZ8=; 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=1696609714; v=1; b=YV3uWBVnosOwrlhPpygHRlNz5p4Vl8udwpS9kDPropObQPWmzJF0ogTffj0LiOstA6Huwcao buJRYn8yQf9m0TKK5EUGPWRxNNaO8hbpBq/K09Rvzm3mk2Tv9uxDjV/ORU6WoLVaqv5uDB2Qav9 AjKSyUoUVhkeJDRz35RcjPmI= X-Received: by 127.0.0.2 with SMTP id PBUeYY1788612xxWuWGSXQBw; Fri, 06 Oct 2023 09:28:34 -0700 X-Received: from NAM11-DM6-obe.outbound.protection.outlook.com (NAM11-DM6-obe.outbound.protection.outlook.com [40.107.223.47]) by mx.groups.io with SMTP id smtpd.web10.17510.1696609713985639641 for ; Fri, 06 Oct 2023 09:28:34 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=klsWUP1YInNq6lwDToJNAYTRLVDQJ+6lQkh00OOcUvqk5s5IoXdKPXdYDZ6Qr4Eo9EqU2DWTpMMTtbGAnKDw6P2a2kj9l/C0LosCmZYd5xQBfLaInViz4a5B149W4oyzj09RcBGAHH+wxOvXUK/QkdW2Ee1Hfl1QoGoncxbTscgyu8pSp+z86lJ2yGasABD6FpWhE5M5cQmTt2FGL0iAk33cZgjoLrDmoa5XgR5auVPqtfUwhi4KaRxuTjvXYZiHG7gsli3nzkqARUxZafa6pMoVcAMgdNtQgIUErXRo/x/TUWJPLme601H8HzBD0Gj/E1Ik8WVcRdhcLKIRi+CeGw== 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=P3nNvMGIBn4xub3ruMYS87LaajrSIR2fAOkvr+fcrS0=; b=V8UeNmoAT6OWC/Gu2rzKepbxz9GBvgDA0xLL41n0sK0vnqqdwbyEih9tPJCTee/3jTbS4OyuwSiNhQTe/85tCCa86yVHmDhBfgpC/nSf9WBYAIzYjFxPqODuE1y/cRH2Z3sRcjpemrNBrRCHBc/liSR41NZLTY9y9xEF1EPumO+U6PW6KrysAkeCRF0EBd1/zQOwycfJyLiAtbzbDZkJoHa5QvnKvD+FzS8wKDUL1MChwgCpK58T3WBmSSUufufygTCW9iDuNgBLx7V+jRPbTZGd0qKdQjFefBYcHq/n6hiDvuQwUFiUxwAd7fPmh7Vj8Zak+c+/28KvSW97hccxLw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) 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 MN2PR06CA0026.namprd06.prod.outlook.com (2603:10b6:208:23d::31) by DM8PR12MB5462.namprd12.prod.outlook.com (2603:10b6:8:24::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.39; Fri, 6 Oct 2023 16:28:30 +0000 X-Received: from MN1PEPF0000ECD7.namprd02.prod.outlook.com (2603:10b6:208:23d:cafe::78) by MN2PR06CA0026.outlook.office365.com (2603:10b6:208:23d::31) 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:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; 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+109365+1787277+3901457@groups.io; helo=mail02.groups.io; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C X-Received: from mail.nvidia.com (216.228.117.161) by MN1PEPF0000ECD7.mail.protection.outlook.com (10.167.242.136) 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:29 +0000 X-Received: from rnnvmail203.nvidia.com (10.129.68.9) by mail.nvidia.com (10.129.200.67) 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:14 -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:13 -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:13 -0700 From: "Jeshua Smith via groups.io" To: CC: , , Jeshua Smith Subject: [edk2-devel] [PATCH 1/2] DynamicTablesPkg/TableHelperLib: Fix and improve text handling Date: Fri, 6 Oct 2023 16:28:06 +0000 Message-ID: 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: MN1PEPF0000ECD7:EE_|DM8PR12MB5462:EE_ X-MS-Office365-Filtering-Correlation-Id: 49e0112a-5a5e-45a7-a967-08dbc6894695 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: LsbDlAodW6Pd0z9CVT8fBsj09YpPNsAn+lBoHThqGqyxBQw7qvY7/hVWuDp6k19Y3UIyc3q+p0g1halP4exXDRDJ40pWw3zMAF8hmvga6epFT2UE2Jo+nuiFirEjsTTGjDgNO78vzIu79wxmkoN1F3cMjau/chtGMt+jKmjAQ8+VlDHHcBZMx3h1A64DBY1GBrzWXBFwlnbkr8onQQ7QCC1KFAfu6odl+0hAiLTpV0Cgqs6GeqC6Gu8oe3zp8Xn3D4dsEF0wzuOPz9kid1PQgPAPxP5dd6ZAP2Y4fJhSAZHeZ9M3EyUZ/W/oBps9Xg8KWR56jF8u6h+TVOqOrmFZRr4NcjqClkM0khnPpVP3+U1qjggSC3KSCkYZnNX8esw1Km6+c3GMD/61NmDhKeV1FrtTvqUI25+TZZMsIE72gFDs3NJ+mNQYBs/WyxoehK2jln3VI874TM2HUHpS3FLFf2AIziyygUb0u0zlCR0cg2wQqaIas/xN7C3H2/1taz5uHD9C39+A6UhVg5KX63Wo3z/5pk0MNGD43WUhgYs+DeY6WKLw8Npgrfc6794+FUdRpfeFITee3lXaScPM2JThf8eqrFFw3M/F4mgH2CS24ylEmFD66Nv4t2+eqnslN+T0pcwEpBg+4nyOtoCYgVk6UBE/68jzT/epPuCMzLOkqfUY8BN2C7GKedFCUQ3S3QfSdlY528u1DxdNevowvcF0zVdoxD8tIeIDmxJsyz5naKezD+PdxqUxIY0ISzFjJ6P2 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Oct 2023 16:28:29.8214 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 49e0112a-5a5e-45a7-a967-08dbc6894695 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.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MN1PEPF0000ECD7.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM8PR12MB5462 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: ndHffVncWrXHgHPtGaR1taaex1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1696609715459100001 Content-Type: text/plain; charset="utf-8" This fixes two bugs and adds some enhancements to the handling of characters and strings in objects being printed by the CM ObjectParser. Bug fixes: 1. PrintOemID() currently attempts to print characters with "%C", but the correct syntax is (lowercase) "%c". This bug results in "CCCCCC" being printed instead of the actual ASCII characters. 2. PrintString() is being passed a pointer to data in objects, but in some cases this data is the actual string to print and other cases it is a pointer to the string to print. This adds a PrintStringPtr function and uses the correct functions depending on the situation. Enhancements: 1. Some objects contain ASCII characters, which are currently printed as their hex values. This adds functions to print out ASCII character fields as text rather than hex, and uses those functions in several cases where the object data is defined to be ASCII. 2. The PrintOemID() function is replaced with the new identical but more generecically-named PrintChar6() function. Signed-off-by: Jeshua Smith Reviewed-by: Pierre Gondois Reviewed-by: Sami Mujawar --- .../ConfigurationManagerObjectParser.c | 176 ++++++++++++++---- 1 file changed, 143 insertions(+), 33 deletions(-) diff --git a/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationMa= nagerObjectParser.c b/DynamicTablesPkg/Library/Common/TableHelperLib/Config= urationManagerObjectParser.c index 99d6032510..92df1efee8 100644 --- a/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerOb= jectParser.c +++ b/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerOb= jectParser.c @@ -14,7 +14,7 @@ STATIC VOID EFIAPI -PrintOemId ( +PrintString ( CONST CHAR8 *Format, UINT8 *Ptr ); @@ -22,7 +22,31 @@ PrintOemId ( STATIC VOID EFIAPI -PrintString ( +PrintStringPtr ( + CONST CHAR8 *Format, + UINT8 *Ptr + ); + +STATIC +VOID +EFIAPI +PrintChar4 ( + CONST CHAR8 *Format, + UINT8 *Ptr + ); + +STATIC +VOID +EFIAPI +PrintChar6 ( + CONST CHAR8 *Format, + UINT8 *Ptr + ); + +STATIC +VOID +EFIAPI +PrintChar8 ( CONST CHAR8 *Format, UINT8 *Ptr ); @@ -190,16 +214,16 @@ STATIC CONST CM_OBJ_PARSER CmArmItsGroupNodeParser[]= =3D { /** A parser for EArmObjNamedComponent. */ STATIC CONST CM_OBJ_PARSER CmArmNamedComponentNodeParser[] =3D { - { "Token", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL }, - { "IdMappingCount", 4, "0x%x", NULL }, - { "IdMappingToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL }, - { "Flags", 4, "0x%x", NULL }, - { "CacheCoherent", 4, "0x%x", NULL }, - { "AllocationHints", 1, "0x%x", NULL }, - { "MemoryAccessFlags", 1, "0x%x", NULL }, - { "AddressSizeLimit", 1, "0x%x", NULL }, - { "ObjectName", sizeof (CHAR8 *), NULL, PrintString }, - { "Identifier", 4, "0x%x", NULL }, + { "Token", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL = }, + { "IdMappingCount", 4, "0x%x", NULL = }, + { "IdMappingToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL = }, + { "Flags", 4, "0x%x", NULL = }, + { "CacheCoherent", 4, "0x%x", NULL = }, + { "AllocationHints", 1, "0x%x", NULL = }, + { "MemoryAccessFlags", 1, "0x%x", NULL = }, + { "AddressSizeLimit", 1, "0x%x", NULL = }, + { "ObjectName", sizeof (CHAR8 *), NULL, PrintStringPtr = }, + { "Identifier", 4, "0x%x", NULL = }, }; =20 /** A parser for EArmObjRootComplex. @@ -740,19 +764,19 @@ STATIC CONST CM_OBJ_PARSER_ARRAY ArmNamespaceObjectP= arser[] =3D { */ STATIC CONST CM_OBJ_PARSER StdObjCfgMgrInfoParser[] =3D { { "Revision", 4, "0x%x", NULL }, - { "OemId[6]", 6, "%C%C%C%C%C%C", PrintOemId } + { "OemId[6]", 6, "%c%c%c%c%c%c", PrintChar6 } }; =20 /** A parser for EStdObjAcpiTableList. */ STATIC CONST CM_OBJ_PARSER StdObjAcpiTableInfoParser[] =3D { - { "AcpiTableSignature", 4, "0x%x", = NULL }, - { "AcpiTableRevision", 1, "%d", = NULL }, - { "TableGeneratorId", sizeof (ACPI_TABLE_GENERATOR_ID), "0x%x", = NULL }, - { "AcpiTableData", sizeof (EFI_ACPI_DESCRIPTION_HEADER *), "0x%p", = NULL }, - { "OemTableId", 8, "0x%LLX"= , NULL }, - { "OemRevision", 4, "0x%x", = NULL }, - { "MinorRevision", 1, "0x%x", = NULL }, + { "AcpiTableSignature", 4, "%c%c%c%= c", PrintChar4 }, + { "AcpiTableRevision", 1, "%d", = NULL }, + { "TableGeneratorId", sizeof (ACPI_TABLE_GENERATOR_ID), "0x%x", = NULL }, + { "AcpiTableData", sizeof (EFI_ACPI_DESCRIPTION_HEADER *), "0x%p", = NULL }, + { "OemTableId", 8, "%c%c%c%= c%c%c%c%c", PrintChar8 }, + { "OemRevision", 4, "0x%x", = NULL }, + { "MinorRevision", 1, "0x%x", = NULL }, }; =20 /** A parser for EStdObjSmbiosTableList. @@ -773,22 +797,99 @@ STATIC CONST CM_OBJ_PARSER_ARRAY StdNamespaceObjectP= arser[] =3D { ARRAY_SIZE (StdObjSmbiosTableInfoParser) }, }; =20 -/** Print OEM Id. +/** Print string data. + + The string must be NULL terminated. + + @param [in] Format Format to print the Ptr. + @param [in] Ptr Pointer to the string. +**/ +STATIC +VOID +EFIAPI +PrintString ( + IN CONST CHAR8 *Format, + IN UINT8 *Ptr + ) +{ + if (Ptr =3D=3D NULL) { + ASSERT (0); + return; + } + + DEBUG ((DEBUG_ERROR, "%a", Ptr)); +} + +/** Print string from pointer. + + The string must be NULL terminated. + + @param [in] Format Format to print the string. + @param [in] Ptr Pointer to the string pointer. +**/ +STATIC +VOID +EFIAPI +PrintStringPtr ( + IN CONST CHAR8 *Format, + IN UINT8 *Ptr + ) +{ + UINT8 *String; + + if (Ptr =3D=3D NULL) { + ASSERT (0); + return; + } + + String =3D *(UINT8 **)Ptr; + + if (String =3D=3D NULL) { + String =3D (UINT8 *)"(NULLPTR)"; + } + + PrintString (Format, String); +} + +/** Print 4 characters. =20 @param [in] Format Format to print the Ptr. - @param [in] Ptr Pointer to the OEM Id. + @param [in] Ptr Pointer to the characters. **/ STATIC VOID EFIAPI -PrintOemId ( +PrintChar4 ( IN CONST CHAR8 *Format, IN UINT8 *Ptr ) { DEBUG (( - DEBUG_INFO, - (Format !=3D NULL) ? Format : "%C%C%C%C%C%C", + DEBUG_ERROR, + (Format !=3D NULL) ? Format : "%c%c%c%c", + Ptr[0], + Ptr[1], + Ptr[2], + Ptr[3] + )); +} + +/** Print 6 characters. + + @param [in] Format Format to print the Ptr. + @param [in] Ptr Pointer to the characters. +**/ +STATIC +VOID +EFIAPI +PrintChar6 ( + IN CONST CHAR8 *Format, + IN UINT8 *Ptr + ) +{ + DEBUG (( + DEBUG_ERROR, + (Format !=3D NULL) ? Format : "%c%c%c%c%c%c", Ptr[0], Ptr[1], Ptr[2], @@ -798,22 +899,31 @@ PrintOemId ( )); } =20 -/** Print string. - - The string must be NULL terminated. +/** Print 8 characters. =20 @param [in] Format Format to print the Ptr. - @param [in] Ptr Pointer to the string. + @param [in] Ptr Pointer to the characters. **/ STATIC VOID EFIAPI -PrintString ( - CONST CHAR8 *Format, - UINT8 *Ptr +PrintChar8 ( + IN CONST CHAR8 *Format, + IN UINT8 *Ptr ) { - DEBUG ((DEBUG_ERROR, "%a", Ptr)); + DEBUG (( + DEBUG_ERROR, + (Format !=3D NULL) ? Format : "%c%c%c%c%c%c%c%c", + Ptr[0], + Ptr[1], + Ptr[2], + Ptr[3], + Ptr[4], + Ptr[5], + Ptr[6], + Ptr[7] + )); } =20 /** Print fields of the objects. --=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 (#109365): https://edk2.groups.io/g/devel/message/109365 Mute This Topic: https://groups.io/mt/101801390/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 Sat May 18 14:25:17 2024 Delivered-To: importer@patchew.org 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+109364+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 16966097098221008.4781517854094; Fri, 6 Oct 2023 09:28:29 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=6d89jj6PZZUb0iPHWrwnfAsGBB4XAEHc5ZOI/AEBfwE=; 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=h4jnb6tyFW7ZMmxrkoSfzC7CBhIYMJ7/41R65X+ypP43x+3nAiLeBo7S0l5KjoVmaWp+lq2c ar0hoMoDLLJ6mnM9Blki6xoqU/VONA97cy6zurdJ65A1Y3AFRbtFK3JvRl07+ccnIOo6dE5Asj9 wSVfC6a2HhvybSaW9yi7ZNCo= X-Received: by 127.0.0.2 with SMTP id VfZkYY1788612xq4qLlqZ9lY; 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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+109364+1787277+3901457@groups.io; helo=mail02.groups.io; 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: FmtrkzrCza8gXhxeYGRZC7cqx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1696609711422100001 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Pierre Gondois Reviewed-by: Sami Mujawar --- .../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/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-