From: Laszlo Ersek <lersek@redhat.com>
To: edk2-devel-01 <edk2-devel@ml01.01.org>
Cc: Feng Tian <feng.tian@intel.com>, Star Zeng <star.zeng@intel.com>
Subject: [PATCH 2/3] MdeModulePkg: S3SaveStateDxe, SmmS3SaveState: save 64-bit LoopTimes
Date: Thu, 1 Dec 2016 18:55:55 +0100 [thread overview]
Message-ID: <20161201175556.2479-3-lersek@redhat.com> (raw)
In-Reply-To: <20161201175556.2479-1-lersek@redhat.com>
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>
---
MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveState.c | 8 ++++----
MdeModulePkg/Universal/Acpi/SmmS3SaveState/SmmS3SaveState.c | 8 ++++----
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveState.c b/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveState.c
index 32263c96c56b..efc0ef914064 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 739f19eac437..0d1580dc35ab 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
--
2.9.2
next prev parent reply other threads:[~2016-12-01 17:56 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-01 17:55 [PATCH 0/3] MdePkg, MdeModulePkg, Vlv2TbltDevicePkg: 64-bit LoopTimes in S3 MEM_POLL Laszlo Ersek
2016-12-01 17:55 ` [PATCH 1/3] MdePkg, MdeModulePkg: S3BootScriptSaveMemPoll(): accept 64-bit LoopTimes Laszlo Ersek
2016-12-01 17:55 ` Laszlo Ersek [this message]
2016-12-01 17:55 ` [PATCH 3/3] Vlv2TbltDevicePkg/BootScriptSaveDxe: save " Laszlo Ersek
2016-12-02 1:53 ` [PATCH 0/3] MdePkg, MdeModulePkg, Vlv2TbltDevicePkg: 64-bit LoopTimes in S3 MEM_POLL Yao, Jiewen
2016-12-02 4:54 ` Zeng, Star
2016-12-02 9:46 ` Laszlo Ersek
2016-12-02 23:56 ` Yao, Jiewen
2016-12-03 18:33 ` Laszlo Ersek
2016-12-09 22:58 ` Yao, Jiewen
2016-12-16 1:00 ` Kinney, Michael D
2017-01-03 11:35 ` Laszlo Ersek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161201175556.2479-3-lersek@redhat.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox