diff options
author | Oliver Smith-Denny <osde@microsoft.com> | 2025-09-26 19:58:53 +0300 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2025-10-23 03:57:59 +0300 |
commit | 34cd1aca46b9d2fec67f3f25c9457fc6179c09ed (patch) | |
tree | 0440e048cce764100409ed5d040e4faf9a82ff3f /BaseTools/Source/Python/msa2inf/ConvertModule.py | |
parent | e67f405713f0cc1e8c4cb266bf9cd11a89ff162f (diff) | |
download | edk2-34cd1aca46b9d2fec67f3f25c9457fc6179c09ed.tar.xz |
UefiCpuPkg: MpInitLib: Fix Task Register Race Condition GP Fault
TR is used to enable a separate safe stack when a stack overflow occurs.
When PEI starts up the APs, TR is non-zero and so each processor has its
own GDT. TR is an offset into the GDT and so points to a different TSS
entry in each AP.
There is a small window in early DXE after MpInitLibInitialize() is
called where:
- TR is non-zero because it has been inherited from the PEI phase
- TR is not restored to 0
- The APs are all switched to using the BSP's GDT
- SaveVolatileRegisters() is called from ApWakeupFunction() before the
APs go to sleep, which saves the non-zero TR value to
CpuMpData->CpuData[].VolatileRegisters.Tr, cause TR to point to the
same TSS entry in the BSP's GDT
- The next time the APs are woken up, RestoreVolatileRegisters() is
called from ApWakeupFunction() which would attempt to load the non-zero
TR value into the actual task register, which creates a race condition
to a #GP fault because loading the task register sets the busy bit in
the TSS descriptor and a #GP fault occurs if the busy bit is already
set when loading the task register.
To avoid this issue, the task register is only loaded if TR is non-zero
and the TSS descriptor is valid and not busy. HW sets the busy bit and
does not clear it. edk2 does not clear the busy bit, so the BSP's TSS
descriptor will be marked busy forever and the APs will not load the
task register until they have their own GDT/TSS set up.
Co-authored-by: Ray Ni <ray.ni@intel.com>
Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
Diffstat (limited to 'BaseTools/Source/Python/msa2inf/ConvertModule.py')
0 files changed, 0 insertions, 0 deletions