summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaszlo Ersek <lersek@redhat.com>2016-11-30 20:19:06 +0100
committerLaszlo Ersek <lersek@redhat.com>2017-01-03 12:23:38 +0100
commit387ccad8f6f3acbae80bbeb816c944dec672aa66 (patch)
tree450017276a8c1c7572c07c77697285307902835e
parent63042a718887693a07e6575fc8c8f58cdd0933cc (diff)
downloadedk2-platforms-387ccad8f6f3acbae80bbeb816c944dec672aa66.tar.xz
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>
-rw-r--r--MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveState.c8
-rw-r--r--MdeModulePkg/Universal/Acpi/SmmS3SaveState/SmmS3SaveState.c8
2 files changed, 8 insertions, 8 deletions
diff --git a/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveState.c b/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveState.c
index 32263c96c5..efc0ef9140 100644
--- a/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveState.c
+++ b/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveState.c
@@ -343,15 +343,15 @@ BootScriptWriteMemPoll (
UINT64 Address;
VOID *Data;
VOID *DataMask;
- UINTN Delay;
- UINTN LoopTimes;
+ UINT64 Delay;
+ UINT64 LoopTimes;
UINT32 Remainder;
Width = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH);
Address = VA_ARG (Marker, UINT64);
Data = VA_ARG (Marker, VOID *);
DataMask = VA_ARG (Marker, VOID *);
- Delay = (UINTN)VA_ARG (Marker, UINT64);
+ Delay = VA_ARG (Marker, UINT64);
//
// According to the spec, the interval between 2 polls is 100ns,
// but the unit of Duration for S3BootScriptSaveMemPoll() is microsecond(1000ns).
@@ -359,7 +359,7 @@ BootScriptWriteMemPoll (
// Duration will be minimum 1(microsecond) to be minimum deviation,
// so LoopTimes = Delay / 10.
//
- LoopTimes = (UINTN) DivU64x32Remainder (
+ LoopTimes = DivU64x32Remainder (
Delay,
10,
&Remainder
diff --git a/MdeModulePkg/Universal/Acpi/SmmS3SaveState/SmmS3SaveState.c b/MdeModulePkg/Universal/Acpi/SmmS3SaveState/SmmS3SaveState.c
index 739f19eac4..0d1580dc35 100644
--- a/MdeModulePkg/Universal/Acpi/SmmS3SaveState/SmmS3SaveState.c
+++ b/MdeModulePkg/Universal/Acpi/SmmS3SaveState/SmmS3SaveState.c
@@ -342,15 +342,15 @@ BootScriptWriteMemPoll (
UINT64 Address;
VOID *Data;
VOID *DataMask;
- UINTN Delay;
- UINTN LoopTimes;
+ UINT64 Delay;
+ UINT64 LoopTimes;
UINT32 Remainder;
Width = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH);
Address = VA_ARG (Marker, UINT64);
Data = VA_ARG (Marker, VOID *);
DataMask = VA_ARG (Marker, VOID *);
- Delay = (UINTN)VA_ARG (Marker, UINT64);
+ Delay = VA_ARG (Marker, UINT64);
//
// According to the spec, the interval between 2 polls is 100ns,
// but the unit of Duration for S3BootScriptSaveMemPoll() is microsecond(1000ns).
@@ -358,7 +358,7 @@ BootScriptWriteMemPoll (
// Duration will be minimum 1(microsecond) to be minimum deviation,
// so LoopTimes = Delay / 10.
//
- LoopTimes = (UINTN) DivU64x32Remainder (
+ LoopTimes = DivU64x32Remainder (
Delay,
10,
&Remainder