summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael D Kinney <michael.d.kinney@intel.com>2025-01-22 17:32:30 -0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2025-01-23 04:20:47 +0000
commit81802056c89c4d01cc38479f2fd8a2f88c1b4ea3 (patch)
treecec4d5586630fc05b1ea19f23debaa3ae18539e1
parent54c1460dd0823e548c4bb48caafb8a896c42557b (diff)
downloadedk2-81802056c89c4d01cc38479f2fd8a2f88c1b4ea3.tar.gz
EmulatorPkg: Move magic page to first allocation
The magic page is allocated from a fixed address specified by PcdPeiServicesTablePage. This allocation has been observed to sometimes fail. Move the allocation of this buffer to the very beginning of main() to minimize the change that another allocation is allocated from the PcdPeiServicesTablePage address. Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
-rw-r--r--EmulatorPkg/Win/Host/WinHost.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/EmulatorPkg/Win/Host/WinHost.c b/EmulatorPkg/Win/Host/WinHost.c
index a78ca2acff..9a5201f4d1 100644
--- a/EmulatorPkg/Win/Host/WinHost.c
+++ b/EmulatorPkg/Win/Host/WinHost.c
@@ -453,6 +453,28 @@ Returns:
EMU_THUNK_PPI *SecEmuThunkPpi;
//
+ // If enabled use the magic page to communicate between modules
+ // This replaces the PI PeiServicesTable pointer mechanism that
+ // deos not work in the emulator. It also allows the removal of
+ // writable globals from SEC, PEI_CORE (libraries), PEIMs
+ //
+ EmuMagicPage = (VOID *)(UINTN)(FixedPcdGet64 (PcdPeiServicesTablePage) & MAX_UINTN);
+ if (EmuMagicPage != NULL) {
+ UINT64 Size;
+ Status = WinNtOpenFile (
+ NULL,
+ SIZE_4KB,
+ 0,
+ &EmuMagicPage,
+ &Size
+ );
+ if (EFI_ERROR (Status)) {
+ SecPrint ("ERROR : Could not allocate PeiServicesTablePage @ %p\n\r", EmuMagicPage);
+ return EFI_DEVICE_ERROR;
+ }
+ }
+
+ //
// Enable the privilege so that RTC driver can successfully run SetTime()
//
OpenProcessToken (GetCurrentProcess (), TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY, &Token);
@@ -576,28 +598,6 @@ Returns:
}
//
- // If enabled use the magic page to communicate between modules
- // This replaces the PI PeiServicesTable pointer mechanism that
- // deos not work in the emulator. It also allows the removal of
- // writable globals from SEC, PEI_CORE (libraries), PEIMs
- //
- EmuMagicPage = (VOID *)(UINTN)(FixedPcdGet64 (PcdPeiServicesTablePage) & MAX_UINTN);
- if (EmuMagicPage != NULL) {
- UINT64 Size;
- Status = WinNtOpenFile (
- NULL,
- SIZE_4KB,
- 0,
- &EmuMagicPage,
- &Size
- );
- if (EFI_ERROR (Status)) {
- SecPrint ("ERROR : Could not allocate PeiServicesTablePage @ %p\n\r", EmuMagicPage);
- return EFI_DEVICE_ERROR;
- }
- }
-
- //
// Open All the firmware volumes and remember the info in the gFdInfo global
// Meanwhile, find the SEC Core.
//