From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (NAM04-MW2-obe.outbound.protection.outlook.com [40.107.101.67]) by mx.groups.io with SMTP id smtpd.web10.8411.1646748513269470535 for ; Tue, 08 Mar 2022 06:08:33 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=mAqD30El; 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.101.67, mailfrom: abdullateef.attar@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W8dhki35hQwnEpl4FD/OmV9AZdJLcfrJajlCv3ET+uirDNJqC8f/8a86LSusunlM9LB4X7Yc0kz5i3shuF/jx7C1nJqJHIBDdE5/lzi2a8EUiLzgksoEsgCeobZoJjv/Ak2TklCS4FhjkPkkbvBdoNHBtoMQY8SNyEg9HEEd7exxMrBrwjKJJXCUn21ZshxdJybkD+DjWsc/blkna1EBSII6XkA+PTiicUyzJzXOHyI88WgMFtLRDzFUxB1YhfyfH+PHUD1fVz9iD6zRavbgIgD2SdYhQkvr5YWuX/zwoEOGq1JGYhf0CqTTo/JHvYvwAe/WUYRgbHrn+iIA8JoQVw== 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=rbRtK7QDsRIgSo0o8/zWp6uIDsejMTJM5BjJ7x40+Tg=; b=ky/F1kTjE0UafERIA4QK8eErS2e/6MNU7ox+CYrMnadYS2GIFtSfSv9SosWpuiq0kqhl/1Kzk+xPToszS3xPQfwVn4iz2euumwiOvroQ/PDzDpLx6InE9ndrv9q3rRNR+J5GWcz1QdhlaYaB0S5QCzrVE4AwlaSoXWwkMNYPvDL7kbv/qpLXtugXcylnSExvaoHft9e/nXgulZml1FnvkoN2gv6zEqyZxdSAp95/LlJUry/36xghqOdCYuRc6yJSK0MhLtKd4vkc20RV5Eq4kVRSALTZkFoAfLYzngINffz4X9DXKO9m57RP85K0ESBrQ6/Akncd2WtLHlDyWhI+OA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); 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=rbRtK7QDsRIgSo0o8/zWp6uIDsejMTJM5BjJ7x40+Tg=; b=mAqD30ElFD7ToP8+qDaIG/URH3y2Cmo1v3lOEcnzyy3ldj7J8ePL9BVdCSyT/6ZGmlBxLlcMnAVnSZj/iAggZiw+L80Bak7J/f/QfbmT+gsRYzy7wj5BK/W2xvgc33lmAmMg71Rfaf5U7t4x0K8QhynliSc3o2nog8mWJyCNxvE= Received: from BN6PR11CA0049.namprd11.prod.outlook.com (2603:10b6:404:f7::11) by BN6PR12MB1395.namprd12.prod.outlook.com (2603:10b6:404:1f::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.27; Tue, 8 Mar 2022 14:08:31 +0000 Received: from BN8NAM11FT055.eop-nam11.prod.protection.outlook.com (2603:10b6:404:f7:cafe::60) by BN6PR11CA0049.outlook.office365.com (2603:10b6:404:f7::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14 via Frontend Transport; Tue, 8 Mar 2022 14:08:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT055.mail.protection.outlook.com (10.13.177.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5038.14 via Frontend Transport; Tue, 8 Mar 2022 14:08:30 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Tue, 8 Mar 2022 08:08:28 -0600 Received: from BLR-LAB-SFW01.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.18 via Frontend Transport; Tue, 8 Mar 2022 08:08:27 -0600 From: "Abdul Lateef Attar" To: CC: Liming Gao Subject: [PATCH v1 1/1] BoardModulePkg: Copy device path before processing Date: Tue, 8 Mar 2022 19:38:29 +0530 Message-ID: <20220308140829.14884-2-abdattar@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220308140829.14884-1-abdattar@amd.com> References: <20220308140829.14884-1-abdattar@amd.com> MIME-Version: 1.0 Return-Path: AbdulLateef.Attar@amd.com X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bf6c9009-6f63-4c44-b07c-08da010d2010 X-MS-TrafficTypeDiagnostic: BN6PR12MB1395:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Wdf6YpV2UehzaY4leODIGIEb5/F72geSwavk688B52E1Oai+jUvgSTffm84IR2I/qfWEHqn6ofAv4EEAKwcWWo2T72Z2AN4vG5Vy2YhfHXpfVQGXPAG76dtC9W8bs4eC+zs/eALWIVcCXRdLjVBO74CNZQzBk5P0VPjdvRL9cUmKvUc1XOLenRxMpjhdUvYigZeV4rfqSZsy6wJuWZxad0k8g7Y2th2RtFZAf8DcgL0hxFQZjJD/V32exoeLquMlXw52aifByoXyHj+6FzGk7HMtY/FBxkKcATJ6dV3CnNNu9DffjUs7pMeWkZRcLXj1V8fQQayoZpZbHzYziRVX7CNLojYjrJVmJU5ZAyoMwXu+0oTMhzt4lIiMJOdA9Ptva0ZgtvD1k7jn28JYSoWohaO6XQv5h8mGw+20gUl7zHQI7NjgxVVuINBuvldqj30kYrsQ//wC02vqYqABIQWrPtiQKngVqb+LQoG7yDkoYhUiE0E1TCvg/33Yw8Ww+TsAGQR2Hc/2J+cLShbZs/EDhH9ZgXhFvkF7WbVsDr3+/KCCr+EbC478835pcAU6rFfA6YGi0d1pRLEOtAgOn6MdHv1/r7sHhTqvSqauPNErmrDbbvTV/9mPclRVxId+MHm4Epi9fyPBu9IOaD3nGloXr47vLSUMBM89/+uizGbdOAdpbtej+cRS4HOLOjp/cGO8kmNGkDQfIwfktDqR8jHn6g== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(82310400004)(26005)(2906002)(8936002)(40460700003)(36860700001)(508600001)(1076003)(186003)(83380400001)(426003)(336012)(2616005)(47076005)(7696005)(5660300002)(70206006)(70586007)(36756003)(8676002)(4326008)(6916009)(81166007)(356005)(316002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2022 14:08:30.9888 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bf6c9009-6f63-4c44-b07c-08da010d2010 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT055.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1395 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain 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 exception. Hence making a local copy using DuplicateDevicePath() to avoid the page fault exception. Cc Eric Dong Cc: Liming Gao Signed-off-by: Abdul Lateef Attar --- Platform/Intel/BoardModulePkg/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/BoardBdsHookLib= .c @@ -3,6 +3,7 @@ implementation instance of the BDS hook library=0D =0D Copyright (c) 2019, Intel Corporation. All rights reserved.
=0D + Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.
= =0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D **/=0D @@ -131,7 +132,7 @@ IsTrustedConsole ( =0D switch (ConsoleType) {=0D case ConIn:=0D - TrustedConsoleDevicepath =3D PcdGetPtr (PcdTrustedConsoleInputDevice= Path);=0D + TrustedConsoleDevicepath =3D DuplicateDevicePath (PcdGetPtr (PcdTrus= tedConsoleInputDevicePath));=0D break;=0D case ConOut:=0D //=0D @@ -147,7 +148,7 @@ IsTrustedConsole ( TempDevicePath =3D NextDevicePathNode (TempDevicePath);=0D }=0D =0D - TrustedConsoleDevicepath =3D PcdGetPtr (PcdTrustedConsoleOutputDevic= ePath);=0D + TrustedConsoleDevicepath =3D DuplicateDevicePath (PcdGetPtr (PcdTrus= tedConsoleOutputDevicePath));=0D break;=0D default:=0D ASSERT (FALSE);=0D @@ -171,7 +172,9 @@ IsTrustedConsole ( } while (TempDevicePath !=3D NULL);=0D =0D FreePool (ConsoleDevice);=0D -=0D + if (TrustedConsoleDevicepath !=3D NULL) {=0D + FreePool (TrustedConsoleDevicepath);=0D + }=0D return FALSE;=0D }=0D =0D @@ -624,7 +627,7 @@ ConnectTrustedStorage ( EFI_STATUS Status;=0D EFI_HANDLE DeviceHandle;=0D =0D - TrustedStorageDevicepath =3D PcdGetPtr (PcdTrustedStorageDevicePath);=0D + TrustedStorageDevicepath =3D DuplicateDevicePath (PcdGetPtr (PcdTrustedS= torageDevicePath));=0D DumpDevicePath (L"TrustedStorage", TrustedStorageDevicepath);=0D =0D TempDevicePath =3D TrustedStorageDevicepath;=0D @@ -649,6 +652,9 @@ ConnectTrustedStorage ( =0D FreePool (Instance);=0D } while (TempDevicePath !=3D NULL);=0D + if (TrustedStorageDevicepath !=3D NULL) {=0D + FreePool (TrustedStorageDevicepath);=0D + }=0D }=0D =0D =0D @@ -1031,7 +1037,7 @@ AddConsoleVariable ( EFI_HANDLE GraphicsControllerHandle;=0D EFI_DEVICE_PATH *GopDevicePath;=0D =0D - TempDevicePath =3D ConsoleDevicePath;=0D + TempDevicePath =3D DuplicateDevicePath (ConsoleDevicePath);=0D do {=0D Instance =3D GetNextDevicePathInstance (&TempDevicePath, &Size);=0D if (Instance =3D=3D NULL) {=0D @@ -1074,6 +1080,9 @@ AddConsoleVariable ( =0D FreePool (Instance);=0D } while (TempDevicePath !=3D NULL);=0D + if (TempDevicePath !=3D NULL) {=0D + FreePool (TempDevicePath);=0D + }=0D }=0D =0D =0D --=20 2.25.1