]> git.proxmox.com Git - mirror_edk2.git/commit
MdeModulePkg PiDxeS3BootScriptLib: Remove a hidden assumption.
authorStar Zeng <star.zeng@intel.com>
Tue, 15 Sep 2015 07:49:12 +0000 (07:49 +0000)
committerlzeng14 <lzeng14@Edk2>
Tue, 15 Sep 2015 07:49:12 +0000 (07:49 +0000)
commit960f2d533b08b43188d35a4aa32d5a8044a45da4
tree22212f6da5d9ac8a91b141fb6b51123b9fe8b845
parent2c55a81a0a94656d88dbd8ed56b37c5a53f5e20f
MdeModulePkg PiDxeS3BootScriptLib: Remove a hidden assumption.

What to do:
1. Remove a hidden assumption "No SMM driver writes BootScript between
SmmReadyToLock and S3SleepEntryCallback".
 1.1. Use SmmExitBootServices and SmmLegacyBoot notification to record
      AtRuntime flag.
 1.2. Use mBootScriptDataBootTimeGuid LockBox to save boot time boot
      script data to handle potential INSERT boot script at runtime in SMM.
2. Do not depend on OS to help restore ACPINvs data and use
EfiReservedMemoryType instead of EfiACPIMemoryNVS.
 2.1. Use mBootScriptSmmPrivateDataGuid LockBox to save boot script
      SMM private data with BackFromS3 = TRUE at runtime. S3 resume
      will help restore it to tell the Library the system is back
      from S3.

Why to do:
1. The hidden assumption "No SMM driver writes BootScript between
SmmReadyToLock and S3SleepEntryCallback" will cause confusion to
the library's consumer and block the usage of "SMM driver writes
BootScript after SmmReadyToLock". So Remove the assumption.
2. In original code, there might be a corner case that malicious
code patch ACPINvs boot TableLength field same as SMM boot script.
So that it can skip the table restore. The impact is that BootScript
in SMM may be overridden by malicious code.
--------------------
    CopyMem ((VOID*)&TableHeader, (VOID*)mS3BootScriptTablePtr->TableBase, sizeof(EFI_BOOT_SCRIPT_TABLE_HEADER));
    if (mS3BootScriptTablePtr->TableLength + sizeof(EFI_BOOT_SCRIPT_TERMINATE) != TableHeader.TableLength) { // TableLength is in NVS
      ......
      //
      // NOTE: We should NOT use TableHeader.TableLength, because it is already updated to be whole length.
      //
      mS3BootScriptTablePtr->TableLength = (UINT32)(mLockBoxLength - sizeof(EFI_BOOT_SCRIPT_TERMINATE)); ? This line can be skipped.
--------------------
So use EfiReservedMemoryType instead of EfiACPIMemoryNVS as the code
has been updated to not depend on OS to help restore ACPINvs data.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18467 6f19259b-4bc3-4df7-8a09-765794883524
MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf
MdeModulePkg/Library/PiDxeS3BootScriptLib/InternalBootScriptLib.h
MdeModulePkg/MdeModulePkg.dec
MdeModulePkg/MdeModulePkg.uni