From 0411a0dce5936438df15b7f32dc92c53d40eaf2d Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Wed, 30 Jul 2014 11:44:31 -0400 Subject: [PATCH] common: Get rid of EBX restoration for x86-64. It is not a PIC register, break out x86-specific PIC support. This would break x86-64 for less forgiving assemblers that (correctly) do not accept pushl/popl. --- regressions/common.h | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/regressions/common.h b/regressions/common.h index 47989a9..f100e89 100644 --- a/regressions/common.h +++ b/regressions/common.h @@ -367,7 +367,7 @@ aff_iterate_core(struct affinity *acb CK_CC_UNUSED, unsigned int *core) CK_CC_INLINE static uint64_t rdtsc(void) { -#if defined(__x86_64__) || defined(__x86__) +#if defined(__x86_64__) uint32_t eax = 0, edx; #if defined(CK_MD_RDTSCP) __asm__ __volatile__("rdtscp" @@ -377,9 +377,32 @@ rdtsc(void) return (((uint64_t)edx << 32) | eax); #else + __asm__ __volatile__("cpuid;" + "rdtsc;" + : "+a" (eax), "=d" (edx) + : + : "%ebx", "%ecx", "memory"); - __asm__ __volatile__("pushl %%ebx;" + __asm__ __volatile__("xorl %%eax, %%eax;" "cpuid;" + : + : + : "%eax", "%ebx", "%ecx", "%edx", "memory"); + + return (((uint64_t)edx << 32) | eax); +#endif /* !CK_MD_RDTSCP */ +#elif defined(__x86__) + uint32_t eax = 0, edx; +#if defined(CK_MD_RDTSCP) + __asm__ __volatile__("rdtscp" + : "+a" (eax), "=d" (edx) + : + : "%ecx", "memory"); + + return (((uint64_t)edx << 32) | eax); +#else + __asm__ __volatile__("pushl %%ebx;" + "cpuid;" "rdtsc;" : "+a" (eax), "=d" (edx) : @@ -387,7 +410,7 @@ rdtsc(void) __asm__ __volatile__("xorl %%eax, %%eax;" "cpuid;" - "popl %%ebx;" + "popl %%ebx;" : : : "%eax", "%ecx", "%edx", "memory");