linux/arch/x86/kernel
Borislav Petkov 25e0aeaab0 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 f5967101e9)
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Signed-off-by: Greg Hackmann <ghackmann@google.com>

Conflicts:
	lib/Makefile

Change-Id: Ie7e6dce51c7093b1162337ec8bfc5abde0d79688
2017-11-20 21:15:59 +05:30
..
acpi x86/acpi: Prevent out of bound access caused by broken ACPI tables 2017-07-27 15:06:07 -07:00
apic x86/ioapic: Pass the correct data to unmask_ioapic_irq() 2017-07-27 15:06:07 -07:00
cpu x86/microcode/intel: Disable late loading on model 79 2017-11-02 09:40:50 +01:00
fpu x86/fpu: Don't let userspace set bogus xcomp_bv 2017-10-05 09:41:47 +02:00
kprobes kprobes/x86: Fix kernel panic when certain exception-handling addresses are probed 2017-05-14 13:32:55 +02:00
.gitignore
alternative.c x86/alternatives: Make optimize_nops() interrupt safe and synced 2015-09-03 21:27:47 +02:00
amd_gart_64.c
amd_nb.c x86/amd_nb: Fix boot crash on non-AMD systems 2016-07-27 09:47:29 -07:00
apb_timer.c x86/asm/tsc: Rename native_read_tsc() to rdtsc() 2015-07-06 15:23:28 +02:00
aperture_64.c
apm_32.c apm32: Fix cputime == jiffies assumption 2015-07-29 15:44:58 +02:00
asm-offsets_32.c
asm-offsets_64.c x86/asm/entry: (Re-)rename __NR_entry_INT80_compat_max to __NR_syscall_compat_max 2015-06-08 23:43:38 +02:00
asm-offsets.c Merge branch 'x86-headers-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2015-11-03 21:05:40 -08:00
audit_64.c
bootflag.c x86: don't use module_init for non-modular core bootflag code 2015-06-16 14:12:34 -04:00
check.c Linux 4.2-rc8 2015-08-25 09:59:19 +02:00
cpuid.c x86: Drop bogus __ref / __refdata annotations 2015-07-20 18:57:20 +02:00
crash_dump_32.c
crash_dump_64.c
crash.c x86/kexec: Remove obsolete 'in_crash_kexec' flag 2015-10-12 09:43:11 +02:00
devicetree.c Replace module_init with equivalent device_initcall in non modules. 2015-07-02 10:30:48 -07:00
doublefault.c
dumpstack_32.c
dumpstack_64.c
dumpstack.c
e820.c x86/e820: Don't merge consecutive E820_PRAM ranges 2016-10-28 03:01:33 -04:00
early_printk.c x86/early_printk: Set __iomem address space for IO 2015-10-13 21:45:56 +02:00
early-quirks.c drm/i915: Account for TSEG size when determining 865G stolen base 2016-10-31 04:13:58 -06:00
espfix_64.c Merge branch 'x86/urgent' into x86/asm, before applying dependent patches 2015-07-31 10:23:35 +02:00
ftrace.c Merge remote-tracking branch 'lts/linux-4.4.y' into linux-linaro-lsk-v4.4 2017-05-15 17:31:58 +08:00
head_32.S x86/traps: Ignore high word of regs->cs in early_fixup_exception() 2016-12-08 07:15:24 +01:00
head_64.S x86/cpu: Call verify_cpu() after having entered long mode too 2015-11-07 10:45:02 +01:00
head.c
head32.c
head64.c x86/kasan: Fix boot with KASAN=y and PROFILE_ANNOTATED_BRANCHES=y 2017-03-22 12:04:18 +01:00
hpet.c x86/irq: Make irq activate operations symmetric 2017-02-09 08:02:47 +01:00
hw_breakpoint.c perf/x86/hw_breakpoints: Fix check for kernel-space breakpoints 2015-08-04 10:16:55 +02:00
i386_ksyms_32.c BACKPORT: x86/hweight: Get rid of the special calling convention 2017-11-20 21:15:59 +05:30
i8237.c
i8253.c clockevents/drivers/i8253: Migrate to new 'set-state' interface 2015-08-10 11:40:30 +02:00
i8259.c x86/irq: Probe for PIC presence before allocating descs for legacy IRQs 2015-11-07 10:37:37 +01:00
io_delay.c
ioport.c x86/iopl: Fix iopl capability check on Xen PV 2016-04-12 09:08:38 -07:00
irq_32.c genirq: Remove irq argument from irq flow handlers 2015-09-16 15:47:51 +02:00
irq_64.c x86/irq: Drop unlikely before IS_ERR_OR_NULL 2015-10-01 11:08:56 +02:00
irq_work.c treewide: Remove old email address 2015-11-23 09:44:58 +01:00
irq.c x86/irq: Call irq_force_move_complete with irq descriptor 2016-03-03 15:07:31 -08:00
irqinit.c x86/irq: Store irq descriptor in vector array 2015-08-06 00:14:59 +02:00
jump_label.c jump_label: Rename JUMP_LABEL_{EN,DIS}ABLE to JUMP_LABEL_{JMP,NOP} 2015-08-03 11:34:12 +02:00
kdebugfs.c
kexec-bzimage64.c Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security 2015-09-08 12:41:25 -07:00
kgdb.c x86/mm: Always enable CONFIG_DEBUG_RODATA and remove the Kconfig option 2016-03-17 18:51:51 +00:00
ksysfs.c
kvm.c KVM: async_pf: make rcu irq exit if not triggered from idle task 2017-08-11 09:08:47 -07:00
kvmclock.c x86: kvmclock: abolish PVCLOCK_COUNTS_FROM_ZERO 2015-10-01 15:06:42 +02:00
ldt.c x86/ldt: Fix small LDT allocation for Xen 2015-09-14 12:10:50 +02:00
livepatch.c UPSTREAM: module: use a structure to encapsulate layout. 2017-08-11 19:31:04 +05:30
machine_kexec_32.c
machine_kexec_64.c kexec: provide arch_kexec_protect(unprotect)_crashkres() 2017-10-25 11:24:40 +08:00
Makefile kexec: split kexec_load syscall from kexec core code 2015-09-10 13:29:01 -07:00
mcount_64.S ftrace/x86: Set ftrace_stub to weak to prevent gcc from using short jumps to it 2017-01-26 08:23:46 +01:00
mmconf-fam10h_64.c
module.c
mpparse.c
msr.c
nmi_selftest.c
nmi.c Merge branch 'x86/urgent' into x86/asm, before applying dependent patches 2015-07-31 10:23:35 +02:00
paravirt_patch_32.c x86/asm/tsc, x86/paravirt: Remove read_tsc() and read_tscp() paravirt hooks 2015-07-06 15:23:26 +02:00
paravirt_patch_64.c Merge branch 'locking/core' into x86/core, to prepare for dependent patch 2015-06-03 10:07:35 +02:00
paravirt-spinlocks.c
paravirt.c x86/paravirt: Do not trace _paravirt_ident_*() functions 2016-09-24 10:07:37 +02:00
pci-calgary_64.c x86/pci-calgary: Fix iommu_free() comparison of unsigned expression >= 0 2017-05-14 13:32:55 +02:00
pci-dma.c mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd 2015-11-06 17:50:42 -08:00
pci-iommu_table.c
pci-nommu.c
pci-swiotlb.c x86/swiotlb: Try coherent allocations with __GFP_NOWARN 2015-06-11 08:28:38 +02:00
pcspeaker.c
perf_regs.c
pmem.c libnvdimm, e820: skip module loading when no type-12 2015-11-30 09:10:33 -08:00
probe_roms.c
process_32.c sched/core, sched/x86: Kill thread_info::saved_preempt_count 2015-10-06 17:08:18 +02:00
process_64.c x86/iopl/64: Properly context-switch IOPL on Xen PV 2016-04-12 09:08:38 -07:00
process.c Move x86_64 idle notifiers to generic 2016-02-16 13:52:32 -08:00
ptrace.c x86/dumpstack: Fix x86_32 kernel_stack_pointer() previous stack access 2016-10-16 17:36:15 +02:00
pvclock.c pvclock: Add CPU barriers to get correct version value 2016-08-10 11:49:27 +02:00
quirks.c timers/x86/hpet: Type adjustments 2015-10-21 11:17:32 +02:00
reboot_fixups_32.c
reboot.c x86/reboot/quirks: Add iMac10,1 to pci_reboot_dmi_table[] 2016-01-31 11:28:54 -08:00
relocate_kernel_32.S
relocate_kernel_64.S
resource.c
rtc.c x86/paravirt: Prevent rtc_cmos platform device init on PV guests 2015-12-19 21:35:13 +01:00
setup_percpu.c
setup.c x86/mm/pat: Don't report PAT on CPUs that don't support it 2017-07-15 11:57:50 +02:00
signal_compat.c x86/compat: Move copy_siginfo_*_user32() to signal_compat.c 2015-07-06 15:28:55 +02:00
signal.c x86/signal: Fix restart_syscall number for x32 tasks 2015-12-05 18:52:14 +01:00
smp.c x86/mce: Clear Local MCE opt-in before kexec 2015-08-13 10:12:52 +02:00
smpboot.c x86 smpboot: Re-enable init_udelay=0 by default on modern CPUs 2015-11-25 23:17:48 +01:00
stacktrace.c
step.c Merge branch 'x86/urgent' into x86/asm to fix up conflicts and to pick up fixes 2015-08-18 09:39:47 +02:00
sys_x86_64.c mm: larger stack guard gap, between vmas 2017-06-26 07:13:11 +02:00
sysfb_efi.c x86/sysfb_efi: Fix valid BAR address range check 2016-05-11 11:21:20 +02:00
sysfb_simplefb.c
sysfb.c
tboot.c
tce_64.c
test_nx.c x86/mm: Always enable CONFIG_DEBUG_RODATA and remove the Kconfig option 2016-03-17 18:51:51 +00:00
test_rodata.c x86/mm: Always enable CONFIG_DEBUG_RODATA and remove the Kconfig option 2016-03-17 18:51:51 +00:00
time.c
tls.c
tls.h
topology.c x86: Drop bogus __ref / __refdata annotations 2015-07-20 18:57:20 +02:00
trace_clock.c x86/asm/tsc: Add rdtsc_ordered() and use it in trivial call sites 2015-07-06 15:23:29 +02:00
tracepoint.c
traps.c Revert "x86/mm: Expand the exception table logic to allow new handling options" 2016-10-31 19:56:26 -06:00
tsc_msr.c x86/tsc: Read all ratio bits from MSR_PLATFORM_INFO 2016-05-11 11:21:19 +02:00
tsc_sync.c x86/asm/tsc/sync: Use rdtsc_ordered() in check_tsc_warp() and drop extra barriers 2015-07-06 15:23:29 +02:00
tsc.c perf/x86: Fix time_shift in perf_event_mmap_page 2015-10-20 10:30:52 +02:00
uprobes.c uprobes/x86: Fix RIP-relative handling of EVEX-encoded instructions 2016-09-07 08:32:36 +02:00
verify_cpu.S x86/cpu: Call verify_cpu() after having entered long mode too 2015-11-07 10:45:02 +01:00
vm86_32.c x86/vm86: Block non-root vm86(old) if mmap_min_addr != 0 2015-09-05 09:01:16 +02:00
vmlinux.lds.S x86/mm: Always enable CONFIG_DEBUG_RODATA and remove the Kconfig option 2016-03-17 18:51:51 +00:00
vsmp_64.c x86: replace __init_or_module with __init in non-modular vsmp_64.c 2015-06-16 14:12:41 -04:00
x86_init.c PCI changes for the v4.2 merge window: 2015-06-23 13:41:24 -07:00
x8664_ksyms_64.c BACKPORT: x86/hweight: Get rid of the special calling convention 2017-11-20 21:15:59 +05:30