summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Martin <olivier.martin@arm.com>2014-11-11 00:52:46 +0000
committeroliviermartin <oliviermartin@Edk2>2014-11-11 00:52:46 +0000
commit4a2928934b37e798a15ecc8546b8432057d090bf (patch)
tree4f75680e6237af289c9d2945f25d90672b6f6207
parent284fb5c811fb7784ee3afa753dbdf5b389c4cdce (diff)
downloadedk2-platforms-4a2928934b37e798a15ecc8546b8432057d090bf.tar.xz
ArmPkg/ArmArchTimerLib: Promotes 32bit value to prevent overflow
Both MicroSeconds and PcdArmArchTimerFreqInHz are 32-bit values on AArch32 so their multiplication produces 32-bit result that might cause wrong calculation. Example: With MicroSeconds = 200 us, PcdArmArchTimerFreqInHz = 24MHz. 200*24000000 = 0x1_1E1A_3000 => So 0x1E1A_3000 when the type is UINT32. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Olivier Martin <olivier.martin@arm.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16329 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c b/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c
index 5d8e006cc9..c0ab4a4433 100644
--- a/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c
+++ b/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c
@@ -85,7 +85,7 @@ MicroSecondDelay (
// Calculate counter ticks that can represent requested delay:
// = MicroSeconds x TICKS_PER_MICRO_SEC
// = MicroSeconds x Frequency.10^-6
- TimerTicks64 = (MicroSeconds * PcdGet32 (PcdArmArchTimerFreqInHz)) / 1000000U;
+ TimerTicks64 = ((UINT64)MicroSeconds * PcdGet32 (PcdArmArchTimerFreqInHz)) / 1000000U;
// Read System Counter value
SystemCounterVal = ArmGenericTimerGetSystemCount ();