Skip to content

Commit 6f17bd5

Browse files
LiuZhiguang001mergify[bot]
authored andcommitted
UefiCpuPkg/S3: Skip CR3 modification in S3Resume for 64-bit PEI
Previously, when PEI was 32-bit and DXE was 64-bit, S3 resume code had to set or change the CR3 register before executing 64-bit code. However, with both PEI and DXE now may being 64-bit, this modification is unnecessary as PEI already utilizes sufficiently large page tables. Additionally, there is a bug in the current implementation where the changed CR3 during S3 resume could map only below 4G MMIO, which could lead to issues if end of PEI notify attempts to access above 4G. Overall, skipping the CR3 modification in S3Resume when PEI is 64-bit can fix the bug and also avoid unnecessary logic. Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
1 parent da1c6dd commit 6f17bd5

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ S3ResumeExecuteBootScript (
871871
SignalToSmmByCommunication (&gEdkiiS3SmmInitDoneGuid);
872872
}
873873

874-
if ((FeaturePcdGet (PcdDxeIplSwitchToLongMode)) || (sizeof (UINTN) == sizeof (UINT64))) {
874+
if (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) {
875875
AsmWriteCr3 ((UINTN)AcpiS3Context->S3NvsPageTableAddress);
876876
}
877877

@@ -1083,7 +1083,7 @@ S3RestoreConfig2 (
10831083
CpuDeadLoop ();
10841084
}
10851085

1086-
if ((FeaturePcdGet (PcdDxeIplSwitchToLongMode)) || (sizeof (UINTN) == sizeof (UINT64))) {
1086+
if (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) {
10871087
//
10881088
// Need reconstruct page table here, since we do not trust ACPINvs.
10891089
//
@@ -1217,7 +1217,9 @@ S3RestoreConfig2 (
12171217
AsmWriteCr0 (Cr0.UintN);
12181218
}
12191219

1220-
AsmWriteCr3 ((UINTN)SmmS3ResumeState->SmmS3Cr3);
1220+
if (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) {
1221+
AsmWriteCr3 ((UINTN)SmmS3ResumeState->SmmS3Cr3);
1222+
}
12211223

12221224
//
12231225
// Disable interrupt of Debug timer, since IDT table cannot work in long mode.

0 commit comments

Comments
 (0)