Fix bad asm constrants for x86-64 cpuid()
authorJens Axboe <axboe@kernel.dk>
Thu, 31 Oct 2013 16:56:53 +0000 (10:56 -0600)
committerJens Axboe <axboe@kernel.dk>
Thu, 31 Oct 2013 16:56:53 +0000 (10:56 -0600)
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 <axboe@kernel.dk>
arch/arch-x86_64.h

index d7ea12e0d0723d6e8c8d9d9671cc3ab151d5645b..61ac75eefef97a64423cecbef4eff32c2b7199ff 100644 (file)
@@ -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");
 }