* [edk2-platforms PATCH v1 0/1] BoardModulePkg: Copy device path
@ 2022-03-15 4:46 Abdul Lateef Attar
2022-03-15 4:46 ` [edk2-platforms PATCH v1 1/1] BoardModulePkg: Copy device path before processing Abdul Lateef Attar
0 siblings, 1 reply; 2+ messages in thread
From: Abdul Lateef Attar @ 2022-03-15 4:46 UTC (permalink / raw)
To: devel; +Cc: Eric Dong, Liming Gao
(Resending patch with [edk2-platforms] prefix with correct emailid).
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.
REF : https://github.com/abdattar/edk2-platforms/tree/BoardModulePkg
Cc: Eric Dong <eric.dong@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Abdul Lateef Attar (1):
BoardModulePkg: Copy device path before processing
Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* [edk2-platforms PATCH v1 1/1] BoardModulePkg: Copy device path before processing
2022-03-15 4:46 [edk2-platforms PATCH v1 0/1] BoardModulePkg: Copy device path Abdul Lateef Attar
@ 2022-03-15 4:46 ` Abdul Lateef Attar
0 siblings, 0 replies; 2+ messages in thread
From: Abdul Lateef Attar @ 2022-03-15 4:46 UTC (permalink / raw)
To: devel; +Cc: Eric Dong, Liming Gao
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 <eric.dong@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Abdul Lateef Attar <abdattar@amd.com>
---
Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.c b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.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
Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+ Copyright (C) 2022 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);
@@ -171,7 +172,9 @@ IsTrustedConsole (
} while (TempDevicePath != NULL);
FreePool (ConsoleDevice);
-
+ if (TrustedConsoleDevicepath != NULL) {
+ FreePool (TrustedConsoleDevicepath);
+ }
return FALSE;
}
@@ -624,7 +627,7 @@ ConnectTrustedStorage (
EFI_STATUS Status;
EFI_HANDLE DeviceHandle;
- TrustedStorageDevicepath = PcdGetPtr (PcdTrustedStorageDevicePath);
+ TrustedStorageDevicepath = DuplicateDevicePath (PcdGetPtr (PcdTrustedStorageDevicePath));
DumpDevicePath (L"TrustedStorage", TrustedStorageDevicepath);
TempDevicePath = TrustedStorageDevicepath;
@@ -649,6 +652,9 @@ ConnectTrustedStorage (
FreePool (Instance);
} while (TempDevicePath != NULL);
+ if (TrustedStorageDevicepath != NULL) {
+ FreePool (TrustedStorageDevicepath);
+ }
}
@@ -1031,7 +1037,7 @@ AddConsoleVariable (
EFI_HANDLE GraphicsControllerHandle;
EFI_DEVICE_PATH *GopDevicePath;
- TempDevicePath = ConsoleDevicePath;
+ TempDevicePath = DuplicateDevicePath (ConsoleDevicePath);
do {
Instance = GetNextDevicePathInstance (&TempDevicePath, &Size);
if (Instance == NULL) {
@@ -1074,6 +1080,9 @@ AddConsoleVariable (
FreePool (Instance);
} while (TempDevicePath != NULL);
+ if (TempDevicePath != NULL) {
+ FreePool (TempDevicePath);
+ }
}
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-03-15 4:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-15 4:46 [edk2-platforms PATCH v1 0/1] BoardModulePkg: Copy device path Abdul Lateef Attar
2022-03-15 4:46 ` [edk2-platforms PATCH v1 1/1] BoardModulePkg: Copy device path before processing Abdul Lateef Attar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox