diff options
author | Jack Lloyd <[email protected]> | 2017-01-23 07:51:59 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-01-23 07:51:59 -0500 |
commit | e54834f871d1d8073f92e8e60af121842b241015 (patch) | |
tree | 1b2a6dc41af8e5d45b082c7ebaec6fc83a9cdf4e /src | |
parent | aa1950ec80199c65992e63bd2e5898b267ad38d6 (diff) |
If PowerPC clock returns 0, skip it.
Doesn't seem to be a problem with the asm, code works fine on physical
hardware (POWER8) but on qemu (on CI) both instructions return zero
and the test fails.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/utils/os_utils.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/lib/utils/os_utils.cpp b/src/lib/utils/os_utils.cpp index 4dac4f9af..87cbcfd0f 100644 --- a/src/lib/utils/os_utils.cpp +++ b/src/lib/utils/os_utils.cpp @@ -58,10 +58,18 @@ uint64_t get_processor_timestamp() return (static_cast<uint64_t>(rtc_high) << 32) | rtc_low; } -#elif defined(BOTAN_USE_GCC_INLINE_ASM) && defined(BOTAN_TARGET_CPU_IS_PPC_FAMILY) +#elif defined(BOTAN_USE_GCC_INLINE_ASM) && defined(BOTAN_TARGET_ARCH_IS_PPC64) uint32_t rtc_low = 0, rtc_high = 0; asm volatile("mftbu %0; mftb %1" : "=r" (rtc_high), "=r" (rtc_low)); - return (static_cast<uint64_t>(rtc_high) << 32) | rtc_low; + + /* + qemu-ppc seems to not support mftb instr, it always returns zero. + If both time bases are 0, assume broken and return another clock. + */ + if(rtc_high > 0 || rtc_low > 0) + { + return (static_cast<uint64_t>(rtc_high) << 32) | rtc_low; + } #elif defined(BOTAN_USE_GCC_INLINE_ASM) && defined(BOTAN_TARGET_ARCH_IS_ALPHA) uint64_t rtc = 0; |