BACKPORT: x86: harden tsc udelay() function
authorAaron Durbin <adurbin@chromium.org>
Wed, 1 May 2013 20:55:14 +0000 (15:55 -0500)
committerChromeBot <chrome-bot@google.com>
Wed, 8 May 2013 18:41:55 +0000 (11:41 -0700)
commit7f20f4cae9ba9f30fb1b917499af8729134e8a9a
treeac05c9cc51f788601e485b8a358a65e9bd20cdc3
parenta8e1aec4b3d221fc741578983c9ced60e92f15dc
BACKPORT: x86: harden tsc udelay() function

Since the TSC udelay() function can be used in SMM that means the
TSC can count up to whatever value. The current loop was not handling
TSC rollover properly. In most cases this should not matter as the TSC
typically starts ticking at value 0, and it would take a very long time
to roll it over. However, it is my understanding that this behavior is
not guaranteed. Theoretically the TSC could start or be be written to
with a large value that would cause the rollover.

BUG=None
BRANCH=None
TEST=Compiled and booted

Change-Id: I0f86672e0951b51c791c63bb1173eb371b347f40
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/50457
Reviewed-by: Stefan Reinauer <reinauer@google.com>
src/cpu/x86/tsc/delay_tsc.c