OSDN Git Service

BACKPORT: x86/hweight: Get rid of the special calling convention
authorBorislav Petkov <bp@suse.de>
Mon, 30 May 2016 10:56:27 +0000 (12:56 +0200)
committerGreg Hackmann <ghackmann@google.com>
Mon, 9 Oct 2017 21:00:13 +0000 (14:00 -0700)
commitfd5df2a435a5f2015b3b11504574e500ca3ab452
treecfefea1ba3963de7e4507f86c69347aaf7072a63
parentcafc5bc76374ba807d570055be4e217572d33a49
BACKPORT: x86/hweight: Get rid of the special calling convention

People complained about ARCH_HWEIGHT_CFLAGS and how it throws a wrench
into kcov, lto, etc, experimentations.

Add asm versions for __sw_hweight{32,64}() and do explicit saving and
restoring of clobbered registers. This gets rid of the special calling
convention. We get to call those functions on !X86_FEATURE_POPCNT CPUs.

We still need to hardcode POPCNT and register operands as some old gas
versions which we support, do not know about POPCNT.

Btw, remove redundant REX prefix from 32-bit POPCNT because alternatives
can do padding now.

Suggested-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1464605787-20603-1-git-send-email-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
(cherry picked from commit f5967101e9de12addcda4510dfbac66d7c5779c3)
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Signed-off-by: Greg Hackmann <ghackmann@google.com>
Conflicts:
lib/Makefile

Change-Id: Ie7e6dce51c7093b1162337ec8bfc5abde0d79688
arch/x86/Kconfig
arch/x86/include/asm/arch_hweight.h
arch/x86/kernel/i386_ksyms_32.c
arch/x86/kernel/x8664_ksyms_64.c
arch/x86/lib/Makefile
arch/x86/lib/hweight.S [new file with mode: 0644]
lib/Makefile
lib/hweight.c