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 0450A740037 for ; Mon, 18 Sep 2023 13:08:54 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=3uDsgOAax+J3Sgixss1G69qqIuZEbB20pzve8m0IcZo=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:Received-SPF:From:To:CC:Subject:Date:Message-ID: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=1695042533; v=1; b=YAZvzLed6xrcz1EkYlFr4FZwzYT280pWbRUlcHFrqlNw+IhzgHeE9QYRdTlfEJRiGbEJpT7n J09kUbBiSuQ9rTipcnqTjSfkOtWFlvcKyLtFLSAl7NVcOnQNIYhijpXrwuYYjGir/WeTTCfVQtF vyzTCmYfVGYOefJ9HzfmcWmg= X-Received: by 127.0.0.2 with SMTP id rfGbYY7687511xxI1WCn7WWi; Mon, 18 Sep 2023 06:08:53 -0700 X-Received: from NAM10-DM6-obe.outbound.protection.outlook.com (NAM10-DM6-obe.outbound.protection.outlook.com [40.107.93.54]) by mx.groups.io with SMTP id smtpd.web10.50537.1695042532783510778 for ; Mon, 18 Sep 2023 06:08:53 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B1e8BkOz1RSVHmUvWpHULox1l6XhE+q944anT6UEgCCiMCHQdiZcMkThesCDyEenp4JR4gj6AYoyeF1RlqMYeMsOCxShAgKNPJA9kpNmIVvRvGqXEO6tsGWkDiXU5dPPkDn/I5497OsSB+3bOrsqFKi09rzHwAmLbu9YNHTygsPR+J4pPlS+1Lysjym6SX8Uk+zroZ69FNN8w2TuDiDPS2VWo7m8UPO66nBbugvK41sVQBKTmHWaU79WSaNzJapsdT2jsXbDxp0igJfTU1nrou+wCJwXLPhOMf7FYGVsOPNPMbnotgijRYSZG3aR5o642pVwwY24vbR8SiAkDDUp5w== 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=pG0cu5G8mrgur0UeEaw/F0Z4ce8fwEaFr5u3OmbDzNs=; b=JQ/E1UyyGgSAK8uMfUT2VJMFiLj8qtFFFX1gMv+nubscFLXzkAkSRv7smsa9vJFkR0t0TtBq55bmlx5RQDt2dR621FCWCgtjngB95z+RgwFF+a1TTxnok3GESlDXvq9yi6CC0GyxWRtxSNbdxwQJNPWPrXCY2XqVCa41E1lC0WUUvJkIcJJKQvxKqrHeA62MxCqgFOjktM/pyPFZus6CZb3E+41JDAq+DaaZ/eszMemU3wIn6ez1o8XYt+oFwnJDeOTmll6htGJNkB737GTBwUFgFAb/8eSqKeA2cqD8gLtPItxQ455sFjqqTU3bll4SQnDT1Bu1jtOHBFDmkhUUdA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) 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 SN7PR04CA0190.namprd04.prod.outlook.com (2603:10b6:806:126::15) by LV8PR12MB9156.namprd12.prod.outlook.com (2603:10b6:408:181::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27; Mon, 18 Sep 2023 13:08:49 +0000 X-Received: from SN1PEPF0002636E.namprd02.prod.outlook.com (2603:10b6:806:126:cafe::ea) by SN7PR04CA0190.outlook.office365.com (2603:10b6:806:126::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27 via Frontend Transport; Mon, 18 Sep 2023 13:08:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) 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.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C X-Received: from mail.nvidia.com (216.228.118.233) by SN1PEPF0002636E.mail.protection.outlook.com (10.167.241.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.20 via Frontend Transport; Mon, 18 Sep 2023 13:08:49 +0000 X-Received: from drhqmail202.nvidia.com (10.126.190.181) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 18 Sep 2023 06:08:40 -0700 X-Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 18 Sep 2023 06:08:40 -0700 X-Received: from NV-CL38DL3.nvidia.com (10.127.8.14) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Mon, 18 Sep 2023 06:08:39 -0700 From: "Nickle Wang via groups.io" To: CC: Abner Chang , Igor Kulchytskyy , "Nick Ramirez" Subject: [edk2-devel] [PATCH] RedfishPkg/JsonLib: fix JsonObjectGetValue issue Date: Mon, 18 Sep 2023 21:08:38 +0800 Message-ID: <20230918130838.6137-1-nicklew@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636E:EE_|LV8PR12MB9156:EE_ X-MS-Office365-Filtering-Correlation-Id: 43be57cf-2515-42b0-43e3-08dbb8486613 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: 22iykbSlUGxDMY9+bvraIQerOFdM4KGUyE7U8Yo1azJApG/deVlfxWAkokLsZTYDAma23UeIOsePmEaFv1LPBrMakYOI2Vj0Fasrw3qs0PZfqUMGv1DAJ6KFQqzzij2sQoFmMRcsx26xz6dh2h9qF9blVn3mC1NEka3jbdycdYc0aFV46HdUGNbHj/TLIN1d/ix5+r6KCwGz/r58O/D7bDHjxg63/A4kEJSQDQiL75O0Bmm8xd9d6Q/kyXb79QAmc+M04fid1mfd5YmG6YpjC71IbTkTfKB9rOEv1qaalmKIM26bP+NQrsumo1AfdttGhn6lSuwFazbvM7UW8W3rtNEBVVnSKQ8b2Vl8Wij0NvG93thu6+cz714tmhT8FSXcLDMc2lyGuBCH5RKHrSAnXCs0ZcXwGZHpk3qe/Knn2VIihM5/xbdKvulzyR6W+tmgpN+iz2EgzQyuojyGBb21powzeJG7FEIMl8VzVT/RIpALQ09VBIma+TL/+MuzkDy4pf5MYTHVz6e8aOBAQsIia3GB0JiQCSllUOHH6/UT5Iao+5SWGytaw+OlBWGoIdJZ8Hkr7CrQzAFuX/xGkSP+pozkKcrE+it0TxKvlQUrD6dBG9gA3/7GQOUv9THH6C758Z6MJ6LIaUmZSPYlNsO7M5X5ZOeV/xicU4zB8TCZ0KzrBP+0CB6yJOrSuesRI+Ejdu1/7S9WvGGyodtADprDVgeVQIi5juTIZzBVNZBBEM2dh9U6/XlnpcewVRby2RKu X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2023 13:08:49.1501 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 43be57cf-2515-42b0-43e3-08dbb8486613 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF0002636E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR12MB9156 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,nicklew@nvidia.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 6mYth2mupeeOT9aY16MtJzmAx7686176AA= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-Spam-Flag: yes X-Spam-Level: ************ X-GND-Spam-Score: 190 X-GND-Status: SPAM Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=YAZvzLed; 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}") JsonObjectGetValue() cannot find corresponding JSON value when the EDKII_JSON_VALUE object is created by another UEFI driver. This is because "hashtable_seed" is initialized by current time while JsonLib is loaded. So, "hashtable_seed" will be different in each individual UEFI driver. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Igor Kulchytskyy Cc: Nick Ramirez --- RedfishPkg/Library/JsonLib/JsonLib.inf | 1 + RedfishPkg/Library/JsonLib/JsonLib.c | 34 ++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/RedfishPkg/Library/JsonLib/JsonLib.inf b/RedfishPkg/Library/Js= onLib/JsonLib.inf index 9d52a622e13a..b0d1bcac7cb3 100644 --- a/RedfishPkg/Library/JsonLib/JsonLib.inf +++ b/RedfishPkg/Library/JsonLib/JsonLib.inf @@ -15,6 +15,7 @@ MODULE_TYPE =3D DXE_DRIVER VERSION_STRING =3D 1.0 LIBRARY_CLASS =3D JsonLib|DXE_DRIVER UEFI_APPLICATION U= EFI_DRIVER + CONSTRUCTOR =3D JsonLibConstructor =20 # # VALID_ARCHITECTURES =3D IA32 X64 ARM AARCH64 RISCV64 diff --git a/RedfishPkg/Library/JsonLib/JsonLib.c b/RedfishPkg/Library/Json= Lib/JsonLib.c index 9b758b940293..a7ec2ab217a6 100644 --- a/RedfishPkg/Library/JsonLib/JsonLib.c +++ b/RedfishPkg/Library/JsonLib/JsonLib.c @@ -19,6 +19,8 @@ =20 #include "jansson.h" =20 +extern volatile UINT32 hashtable_seed; + /** The function is used to initialize a JSON value which contains a new JSO= N array, or NULL on error. Initially, the array is empty. @@ -1138,3 +1140,35 @@ JsonGetType ( { return (EDKII_JSON_TYPE)(((json_t *)JsonValue)->type); } + +/** + JSON Library constructor. + + @param ImageHandle The image handle. + @param SystemTable The system table. + + @retval EFI_SUCCESS Protocol listener is registered successfully. + +**/ +EFI_STATUS +EFIAPI +JsonLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + // + // hashtable_seed is initalized by current time while JsonLib is loaded. + // Due to above mechanism, hashtable_seed will be different in each indi= vidual + // UEFI driver. As the result, the hash of same key in different UEFI dr= iver + // would be different. This breaks JsonObjectGetValue() because + // JsonObjectGetValue() won't be able to find corresponding JSON value i= f + // this EDKII_JSON_VALUE is created by another UEFI driver. + // + // Initial the seed to a fixed magic value for JsonLib to be working in = all + // UEFI drivers. + // + hashtable_seed =3D 0xFDAE2143; + + return EFI_SUCCESS; +} --=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 (#108777): https://edk2.groups.io/g/devel/message/108777 Mute This Topic: https://groups.io/mt/101432663/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-