/// Variables from SMI Handler\r
///\r
X86_ASSEMBLY_PATCH_LABEL gPatchSmbase;\r
-extern volatile UINT32 gSmiStack;\r
-extern UINT32 gSmiCr3;\r
+X86_ASSEMBLY_PATCH_LABEL gPatchSmiStack;\r
+X86_ASSEMBLY_PATCH_LABEL gPatchSmiCr3;\r
extern volatile UINT8 gcSmiHandlerTemplate[];\r
extern CONST UINT16 gcSmiHandlerSize;\r
\r
)\r
{\r
PROCESSOR_SMM_DESCRIPTOR *Psd;\r
+ UINT32 CpuSmiStack;\r
\r
//\r
// Initialize PROCESSOR_SMM_DESCRIPTOR\r
//\r
// Initialize values in template before copy\r
//\r
- gSmiStack = (UINT32)((UINTN)SmiStack + StackSize - sizeof (UINTN));\r
- gSmiCr3 = Cr3;\r
+ CpuSmiStack = (UINT32)((UINTN)SmiStack + StackSize - sizeof (UINTN));\r
+ PatchInstructionX86 (gPatchSmiStack, CpuSmiStack, 4);\r
+ PatchInstructionX86 (gPatchSmiCr3, Cr3, 4);\r
PatchInstructionX86 (gPatchSmbase, SmBase, 4);\r
gSmiHandlerIdtr.Base = IdtBase;\r
gSmiHandlerIdtr.Limit = (UINT16)(IdtSize - 1);\r
//\r
// Set the value at the top of the CPU stack to the CPU Index\r
//\r
- *(UINTN*)(UINTN)gSmiStack = CpuIndex;\r
+ *(UINTN*)(UINTN)CpuSmiStack = CpuIndex;\r
\r
//\r
// Copy template to CPU specific SMI handler location\r