From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (NAM12-BN8-obe.outbound.protection.outlook.com [40.107.237.81]) by mx.groups.io with SMTP id smtpd.web11.11616.1674034740958749574 for ; Wed, 18 Jan 2023 01:39:01 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=u77qZ16J; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.237.81, mailfrom: abdullateef.attar@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lK3Lo2180NyB8JZMPo0dDjXgcPeVoV+bDDX8Izg/vW8erdIeCILk5AK6iBFZwbBJXn9/K10IuH+xSd1jmK8suEu6DcimIeuKNE4nisjg/lC2/FD5Ef5j4jmFoyi1JeqweHgkTeJq1SZLklcruMYxV2f+j2dHFBo4LiovUXJ3fNz6vfYJtVgYjwD50XuDUnTh3R8GnGWEC9upoL/uFs9C4HiXHNXeC2lIy/rDop8jxKlgbe5OnwRRxCWOt9r0JCjst9Zwc35V0fQKZAagUf/f2soYu2Hh4SU4W3E+AarFygVZAkZThHBUF6YDkewolxnU18V5hFVNCG6egUScx0NClw== 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=OitpRIzsYsgk7OuelIgaHEFjAxLFHZOvArS/QE5FVFo=; b=XERjiL3XHB3gdXTHXi4zSDnzyrK6XwPZ6HkQePcLKySjehs6rsEvUquTl0qG039sN2dT4rcUuXGHMF+iwf+zDy0h0yCuMjdMQPcoYmHLTM8L64FRcNx5M+a4RsRbRBcoMkPmlLT+UhIcBrJ63S2g1jzw9RqlO9UYB99oq8GXG/TFUL/i8ebO/0cVrGmrTGPR/c2bHEdWpy5VqKuoLfzgHLLTa7uK6LpiB1wKZuTjMJDI1acHQWQMmkEHUdQJ6J/T1knWeWKzR+KTe/PxPgTSOahg5q08/5/ms4clkBAlJktTtlIU1m5DYZLIZdrWRhQeviQbuxcGp7xy6WZp14U5/w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OitpRIzsYsgk7OuelIgaHEFjAxLFHZOvArS/QE5FVFo=; b=u77qZ16JghcZ9j5JRLZ7FvxRzYPaZYvTPG1dxTpi/soNl22ImMvTO2yirAD4AyMjKfrUoripn2aTMUqKrArUtzRtBVWOjLIySngKCfBXLVFLexp1OT30Pppjy4qJn/uEuVmeHLxhvMtCiSANz6ZOYF+rN9fFQdb2ji8FLplGT9E= Received: from IA1PR12MB6458.namprd12.prod.outlook.com (2603:10b6:208:3aa::22) by PH8PR12MB7448.namprd12.prod.outlook.com (2603:10b6:510:214::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.24; Wed, 18 Jan 2023 09:38:58 +0000 Received: from IA1PR12MB6458.namprd12.prod.outlook.com ([fe80::54:ad09:aa9e:b2fa]) by IA1PR12MB6458.namprd12.prod.outlook.com ([fe80::54:ad09:aa9e:b2fa%6]) with mapi id 15.20.5986.023; Wed, 18 Jan 2023 09:38:58 +0000 From: "Attar, AbdulLateef (Abdul Lateef)" To: "Oram, Isaac W" , "devel@edk2.groups.io" CC: "Dong, Eric" , "Gao, Liming" Subject: Re: [edk2-devel] [PATCH 1/2] BoardModulePkg: Copy device path before processing Thread-Topic: [edk2-devel] [PATCH 1/2] BoardModulePkg: Copy device path before processing Thread-Index: AQHY+Qy1TBPZ7DVAjESPbdBPlC82o66jcz4AgADbLSA= Date: Wed, 18 Jan 2023 09:38:58 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ActionId=c4124342-7182-4c89-98e8-65cfa6b51602;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ContentBits=0;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Enabled=true;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Method=Standard;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Name=General;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SetDate=2023-01-18T09:35:54Z;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: IA1PR12MB6458:EE_|PH8PR12MB7448:EE_ x-ms-office365-filtering-correlation-id: 2f2db397-f40e-49bd-efda-08daf937d2c8 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 848K1gIg9vkPw/NZr/gMEV5NATH4X8VspXsqLrYRjAzgrQUrwTLUi5HPDP8maj7kbNscRrxg5mcxkt3vT6yDZGs6gV0oBqOk83GnqpAldR4w97VMXqTi3AHklNncdFTHSQnPHsecfrzd7NCxXs7RsSNAv6OekHKfL5pMuVnIzCVzf5isUeo7pk4t21DZ3jo+DYsGUEapX6RbOBNxOv+/Pf01xj7Cbh4C3j3Uh3DrTcwGKT5OiQ8NBWoIwEPgPrgDE7fByJnOOv8uyFFoBRNIOHF3zGURLDyelGTPjgtWNRcCJdfnnYCZ6eRaW66impXcbjrRYNKhDgF2dQTSbxSkCGF9RdG+ncr+UF6vTm8YnqTsqNMEvGMz/IQPa5j1lg9h3VMFI3P9I+CMwmyGlyecTmBECUDD8xrjlzHX9ZF8NAe0Acw5NKwIp0g+G0bp1i3myCWM6cu88aRG5HVbo2/YuR4W8XO+Vu2t9nLToMZaXWASI6IdLt5gWM/XKXLHXBN2J2PY8zJsP1wbTUBt/x349IK4O+5H5ORIP1897rg552CJp7P5asjHmEt41VK/hJJSUcMvnHHWv1g+hVVd61KRciDzKZvo6Q01xQddu8JR+kcVLZuhm+K/ZKzIW90ALYkOp6gjFZCTI5nKpsIymqpEg4gJntpOLBgt5BBYFnt6j5v1/vWvCKgoX/xnjtNsX7hjD57sZ+hEIRoAd8dAq/RE+CO5SfIeQamOjnYjF0Pt9UlzQsGIWd3FTYewPZmNaZJ2N5SOCmw9HrybbD5HXLAXqA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:IA1PR12MB6458.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(376002)(136003)(346002)(396003)(366004)(451199015)(66899015)(38070700005)(33656002)(86362001)(66476007)(2906002)(52536014)(66556008)(55016003)(76116006)(66946007)(5660300002)(8936002)(122000001)(38100700002)(316002)(71200400001)(7696005)(54906003)(110136005)(53546011)(6506007)(966005)(478600001)(41300700001)(8676002)(66446008)(64756008)(4326008)(186003)(9686003)(83380400001)(26005);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?lyLvYC1wR1SwFpXSf/wbRx+V9Ye3wxMK1OKGYu0WwcBjz+4V3zMLAxYetPXQ?= =?us-ascii?Q?glLEW6a4H4a9WXXp38IbvwQ+KuywewHan+8PCu3FdgalQTk0nqVzb3gnvc/m?= =?us-ascii?Q?R2NwGAqYSnhlSFbl7GNIXXs934EoZxUYCB9JwTCESO47wWkup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ge2IArBKuXUba8Ak1SwqLNEXQWB72j6FpLQSH8QG0BVWPsm?= =?us-ascii?Q?TlXGVRV1j5IVnAOsg1+b/Ms3Ji5z6DQG1W2NXsxIiLKRGk9Zy3+cFS0cHNo0?= =?us-ascii?Q?47VgySj8Cqvca8zU4D0YPzvCvVIACfMX+9/oQ+IKd0m8B3DPCG3jJQr1K8nQ?= =?us-ascii?Q?tiUlrc/NlO6Z7VEDkA1/IsPI7aou80o6ji+QMlNPEpI0K6EdpG71SGVK6Bap?= =?us-ascii?Q?hAUwK2sSMXgeqczZh/UGzu17tTW2GQBUqMxmd/BVYVhJxUJRaMZ5dNMLlilQ?= =?us-ascii?Q?kr81Y3tolCfTyjFcxrWDNUiGBJwUCbB9UclndRjWYvkBfDdzg3+VWzYedhgd?= =?us-ascii?Q?xNkjd5Kury1/7GwvxTbKGjuMwtNsRp0lCZ5f2ZEgCE1I+Q27so/oTc99igCq?= =?us-ascii?Q?hhmFUgpwCC1N7yUEU6KSWbz19OA6uVrvCroa5En0T+q01V08OekqXBn+hjEe?= =?us-ascii?Q?roYt5PoxZPbXgqrBtxQfdz3z7U5brx21nLSodxMGcb01uD9OwB6vty8TVNOK?= =?us-ascii?Q?tzLDmi/ceDpZ1TuMwtYvj3aL0BenGDO1Zw9RMO8q?= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: IA1PR12MB6458.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2f2db397-f40e-49bd-efda-08daf937d2c8 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Jan 2023 09:38:58.0935 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Uui7TxbiKvIPGuaxQsyRB0BPNLo6nBNiTLzvka1upk60X/2RGhj2ntbcHHDwXfYep6PaIANZzBwpV0GsgH7hAQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7448 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable [AMD Official Use Only - General] Hi Isaac, Please see inline for my reply. [Abdul] Thanks AbduL -----Original Message----- From: Oram, Isaac W Sent: 18 January 2023 02:01 To: devel@edk2.groups.io; Attar, AbdulLateef (Abdul Lateef) Cc: Dong, Eric ; Gao, Liming Subject: RE: [edk2-devel] [PATCH 1/2] BoardModulePkg: Copy device path befo= re processing Caution: This message originated from an External Source. Use proper cautio= n when opening attachments, clicking links, or responding. Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.c Line 168: Don't we need to free buffer on this path? [Abdul] we are freeing all allocated buffers here before returning. Lines 655, 1083: Please put a newline between while and the block to free = resources. [Abdul] will make the changes in V3 patch. Regards, Isaac -----Original Message----- From: devel@edk2.groups.io On Behalf Of Abdul Lateef= Attar via groups.io Sent: Tuesday, November 15, 2022 4:04 AM To: devel@edk2.groups.io Cc: Dong, Eric ; Gao, Liming Subject: [edk2-devel] [PATCH 1/2] BoardModulePkg: Copy device path before p= rocessing From: Abdul Lateef Attar GCC compiler puts the DevicePath PCDs to the read-only section. During boot= if try to process the device path after PtrGetPtr it throws a page fault e= xception. Hence making a local copy using DuplicateDevicePath() to avoid the page fau= lt exception. Cc: Eric Dong Cc: Liming Gao Signed-off-by: Abdul Lateef Attar --- .../Library/BoardBdsHookLib/BoardBdsHookLib.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBds= HookLib.c b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsH= ookLib.c index 0bcee7c9a4ba..8700118d255a 100644 --- a/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib= .c +++ b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook +++ Lib.c @@ -3,6 +3,7 @@ implementation instance of the BDS hook library Copyright (c) 2019, Intel Corporation. All rights reserved.
+ Copyright (C) 2022 Advanced Micro Devices, Inc. All rights + reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -131,7 +132,7 @@ IsTrustedConsole ( switch (ConsoleType) { case ConIn: - TrustedConsoleDevicepath =3D PcdGetPtr (PcdTrustedConsoleInputDevice= Path); + TrustedConsoleDevicepath =3D DuplicateDevicePath (PcdGetPtr + (PcdTrustedConsoleInputDevicePath)); break; case ConOut: // @@ -147,7 +148,7 @@ IsTrustedConsole ( TempDevicePath =3D NextDevicePathNode (TempDevicePath); } - TrustedConsoleDevicepath =3D PcdGetPtr (PcdTrustedConsoleOutputDevic= ePath); + TrustedConsoleDevicepath =3D DuplicateDevicePath (PcdGetPtr + (PcdTrustedConsoleOutputDevicePath)); break; default: ASSERT (FALSE); @@ -171,7 +172,9 @@ IsTrustedConsole ( } while (TempDevicePath !=3D NULL); FreePool (ConsoleDevice); - + if (TrustedConsoleDevicepath !=3D NULL) { + FreePool (TrustedConsoleDevicepath); + } return FALSE; } @@ -624,7 +627,7 @@ ConnectTrustedStorage ( EFI_STATUS Status; EFI_HANDLE DeviceHandle; - TrustedStorageDevicepath =3D PcdGetPtr (PcdTrustedStorageDevicePath); + TrustedStorageDevicepath =3D DuplicateDevicePath (PcdGetPtr + (PcdTrustedStorageDevicePath)); DumpDevicePath (L"TrustedStorage", TrustedStorageDevicepath); TempDevicePath =3D TrustedStorageDevicepath; @@ -649,6 +652,9 @@ ConnectTrustedStorage ( FreePool (Instance); } while (TempDevicePath !=3D NULL); + if (TrustedStorageDevicepath !=3D NULL) { + FreePool (TrustedStorageDevicepath); + } } @@ -1031,7 +1037,7 @@ AddConsoleVariable ( EFI_HANDLE GraphicsControllerHandle; EFI_DEVICE_PATH *GopDevicePath; - TempDevicePath =3D ConsoleDevicePath; + TempDevicePath =3D DuplicateDevicePath (ConsoleDevicePath); do { Instance =3D GetNextDevicePathInstance (&TempDevicePath, &Size); if (Instance =3D=3D NULL) { @@ -1074,6 +1080,9 @@ AddConsoleVariable ( FreePool (Instance); } while (TempDevicePath !=3D NULL); + if (TempDevicePath !=3D NULL) { + FreePool (TempDevicePath); + } } -- 2.25.1