> Date: Tue, 15 Mar 2011 14:22:16 +0100
> From: Aleksander Piotrowski <[email protected]>
> 
> hi mark
> 
> i have signal 4, Illegal instruction crash on sparc64 with security/botan
> (required by newer devel/monotone).  it looks like they are trying to get time
> from hardware timer using some funny asm's.  sparc64 and asm are rocket 
> science for me,
> that's why i'm asking for your help :-)
> 
> here goes method body that, according to gdb, is our culprit.  and the exact 
> line is
> 
>       asm volatile("rd %%tick, %0" : "=r" (rtc));
> 
> is this enough info or shall i provide you with more context?
> thanks in advance,

Hi Alek,

On OpenBSD we disable access to %tick from userland.  I think the idea
is to make it harder for people to perform timing attacks, and
therefore improve security.  But I don't consider myself enough of a
security expert to be able to judge wethere that really helps.  So I
CC'ed tech@ in the hope that a more knowledgable person will chime in.

Cheers,

Mark

> /*
> * Get the timestamp
> */
> u64bit Hardware_Timer::clock() const
>    {
>    u64bit rtc = 0;
> 
> #if defined(BOTAN_TARGET_ARCH_IS_IA32) || defined(BOTAN_TARGET_ARCH_IS_AMD64)
>    u32bit rtc_low = 0, rtc_high = 0;
>    asm volatile("rdtsc" : "=d" (rtc_high), "=a" (rtc_low));
>    rtc = (static_cast<u64bit>(rtc_high) << 32) | rtc_low;
> 
> #elif defined(BOTAN_TARGET_ARCH_IS_PPC) || defined(BOTAN_TARGET_ARCH_IS_PPC64)
>    u32bit rtc_low = 0, rtc_high = 0;
>    asm volatile("mftbu %0; mftb %1" : "=r" (rtc_high), "=r" (rtc_low));
>    rtc = (static_cast<u64bit>(rtc_high) << 32) | rtc_low;
> 
> #elif defined(BOTAN_TARGET_ARCH_IS_ALPHA)
>    asm volatile("rpcc %0" : "=r" (rtc));
> 
> #elif defined(BOTAN_TARGET_ARCH_IS_SPARC64)
>    asm volatile("rd %%tick, %0" : "=r" (rtc));
> 
> #elif defined(BOTAN_TARGET_ARCH_IS_IA64)
>    asm volatile("mov %0=ar.itc" : "=r" (rtc));
> 
> #elif defined(BOTAN_TARGET_ARCH_IS_S390X)
>    asm volatile("stck 0(%0)" : : "a" (&rtc) : "memory", "cc");
> 
> #elif defined(BOTAN_TARGET_ARCH_IS_HPPA)
>    asm volatile("mfctl 16,%0" : "=r" (rtc)); // 64-bit only?
> 
> #else
>    #error "Unsure how to access hardware timer on this system"
> #endif
> 
>    return rtc;
>    }

Reply via email to