summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2009-09-21 03:48:30 +0000
committerTavian Barnes <tavianator@gmail.com>2009-09-21 03:48:30 +0000
commit9bfbf7832dd379a4a006d236fbeda27be7e13928 (patch)
treea7311df043b6f92af247efb9619ffe829e1d7c0e
parent5f446ac4c9d98c7819ff836c0666c798f351ae2c (diff)
downloadlibsandglass-9bfbf7832dd379a4a006d236fbeda27be7e13928.tar.xz
Make `cpuid' do the same thing for every sandglass_get_tsc() call.
-rw-r--r--src/x86/tsc-x86.s2
-rw-r--r--src/x86_64/tsc-x86_64.s2
2 files changed, 4 insertions, 0 deletions
diff --git a/src/x86/tsc-x86.s b/src/x86/tsc-x86.s
index 46013bb..09e0e32 100644
--- a/src/x86/tsc-x86.s
+++ b/src/x86/tsc-x86.s
@@ -29,9 +29,11 @@
sandglass_get_tsc:
pushl %ebx /* Callee-save register, clobbered by cpuid */
pushl %esi
+ xorl %eax, %eax /* Make cpuid do a consistent operation */
cpuid /* Serialize */
rdtsc /* Read time stamp counter */
movl %eax, %esi /* Store tsc */
+ xorl %eax, %eax
cpuid /* Serialize again */
movl %esi, %eax
popl %esi
diff --git a/src/x86_64/tsc-x86_64.s b/src/x86_64/tsc-x86_64.s
index 52f02c2..e710891 100644
--- a/src/x86_64/tsc-x86_64.s
+++ b/src/x86_64/tsc-x86_64.s
@@ -28,11 +28,13 @@
.type sandglass_get_tsc, @function
sandglass_get_tsc:
movq %rbx, %rdi /* Callee-save register, clobbered by cpuid */
+ xorl %eax, %eax /* Make cpuid do a consistent operation */
cpuid /* Serialize */
rdtsc /* Read time stamp counter */
shlq $32, %rdx
orq %rdx, %rax
movq %rax, %rsi
+ xorl %eax, %eax
cpuid /* Serialize again */
movq %rsi, %rax
movq %rdi, %rbx