]> git.proxmox.com Git - mirror_edk2.git/commit
MdeModulePkg: S3SaveStateDxe, SmmS3SaveState: save 64-bit LoopTimes
authorLaszlo Ersek <lersek@redhat.com>
Wed, 30 Nov 2016 19:19:06 +0000 (20:19 +0100)
committerLaszlo Ersek <lersek@redhat.com>
Tue, 3 Jan 2017 11:23:38 +0000 (12:23 +0100)
commit387ccad8f6f3acbae80bbeb816c944dec672aa66
tree450017276a8c1c7572c07c77697285307902835e
parent63042a718887693a07e6575fc8c8f58cdd0933cc
MdeModulePkg: S3SaveStateDxe, SmmS3SaveState: save 64-bit LoopTimes

The BootScriptWriteMemPoll() helper function in both drivers does the
following:

- pop Delay from the variable argument list as UINT64, then truncate it to
  UINTN,

- divide Delay by 10, using DivU64x32Remainder(), then store the quotient
  in LoopTimes (also UINTN),

- pass LoopTimes to S3BootScriptSaveMemPoll() as last argument.

The truncation to UINTN is superfluous and wrong in this logic (not to
mention incompatible with the PI spec); it prevents callers from
specifying Delays longer than 0xFFFF_FFFF * 100ns (approximately 429
seconds == 7 minutes 9 seconds) on Ia32. In particular it prevents callers
from specifying an infinite timeout (for example, 0xFFFF_FFFF_FFFF_FFFF *
100ns, approximately 58494 years).

Change the type of Delay and LoopTimes to UINT64. Keep the same logic,
just remove the truncations. The resultant LoopTimes values can be safely
passed to S3BootScriptSaveMemPoll() thanks to the previous patch.

Cc: Feng Tian <feng.tian@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: "Yao, Jiewen" <jiewen.yao@intel.com>
Reviewed-by: Michael Kinney <michael.d.kinney@intel.com>
MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveState.c
MdeModulePkg/Universal/Acpi/SmmS3SaveState/SmmS3SaveState.c