Skip to contentSkip to conversation

Bug in x86_64 do_cpuid()

DISCUSSION Bruce Cran 2 participants 2 messages Oct 30, 2013 – Oct 31, 2013

lore
Share & tools
lore

Bruce Cran

author
#0 lore raw

It seems there's a bug in the x86_64 version of do_cpuid() that causes fio to segfault when built with clang at lower optimization levels:

static inline void do_cpuid(unsigned int *eax, unsigned int *ebx,
unsigned int *ecx, unsigned int *edx)

{
    asm volatile("cpuid"
        : "=a" (*eax), "=b" (*ebx), "=r" (*ecx), "=d" (*edx)
        : "0" (*eax), "2" (*ecx)
        : "memory");
}

via Tijl Coosemans:

Should be: "=c" (*ecx)

But you can also use the '+' modifier and remove the input operands:

: "+a" (*eax), "=b" (*ebx), "+c" (*ecx), "=d" (*edx) :
: "memory"

Signature · 1 line
Bruce Cran
#1 lore raw
Quoted 14 lines · Bruce Cran

It seems there's a bug in the x86_64 version of do_cpuid() that causes fio to segfault when built with clang at lower optimization levels:

static inline void do_cpuid(unsigned int *eax, unsigned int *ebx,
unsigned int *ecx, unsigned int *edx)

{
    asm volatile("cpuid"
        : "=a" (*eax), "=b" (*ebx), "=r" (*ecx), "=d" (*edx)
        : "0" (*eax), "2" (*ecx)
        : "memory");
}

via Tijl Coosemans:

Quoted 7 lines

Should be: "=c" (*ecx)

But you can also use the '+' modifier and remove the input operands:

: "+a" (*eax), "=b" (*ebx), "+c" (*ecx), "=d" (*edx) :
: "memory"

+a/+c doesn't work, but =c will do the trick.

Signature · 1 line
Jens Axboe