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 00989740057 for ; Mon, 18 Sep 2023 13:41:37 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=THkYc3W+cRroAhDgFZcYstyH8rZpODIObtXJsTSqh/Y=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:MIME-Version: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=1695044496; v=1; b=pYlbAqS89bNOr8KX9RnkYCNrxfUCIr63AY9h5/Yyi+hMvdGdz8UqWVJPUr2goaryfAZYtQju ywtwm18u67PN8TeTGIxCtoXmkFA7oipqO5b9z0ebUKKABo+kPSdgONm+TOO5nEaB3qFWsm3PUE3 7K17qGFPgsjAMbtOpzYGZIFw= X-Received: by 127.0.0.2 with SMTP id zzgoYY7687511xm50ZKK2Dgx; Mon, 18 Sep 2023 06:41:36 -0700 X-Received: from NAM12-BN8-obe.outbound.protection.outlook.com (NAM12-BN8-obe.outbound.protection.outlook.com [40.107.237.76]) by mx.groups.io with SMTP id smtpd.web11.51588.1695044494821478542 for ; Mon, 18 Sep 2023 06:41:35 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eFc3VijpmmRDgYdVwlNpIm+0rr9pSz8iz11iinPSGQEpoKvFmiB2J3V8XUCZzmx03JmBBqaBVyqKYfkTB4sGOBZ7hVBDEuXsS/HrygSg7v0Ev/A/kaGNRG/9Frfk+S+72rCPtaajmghztTBrLL8vGQ1FWIbMxwDjlZXfufr439A2aeET0mThM67YHSbJTGvuDA4P3DEggycL2GZuPX8VqrSARttdTX426wq4bW/KVyLZFB2Bvj2rcYaLqWny5CX60OziFw40ye2CBTN4R/K6XVWxu9xim5F/YVWPHHF6W/9K9//JpakIBN8cXA3UnxigupEgquI7CV8qUuxCprwtMg== 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=Np8kb88PEFHmD5aN8Wz5OtKu1C5zA1S/SVEYH2z4Ouw=; b=Cw6t3V2ZBCQYJNPsjpvdJp2rYYOzfEc1kSs+PbQo3NRxqHQelWu0KC9Bt0Dq3M2g69KzaVmHsO2c4aaWDhrhLeyYveZbx3xQtSAyl96qRJlV8d0jij3mQqtcZxOgGezh1WU1uUGSC+aT6XoeaEyKAOM1Rzgvl3I2/+1WHyxVhLI+Wle9Pa6VcTxZ6UizJpwDKYLrIlSrihlwNh81RsQBLxyc+X1WfnvqgzCvnMxRpCTmQ9nD18HAYRGU3HrLqp1AAvAqSPU4n5F5t151Ti6xdyFkBsfJWbervyojGO0fqpfG9yH5w1gfWUgYsGvASISCK9giawA6LWSBFVu0Ztv+eQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ami.com; dmarc=pass action=none header.from=ami.com; dkim=pass header.d=ami.com; arc=none X-Received: from BLAPR10MB5185.namprd10.prod.outlook.com (2603:10b6:208:328::16) by PH7PR10MB7693.namprd10.prod.outlook.com (2603:10b6:510:2e5::20) 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:41:31 +0000 X-Received: from BLAPR10MB5185.namprd10.prod.outlook.com ([fe80::dc2c:50e8:b23e:d010]) by BLAPR10MB5185.namprd10.prod.outlook.com ([fe80::dc2c:50e8:b23e:d010%7]) with mapi id 15.20.6792.026; Mon, 18 Sep 2023 13:41:30 +0000 From: "Igor Kulchytskyy via groups.io" To: Nickle Wang , "devel@edk2.groups.io" CC: Abner Chang , Nick Ramirez Subject: Re: [edk2-devel] [PATCH] RedfishPkg/JsonLib: fix JsonObjectGetValue issue Thread-Topic: [EXTERNAL] [PATCH] RedfishPkg/JsonLib: fix JsonObjectGetValue issue Thread-Index: AQHZ6jFHjj/iUZHxa0mPmFXo0d/sgrAglszQ Date: Mon, 18 Sep 2023 13:41:30 +0000 Message-ID: References: <20230918130838.6137-1-nicklew@nvidia.com> In-Reply-To: <20230918130838.6137-1-nicklew@nvidia.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: BLAPR10MB5185:EE_|PH7PR10MB7693:EE_ x-ms-office365-filtering-correlation-id: 7b292fde-2636-4ef8-2ced-08dbb84cf751 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: 320OdhFFr/6/fsMibzRJr67ahAozndPkmd1fyue77iJgIjWWApBCe8gIqJe7LJ17ly/sq+erjuHuZYrvk282nkG29OLrvLCuoiCr7SSNK4oSffzwfwniFHBt2DWaARhWVJ3NOvStMI/116P7ddgCLxxPhHf3Duz9s3G/Ny2SIxaFTA7jcuRZRDvzwdrFCbtC+ct0n+mds9zCoN3HhEnKKEC4e91nIdmh+2clT5zJZVIbdts+rob22wmEUMI1jh8XF2qwUew3cS9/DU0hqpuOk4gRXVfFJWGXW4PUQilGFtBG/JPosza0b4tQ1xUZ+FwMDwqJ89b1vN6rZ8KHvaIE6Fz7LPllLOmQO7SBczT1Kpp8ud9kZUdUWlvHQnRkYPH3dEQ5Kz5qZZDZ4mU7l+nhRVDvgxfvPVl0f9SNr+NNcnOKVqCq4B3OVfuyaSiPfledoEzzfpdFsAf4G++4oaLl8MnB5/1xdC1UyxUKRJx8PLxETA3x1fAd3Lj+kr6FOBtPcSoZSluqGLT3/OC6H52pJDn02JzReJnTy332+3sKanfMp9LazdZYmCP5MSf2x5DmcXT4/k0M1OwVu+xabhOKqG4ZCS/dYeHCWdawVpK/RIkZP4CsxVqT/MMcXWVDOym8 x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?rWEaavgXaaBQYwMlQWpI5koGiQTtLRkiHfF3dzwDuaQ2+SPRu86ShaxD3CH7?= =?us-ascii?Q?sqzMBPJuxsjScdrm3FQQkHJyEWFfs7GB2s6r9uTKsVc4t/jyFuHc8jiAlVij?= =?us-ascii?Q?//DkjUZMBG8HMzf4cxYLDBsalCwlbBV/ex6t2mw8tzN+vB2NOMsPsUXLjmdQ?= =?us-ascii?Q?OMxgssesP9uj2xs5BN/Np0ViyI4rxe0nKY42nWh1wCRbGMhCBy5MwsZGEC6k?= =?us-ascii?Q?CGlxxJmxqA0ZM6ZFfTGkFURniAzZ5WEUHox9uGYpZg5Kirq98HlqiQPycVhz?= =?us-ascii?Q?G+PLmuwYTCLMWkrHMJxGSSgfmN0nuEeBLntJqVb/X9E8DmhRWeN6ZAw5FZ4D?= =?us-ascii?Q?zkjZObsgVZzX4c4Gd+HAL0CNghGKngFYFlBSQlSI55HI9h8VoP0+O+LvNYeg?= =?us-ascii?Q?FaFuniDxIvcGdA2WvkbUUlNsRfG376InwRLAavsv2wzvKq1oFVD8LtMTgSVM?= =?us-ascii?Q?IBjffGCdkOEqR3ZB9bnRPt4N9NwCaJN97N5KZlH1MNVoeHaZJtQLMsBtwvt9?= =?us-ascii?Q?2g+xovE02CmgCfWg85LrBgaZIKIhQzA8iS/+EH64YU4X9tPvf9Bftg0vgM7N?= =?us-ascii?Q?5NLHURqDX6mv/EHPG+CEIEWFh3xY2FSEElbZYYuycw/dPL0qRkS6ky/YRU6Y?= =?us-ascii?Q?OsrjGIp/69qZb092y8PkrrbmqM1J/o78rbsyJw8RaFT+nNoDCTopyUNffytZ?= =?us-ascii?Q?UqeNFhzrBoj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ami.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5185.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7b292fde-2636-4ef8-2ced-08dbb84cf751 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Sep 2023 13:41:30.9314 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 27e97857-e15f-486c-b58e-86c2b3040f93 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Y8WbH1xmgWoVYI9csD/bbP6EohBPANmCjBtfz2cx4EBzln9wfE0I8gsKW4UU8ULu X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB7693 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,igork@ami.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: mj27rN4NaLpWNq49uEsFCW3Tx7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" 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=pYlbAqS8; 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}") Hi Nickle, Does that mean, that json_object_seed function is useless anymore with thos= e changes? And there is no need for other module to call json_object_seed? Thank you, Igor -----Original Message----- From: Nickle Wang Sent: Monday, September 18, 2023 9:09 AM To: devel@edk2.groups.io Cc: Abner Chang ; Igor Kulchytskyy ; Ni= ck Ramirez Subject: [EXTERNAL] [PATCH] RedfishPkg/JsonLib: fix JsonObjectGetValue issu= e **CAUTION: The e-mail below is from an external source. Please exercise cau= tion before opening attachments, clicking links, or following guidance.** 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 # # 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 @@ #include "jansson.h" +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; +} -- 2.17.1 -The information contained in this message may be confidential and propriet= ary to American Megatrends (AMI). This communication is intended to be read= only by the individual or entity to whom it is addressed or by their desig= nee. If the reader of this message is not the intended recipient, you are o= n notice that any distribution of this message, in any form, is strictly pr= ohibited. Please promptly notify the sender by reply e-mail or by telephone= at 770-246-8600, and then delete or destroy all copies of the transmission= . -=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 (#108781): https://edk2.groups.io/g/devel/message/108781 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-