Skip to content

Commit

Permalink
Fix bad asm constrants for x86-64 cpuid()
Browse files Browse the repository at this point in the history
Bruce reports:

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"

Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
axboe committed Oct 31, 2013
1 parent 03a22d9 commit 8afbf87
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion arch/arch-x86_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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)
: "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx)
: "0" (*eax), "2" (*ecx)
: "memory");
}
Expand Down

0 comments on commit 8afbf87

Please sign in to comment.