From: "Abdul Lateef Attar" <abdattar@amd.com>
To: <devel@edk2.groups.io>
Cc: Abdul Lateef Attar <abdattar@amd.com>,
Oram Isaac W <isaac.w.oram@intel.com>,
Eric Dong <eric.dong@intel.com>,
Liming Gao <gaoliming@byosoft.com.cn>
Subject: [PATCH v3 1/2] BoardModulePkg: Copy device path before processing
Date: Wed, 18 Jan 2023 18:34:12 +0530 [thread overview]
Message-ID: <28e03e3b127cc52b2d675732892e207a572d7d53.1674047008.git.abdattar@amd.com> (raw)
In-Reply-To: <cover.1674047008.git.abdattar@amd.com>
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: Oram Isaac W <isaac.w.oram@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Abdul Lateef Attar <abdattar@amd.com>
---
.../Library/BoardBdsHookLib/BoardBdsHookLib.c | 24 +++++++++++++++----
1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.c b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.c
index 0bcee7c9a4ba..e866f70bc336 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
Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+ Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -131,7 +132,7 @@ IsTrustedConsole (
switch (ConsoleType) {
case ConIn:
- TrustedConsoleDevicepath = PcdGetPtr (PcdTrustedConsoleInputDevicePath);
+ TrustedConsoleDevicepath = DuplicateDevicePath (PcdGetPtr (PcdTrustedConsoleInputDevicePath));
break;
case ConOut:
//
@@ -147,7 +148,7 @@ IsTrustedConsole (
TempDevicePath = NextDevicePathNode (TempDevicePath);
}
- TrustedConsoleDevicepath = PcdGetPtr (PcdTrustedConsoleOutputDevicePath);
+ TrustedConsoleDevicepath = DuplicateDevicePath (PcdGetPtr (PcdTrustedConsoleOutputDevicePath));
break;
default:
ASSERT (FALSE);
@@ -164,6 +165,9 @@ IsTrustedConsole (
if (CompareMem (ConsoleDevice, Instance, Size - END_DEVICE_PATH_LENGTH) == 0) {
FreePool (Instance);
FreePool (ConsoleDevice);
+ if (TempDevicePath != NULL) {
+ FreePool (TempDevicePath);
+ }
return TRUE;
}
@@ -171,7 +175,9 @@ IsTrustedConsole (
} while (TempDevicePath != NULL);
FreePool (ConsoleDevice);
-
+ if (TempDevicePath != NULL) {
+ FreePool (TempDevicePath);
+ }
return FALSE;
}
@@ -624,7 +630,7 @@ ConnectTrustedStorage (
EFI_STATUS Status;
EFI_HANDLE DeviceHandle;
- TrustedStorageDevicepath = PcdGetPtr (PcdTrustedStorageDevicePath);
+ TrustedStorageDevicepath = DuplicateDevicePath (PcdGetPtr (PcdTrustedStorageDevicePath));
DumpDevicePath (L"TrustedStorage", TrustedStorageDevicepath);
TempDevicePath = TrustedStorageDevicepath;
@@ -649,6 +655,10 @@ ConnectTrustedStorage (
FreePool (Instance);
} while (TempDevicePath != NULL);
+
+ if (TempDevicePath != NULL) {
+ FreePool (TempDevicePath);
+ }
}
@@ -1031,7 +1041,7 @@ AddConsoleVariable (
EFI_HANDLE GraphicsControllerHandle;
EFI_DEVICE_PATH *GopDevicePath;
- TempDevicePath = ConsoleDevicePath;
+ TempDevicePath = DuplicateDevicePath (ConsoleDevicePath);
do {
Instance = GetNextDevicePathInstance (&TempDevicePath, &Size);
if (Instance == NULL) {
@@ -1074,6 +1084,10 @@ AddConsoleVariable (
FreePool (Instance);
} while (TempDevicePath != NULL);
+
+ if (TempDevicePath != NULL) {
+ FreePool (TempDevicePath);
+ }
}
--
2.25.1
next parent reply other threads:[~2023-01-18 13:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1674047008.git.abdattar@amd.com>
2023-01-18 13:04 ` Abdul Lateef Attar [this message]
2023-01-18 13:04 ` [PATCH v3 2/2] BoardModulePkg: Adds PCD to load UEFI Shell image Abdul Lateef Attar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=28e03e3b127cc52b2d675732892e207a572d7d53.1674047008.git.abdattar@amd.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox