Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EmulatorPkg: Move magic page to first allocation #10660

Conversation

mdkinney
Copy link
Member

@mdkinney mdkinney commented Jan 23, 2025

Description

Fixes #10652

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 chance that another allocation is allocated from the PcdPeiServicesTablePage address.

  • Breaking change?
  • Impacts security?
  • Includes tests?

How This Was Tested

The issue was reproduced with a build of EmulatorPkg VS2022 IA32 RELEASE. In order to minimize the time required to boot cycle the EmulatorPkg build, the boot manager front page timeout is set to 0 and the Shell default delay is also set to 0.

build -a IA32 -t VS2022 -p EmulatorPkg\EmulatorPkg.dsc -b RELEASE --pcd gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut=0 --pcd gEfiShellPkgTokenSpaceGuid.PcdShellDefaultDelay=0

A cmd script was then used to boot the EmulatorPkg in a loop and log the results to a file.

@echo off
:loop
WinHost.exe
goto loop

A startup.nsh file is used to automatically reset the EmulatorPkg when the boot to Shell completes

BOOT SUCCESS !!!
reset

Within 10 to 20 boot cycles the allocation of the magic page fails.

With the fix in this PR that moves the allocation of the magic page to very beginning of main() the issue was not reproduced in over 11000 boot cycles of the EmulatorPkg.

Integration Instructions

N/A

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 <[email protected]>
Copy link
Member

@niruiyu niruiyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mike, Thanks for fixing this.
I sometimes met this issue and just cannot boot. Then I have to change the PcdPeiServicesTablePage value to workaround it.

@mdkinney mdkinney requested a review from os-d January 23, 2025 04:12
@niruiyu niruiyu added the push Auto push patch series in PR if all checks pass label Jan 23, 2025
@mergify mergify bot merged commit 8180205 into tianocore:master Jan 23, 2025
127 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
push Auto push patch series in PR if all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: EmulatorPkg Page Allocation Failure
2 participants