summaryrefslogtreecommitdiff
path: root/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
diff options
context:
space:
mode:
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2012-08-22 08:56:50 +0000
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2012-08-22 08:56:50 +0000
commitabef469fc1969f1142bf8add4275d573b4793e94 (patch)
treec09371f26bb301961ca3c752640fdf5053f2bc73 /UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
parent8d4e1bd933f22a5e9223dc9923367f6f49b03b00 (diff)
downloadedk2-platforms-abef469fc1969f1142bf8add4275d573b4793e94.tar.xz
Set correct DS/ES/FS/GS/SS segment selectors after GDT loaded.
Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Rui Sun <rui.sun@intel.com> git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13667 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c')
-rw-r--r--UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
index 07d83cc875..ad81c19590 100644
--- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
+++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
@@ -193,6 +193,18 @@ S3RestoreConfig2 (
IN EFI_PEI_S3_RESUME2_PPI *This
);
+/**
+ Set data segment selectors value including DS/ES/FS/GS/SS.
+
+ @param[in] SelectorValue Segment selector value to be set.
+
+**/
+VOID
+EFIAPI
+AsmSetDataSelectors (
+ IN UINT16 SelectorValue
+ );
+
//
// Globals
//
@@ -232,6 +244,8 @@ GLOBAL_REMOVE_IF_UNREFERENCED IA32_GDT mGdtEntries[] = {
/* 0x40 */ {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
};
+#define DATA_SEGEMENT_SELECTOR 0x18
+
//
// IA32 Gdt register
//
@@ -701,6 +715,7 @@ S3ResumeExecuteBootScript (
IA32_DESCRIPTOR *IdtDescriptor;
VOID *IdtBuffer;
PEI_S3_RESUME_STATE *PeiS3ResumeState;
+ BOOLEAN InterruptStatus;
DEBUG ((EFI_D_ERROR, "S3ResumeExecuteBootScript()\n"));
@@ -769,10 +784,19 @@ S3ResumeExecuteBootScript (
*(UINTN*)(IdtDescriptor->Base - sizeof(UINTN)) = (UINTN)GetPeiServicesTablePointer ();
}
+ InterruptStatus = SaveAndDisableInterrupts ();
//
// Need to make sure the GDT is loaded with values that support long mode and real mode.
//
AsmWriteGdtr (&mGdt);
+ //
+ // update segment selectors per the new GDT.
+ //
+ AsmSetDataSelectors (DATA_SEGEMENT_SELECTOR);
+ //
+ // Restore interrupt state.
+ //
+ SetInterruptState (InterruptStatus);
//
// Prepare data for return back
@@ -873,6 +897,7 @@ S3RestoreConfig2 (
SMM_S3_RESUME_STATE *SmmS3ResumeState;
VOID *GuidHob;
BOOLEAN Build4GPageTableOnly;
+ BOOLEAN InterruptStatus;
TempAcpiS3Context = 0;
TempEfiBootScriptExecutorVariable = 0;
@@ -1002,10 +1027,20 @@ S3RestoreConfig2 (
// Switch to long mode to complete resume.
//
+ InterruptStatus = SaveAndDisableInterrupts ();
//
// Need to make sure the GDT is loaded with values that support long mode and real mode.
//
AsmWriteGdtr (&mGdt);
+ //
+ // update segment selectors per the new GDT.
+ //
+ AsmSetDataSelectors (DATA_SEGEMENT_SELECTOR);
+ //
+ // Restore interrupt state.
+ //
+ SetInterruptState (InterruptStatus);
+
AsmWriteCr3 ((UINTN)SmmS3ResumeState->SmmS3Cr3);
AsmEnablePaging64 (
0x38,