aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUros Bizjak <ubizjak@gmail.com>2018-10-14 16:23:54 -0400
committerBorislav Petkov <bp@suse.de>2018-11-05 04:42:32 -0500
commit566b62a3676caed1f8c626e26066ff3ae3a38918 (patch)
treea3fa577164533cb0fb2af5e3c1aaff9fa8f71a94
parent651022382c7f8da46cb4872a545ee1da6d097d2a (diff)
x86: Use POPCNT mnemonics in arch_hweight.h
Recently, the minimum required version of binutils was changed to 2.20, which supports POPCNT instruction mnemonics. Replace the byte-wise specification of POPCNT with those proper mnemonics. [ bp: massage commit message and remove line breaks. ] Signed-off-by: Uros Bizjak <ubizjak@gmail.com> Signed-off-by: Borislav Petkov <bp@suse.de> CC: "H. Peter Anvin" <hpa@zytor.com> CC: Ingo Molnar <mingo@redhat.com> CC: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/20181014202354.21281-1-ubizjak@gmail.com
-rw-r--r--arch/x86/include/asm/arch_hweight.h10
1 files changed, 2 insertions, 8 deletions
diff --git a/arch/x86/include/asm/arch_hweight.h b/arch/x86/include/asm/arch_hweight.h
index 34a10b2d5b73..fc0693569f7a 100644
--- a/arch/x86/include/asm/arch_hweight.h
+++ b/arch/x86/include/asm/arch_hweight.h
@@ -5,15 +5,9 @@
5#include <asm/cpufeatures.h> 5#include <asm/cpufeatures.h>
6 6
7#ifdef CONFIG_64BIT 7#ifdef CONFIG_64BIT
8/* popcnt %edi, %eax */
9#define POPCNT32 ".byte 0xf3,0x0f,0xb8,0xc7"
10/* popcnt %rdi, %rax */
11#define POPCNT64 ".byte 0xf3,0x48,0x0f,0xb8,0xc7"
12#define REG_IN "D" 8#define REG_IN "D"
13#define REG_OUT "a" 9#define REG_OUT "a"
14#else 10#else
15/* popcnt %eax, %eax */
16#define POPCNT32 ".byte 0xf3,0x0f,0xb8,0xc0"
17#define REG_IN "a" 11#define REG_IN "a"
18#define REG_OUT "a" 12#define REG_OUT "a"
19#endif 13#endif
@@ -24,7 +18,7 @@ static __always_inline unsigned int __arch_hweight32(unsigned int w)
24{ 18{
25 unsigned int res; 19 unsigned int res;
26 20
27 asm (ALTERNATIVE("call __sw_hweight32", POPCNT32, X86_FEATURE_POPCNT) 21 asm (ALTERNATIVE("call __sw_hweight32", "popcntl %1, %0", X86_FEATURE_POPCNT)
28 : "="REG_OUT (res) 22 : "="REG_OUT (res)
29 : REG_IN (w)); 23 : REG_IN (w));
30 24
@@ -52,7 +46,7 @@ static __always_inline unsigned long __arch_hweight64(__u64 w)
52{ 46{
53 unsigned long res; 47 unsigned long res;
54 48
55 asm (ALTERNATIVE("call __sw_hweight64", POPCNT64, X86_FEATURE_POPCNT) 49 asm (ALTERNATIVE("call __sw_hweight64", "popcntq %1, %0", X86_FEATURE_POPCNT)
56 : "="REG_OUT (res) 50 : "="REG_OUT (res)
57 : REG_IN (w)); 51 : REG_IN (w));
58 52