From 8afbf87460396a13e025cdd2203978d137a14a74 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 31 Oct 2013 10:56:53 -0600 Subject: [PATCH] Fix bad asm constrants for x86-64 cpuid() 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 --- arch/arch-x86_64.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arch-x86_64.h b/arch/arch-x86_64.h index d7ea12e0..61ac75ee 100644 --- a/arch/arch-x86_64.h +++ b/arch/arch-x86_64.h @@ -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"); } -- 2.25.1