[PATCH v2 1/3] x86/hash: fix build failure with older binutils

From: Jan Beulich
Date: Thu Feb 27 2014 - 03:47:01 EST


Just like for other ISA extension instruction uses we should check
whether the assembler actually supports them. The fallback here simply
is to encode an instruction with fixed operands (%eax and %ecx).

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Cc: Francesco Fusco <ffusco@xxxxxxxxxx>
Cc: Daniel Borkmann <dborkman@xxxxxxxxxx>
Cc: Thomas Graf <tgraf@xxxxxxxxxx>
Cc: David S. Miller <davem@xxxxxxxxxxxxx>
---
arch/x86/Makefile | 1 +
arch/x86/lib/hash.c | 4 ++++
2 files changed, 5 insertions(+)

--- 3.14-rc4-x86-hash-crc32.orig/arch/x86/Makefile
+++ 3.14-rc4-x86-hash-crc32/arch/x86/Makefile
@@ -152,6 +152,7 @@ cfi-sections := $(call as-instr,.cfi_sec

# does binutils support specific instructions?
asinstr := $(call as-instr,fxsaveq (%rax),-DCONFIG_AS_FXSAVEQ=1)
+asinstr += $(call as-instr,crc32l %eax$(comma)%eax,-DCONFIG_AS_CRC32=1)
avx_instr := $(call as-instr,vxorps %ymm0$(comma)%ymm1$(comma)%ymm2,-DCONFIG_AS_AVX=1)
avx2_instr :=$(call as-instr,vpbroadcastb %xmm0$(comma)%ymm1,-DCONFIG_AS_AVX2=1)

--- 3.14-rc4-x86-hash-crc32.orig/arch/x86/lib/hash.c
+++ 3.14-rc4-x86-hash-crc32/arch/x86/lib/hash.c
@@ -39,7 +39,11 @@

static inline u32 crc32_u32(u32 crc, u32 val)
{
+#ifdef CONFIG_AS_CRC32
asm ("crc32l %1,%0\n" : "+r" (crc) : "rm" (val));
+#else
+ asm (".byte 0xf2, 0x0f, 0x38, 0xf1, 0xc1" : "+a" (crc) : "c" (val));
+#endif
return crc;
}




--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/