X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=UefiCpuPkg%2FPiSmmCpuDxeSmm%2FSmramSaveState.c;h=f0c289254330d3949a0f00dcd3fcc98818c13b9f;hp=b4bc0ec6a53de92c813d01fe7eb1a13b0abfbff9;hb=fc504fdea7fe92bfa88e15f50e64b4d76d4f75fd;hpb=a6b7bc7a87bc7690f7f5fd48cfcd79f14676896e;ds=sidebyside diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c b/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c index b4bc0ec6a5..f0c2892543 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c @@ -1,7 +1,7 @@ /** @file Provides services to access SMRAM Save State Map -Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -105,11 +105,11 @@ typedef struct { /// /// Variables from SMI Handler /// -extern UINT32 gSmbase; -extern volatile UINT32 gSmiStack; -extern UINT32 gSmiCr3; -extern volatile UINT8 gcSmiHandlerTemplate[]; -extern CONST UINT16 gcSmiHandlerSize; +X86_ASSEMBLY_PATCH_LABEL gPatchSmbase; +X86_ASSEMBLY_PATCH_LABEL gPatchSmiStack; +extern UINT32 gSmiCr3; +extern volatile UINT8 gcSmiHandlerTemplate[]; +extern CONST UINT16 gcSmiHandlerSize; // // Variables used by SMI Handler @@ -686,11 +686,12 @@ InstallSmiHandler ( ) { PROCESSOR_SMM_DESCRIPTOR *Psd; + UINT32 CpuSmiStack; // // Initialize PROCESSOR_SMM_DESCRIPTOR // - Psd = (PROCESSOR_SMM_DESCRIPTOR *)(VOID *)(UINTN)(SmBase + SMM_PSD_OFFSET); + Psd = (PROCESSOR_SMM_DESCRIPTOR *)(VOID *)((UINTN)SmBase + SMM_PSD_OFFSET); CopyMem (Psd, &gcPsd, sizeof (gcPsd)); Psd->SmmGdtPtr = (UINT64)GdtBase; Psd->SmmGdtSize = (UINT32)GdtSize; @@ -716,22 +717,23 @@ InstallSmiHandler ( // // Initialize values in template before copy // - gSmiStack = (UINT32)((UINTN)SmiStack + StackSize - sizeof (UINTN)); + CpuSmiStack = (UINT32)((UINTN)SmiStack + StackSize - sizeof (UINTN)); + PatchInstructionX86 (gPatchSmiStack, CpuSmiStack, 4); gSmiCr3 = Cr3; - gSmbase = SmBase; + PatchInstructionX86 (gPatchSmbase, SmBase, 4); gSmiHandlerIdtr.Base = IdtBase; gSmiHandlerIdtr.Limit = (UINT16)(IdtSize - 1); // // Set the value at the top of the CPU stack to the CPU Index // - *(UINTN*)(UINTN)gSmiStack = CpuIndex; + *(UINTN*)(UINTN)CpuSmiStack = CpuIndex; // // Copy template to CPU specific SMI handler location // CopyMem ( - (VOID*)(UINTN)(SmBase + SMM_HANDLER_OFFSET), + (VOID*)((UINTN)SmBase + SMM_HANDLER_OFFSET), (VOID*)gcSmiHandlerTemplate, gcSmiHandlerSize );