Merge branch 'android-4.4-llvm' into android-4.4
Change-Id: Ieb23e9018ae152706f1980fcd5cbd1dffb4d8be6 Signed-off-by: Greg Hackmann <ghackmann@google.com>
This commit is contained in:
commit
02049f8843
33 changed files with 283 additions and 156 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -33,6 +33,7 @@
|
|||
*.lzo
|
||||
*.patch
|
||||
*.gcno
|
||||
*.ll
|
||||
modules.builtin
|
||||
Module.symvers
|
||||
*.dwo
|
||||
|
|
25
Kbuild
25
Kbuild
|
@ -6,31 +6,6 @@
|
|||
# 3) Generate asm-offsets.h (may need bounds.h and timeconst.h)
|
||||
# 4) Check for missing system calls
|
||||
|
||||
# Default sed regexp - multiline due to syntax constraints
|
||||
define sed-y
|
||||
"/^->/{s:->#\(.*\):/* \1 */:; \
|
||||
s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
|
||||
s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
|
||||
s:->::; p;}"
|
||||
endef
|
||||
|
||||
# Use filechk to avoid rebuilds when a header changes, but the resulting file
|
||||
# does not
|
||||
define filechk_offsets
|
||||
(set -e; \
|
||||
echo "#ifndef $2"; \
|
||||
echo "#define $2"; \
|
||||
echo "/*"; \
|
||||
echo " * DO NOT MODIFY."; \
|
||||
echo " *"; \
|
||||
echo " * This file was generated by Kbuild"; \
|
||||
echo " */"; \
|
||||
echo ""; \
|
||||
sed -ne $(sed-y); \
|
||||
echo ""; \
|
||||
echo "#endif" )
|
||||
endef
|
||||
|
||||
#####
|
||||
# 1) Generate bounds.h
|
||||
|
||||
|
|
24
Makefile
24
Makefile
|
@ -301,7 +301,7 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
|
|||
|
||||
HOSTCC = gcc
|
||||
HOSTCXX = g++
|
||||
HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89
|
||||
HOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89
|
||||
HOSTCXXFLAGS = -O2
|
||||
|
||||
ifeq ($(shell $(HOSTCC) -v 2>&1 | grep -c "clang version"), 1)
|
||||
|
@ -624,7 +624,7 @@ KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
|
|||
KBUILD_CFLAGS += $(call cc-disable-warning, int-in-bool-context)
|
||||
|
||||
ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
|
||||
KBUILD_CFLAGS += -Os
|
||||
KBUILD_CFLAGS += $(call cc-option,-Oz,-Os)
|
||||
else
|
||||
ifdef CONFIG_PROFILE_ALL_BRANCHES
|
||||
KBUILD_CFLAGS += -O2
|
||||
|
@ -694,11 +694,22 @@ endif
|
|||
KBUILD_CFLAGS += $(stackp-flag)
|
||||
|
||||
ifeq ($(cc-name),clang)
|
||||
ifneq ($(CROSS_COMPILE),)
|
||||
CLANG_TRIPLE ?= $(CROSS_COMPILE)
|
||||
CLANG_TARGET := -target $(notdir $(CLANG_TRIPLE:%-=%))
|
||||
GCC_TOOLCHAIN := $(realpath $(dir $(shell which $(LD)))/..)
|
||||
endif
|
||||
ifneq ($(GCC_TOOLCHAIN),)
|
||||
CLANG_GCC_TC := -gcc-toolchain $(GCC_TOOLCHAIN)
|
||||
endif
|
||||
KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
|
||||
KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
|
||||
KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
|
||||
KBUILD_CPPFLAGS += $(call cc-option,-Wno-unknown-warning-option,)
|
||||
KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable)
|
||||
KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier)
|
||||
KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
|
||||
KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
|
||||
KBUILD_CFLAGS += $(call cc-disable-warning, duplicate-decl-specifier)
|
||||
# Quiet clang warning: comparison of unsigned expression < 0 is always false
|
||||
KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare)
|
||||
# CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the
|
||||
|
@ -706,6 +717,8 @@ KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare)
|
|||
# See modpost pattern 2
|
||||
KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,)
|
||||
KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior)
|
||||
KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
|
||||
KBUILD_AFLAGS += $(call cc-option, -no-integrated-as)
|
||||
else
|
||||
|
||||
# These warnings generated too much noise in a regular build.
|
||||
|
@ -1281,6 +1294,8 @@ help:
|
|||
@echo ' (default: $$(INSTALL_MOD_PATH)/lib/firmware)'
|
||||
@echo ' dir/ - Build all files in dir and below'
|
||||
@echo ' dir/file.[ois] - Build specified target only'
|
||||
@echo ' dir/file.ll - Build the LLVM assembly file'
|
||||
@echo ' (requires compiler support for LLVM assembly generation)'
|
||||
@echo ' dir/file.lst - Build specified mixed source/assembly target only'
|
||||
@echo ' (requires a recent binutils and recent build (System.map))'
|
||||
@echo ' dir/file.ko - Build module including final link'
|
||||
|
@ -1456,6 +1471,7 @@ clean: $(clean-dirs)
|
|||
-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
|
||||
-o -name '*.symtypes' -o -name 'modules.order' \
|
||||
-o -name modules.builtin -o -name '.tmp_*.o.*' \
|
||||
-o -name '*.ll' \
|
||||
-o -name '*.gcno' \) -type f -print | xargs rm -f
|
||||
|
||||
# Generate tags for editors
|
||||
|
@ -1559,6 +1575,8 @@ endif
|
|||
$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
|
||||
%.symtypes: %.c prepare scripts FORCE
|
||||
$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
|
||||
%.ll: %.c prepare scripts FORCE
|
||||
$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
|
||||
|
||||
# Modules
|
||||
/: prepare scripts FORCE
|
||||
|
|
|
@ -30,7 +30,14 @@ $(warning LSE atomics not supported by binutils)
|
|||
endif
|
||||
endif
|
||||
|
||||
KBUILD_CFLAGS += -mgeneral-regs-only $(lseinstr)
|
||||
ifeq ($(cc-name),clang)
|
||||
# This is a workaround for https://bugs.llvm.org/show_bug.cgi?id=30792.
|
||||
# TODO: revert when this is fixed in LLVM.
|
||||
KBUILD_CFLAGS += -mno-implicit-float
|
||||
else
|
||||
KBUILD_CFLAGS += -mgeneral-regs-only
|
||||
endif
|
||||
KBUILD_CFLAGS += $(lseinstr)
|
||||
KBUILD_CFLAGS += -fno-pic
|
||||
KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
|
||||
KBUILD_CFLAGS += $(call cc-option, -mpc-relative-literal-loads)
|
||||
|
@ -66,6 +73,10 @@ else
|
|||
TEXT_OFFSET := 0x00080000
|
||||
endif
|
||||
|
||||
ifeq ($(cc-name),clang)
|
||||
KBUILD_CFLAGS += $(call cc-disable-warning, asm-operand-widths)
|
||||
endif
|
||||
|
||||
# KASAN_SHADOW_OFFSET = VA_START + (1 << (VA_BITS - 3)) - (1 << 61)
|
||||
# in 32-bit arithmetic
|
||||
KASAN_SHADOW_OFFSET := $(shell printf "0x%08x00000000\n" $$(( \
|
||||
|
|
|
@ -82,7 +82,8 @@ ENTRY(sha1_ce_transform)
|
|||
ldr dgb, [x0, #16]
|
||||
|
||||
/* load sha1_ce_state::finalize */
|
||||
ldr w4, [x0, #:lo12:sha1_ce_offsetof_finalize]
|
||||
ldr_l w4, sha1_ce_offsetof_finalize, x4
|
||||
ldr w4, [x0, x4]
|
||||
|
||||
/* load input */
|
||||
0: ld1 {v8.4s-v11.4s}, [x1], #64
|
||||
|
@ -132,7 +133,8 @@ CPU_LE( rev32 v11.16b, v11.16b )
|
|||
* the padding is handled by the C code in that case.
|
||||
*/
|
||||
cbz x4, 3f
|
||||
ldr x4, [x0, #:lo12:sha1_ce_offsetof_count]
|
||||
ldr_l w4, sha1_ce_offsetof_count, x4
|
||||
ldr x4, [x0, x4]
|
||||
movi v9.2d, #0
|
||||
mov x8, #0x80000000
|
||||
movi v10.2d, #0
|
||||
|
|
|
@ -17,9 +17,6 @@
|
|||
#include <linux/crypto.h>
|
||||
#include <linux/module.h>
|
||||
|
||||
#define ASM_EXPORT(sym, val) \
|
||||
asm(".globl " #sym "; .set " #sym ", %0" :: "I"(val));
|
||||
|
||||
MODULE_DESCRIPTION("SHA1 secure hash using ARMv8 Crypto Extensions");
|
||||
MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>");
|
||||
MODULE_LICENSE("GPL v2");
|
||||
|
@ -32,6 +29,9 @@ struct sha1_ce_state {
|
|||
asmlinkage void sha1_ce_transform(struct sha1_ce_state *sst, u8 const *src,
|
||||
int blocks);
|
||||
|
||||
const u32 sha1_ce_offsetof_count = offsetof(struct sha1_ce_state, sst.count);
|
||||
const u32 sha1_ce_offsetof_finalize = offsetof(struct sha1_ce_state, finalize);
|
||||
|
||||
static int sha1_ce_update(struct shash_desc *desc, const u8 *data,
|
||||
unsigned int len)
|
||||
{
|
||||
|
@ -52,11 +52,6 @@ static int sha1_ce_finup(struct shash_desc *desc, const u8 *data,
|
|||
struct sha1_ce_state *sctx = shash_desc_ctx(desc);
|
||||
bool finalize = !sctx->sst.count && !(len % SHA1_BLOCK_SIZE);
|
||||
|
||||
ASM_EXPORT(sha1_ce_offsetof_count,
|
||||
offsetof(struct sha1_ce_state, sst.count));
|
||||
ASM_EXPORT(sha1_ce_offsetof_finalize,
|
||||
offsetof(struct sha1_ce_state, finalize));
|
||||
|
||||
/*
|
||||
* Allow the asm code to perform the finalization if there is no
|
||||
* partial data and the input is a round multiple of the block size.
|
||||
|
|
|
@ -88,7 +88,8 @@ ENTRY(sha2_ce_transform)
|
|||
ld1 {dgav.4s, dgbv.4s}, [x0]
|
||||
|
||||
/* load sha256_ce_state::finalize */
|
||||
ldr w4, [x0, #:lo12:sha256_ce_offsetof_finalize]
|
||||
ldr_l w4, sha256_ce_offsetof_finalize, x4
|
||||
ldr w4, [x0, x4]
|
||||
|
||||
/* load input */
|
||||
0: ld1 {v16.4s-v19.4s}, [x1], #64
|
||||
|
@ -136,7 +137,8 @@ CPU_LE( rev32 v19.16b, v19.16b )
|
|||
* the padding is handled by the C code in that case.
|
||||
*/
|
||||
cbz x4, 3f
|
||||
ldr x4, [x0, #:lo12:sha256_ce_offsetof_count]
|
||||
ldr_l w4, sha256_ce_offsetof_count, x4
|
||||
ldr x4, [x0, x4]
|
||||
movi v17.2d, #0
|
||||
mov x8, #0x80000000
|
||||
movi v18.2d, #0
|
||||
|
|
|
@ -17,9 +17,6 @@
|
|||
#include <linux/crypto.h>
|
||||
#include <linux/module.h>
|
||||
|
||||
#define ASM_EXPORT(sym, val) \
|
||||
asm(".globl " #sym "; .set " #sym ", %0" :: "I"(val));
|
||||
|
||||
MODULE_DESCRIPTION("SHA-224/SHA-256 secure hash using ARMv8 Crypto Extensions");
|
||||
MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>");
|
||||
MODULE_LICENSE("GPL v2");
|
||||
|
@ -32,6 +29,11 @@ struct sha256_ce_state {
|
|||
asmlinkage void sha2_ce_transform(struct sha256_ce_state *sst, u8 const *src,
|
||||
int blocks);
|
||||
|
||||
const u32 sha256_ce_offsetof_count = offsetof(struct sha256_ce_state,
|
||||
sst.count);
|
||||
const u32 sha256_ce_offsetof_finalize = offsetof(struct sha256_ce_state,
|
||||
finalize);
|
||||
|
||||
static int sha256_ce_update(struct shash_desc *desc, const u8 *data,
|
||||
unsigned int len)
|
||||
{
|
||||
|
@ -52,11 +54,6 @@ static int sha256_ce_finup(struct shash_desc *desc, const u8 *data,
|
|||
struct sha256_ce_state *sctx = shash_desc_ctx(desc);
|
||||
bool finalize = !sctx->sst.count && !(len % SHA256_BLOCK_SIZE);
|
||||
|
||||
ASM_EXPORT(sha256_ce_offsetof_count,
|
||||
offsetof(struct sha256_ce_state, sst.count));
|
||||
ASM_EXPORT(sha256_ce_offsetof_finalize,
|
||||
offsetof(struct sha256_ce_state, finalize));
|
||||
|
||||
/*
|
||||
* Allow the asm code to perform the finalization if there is no
|
||||
* partial data and the input is a round multiple of the block size.
|
||||
|
|
|
@ -50,32 +50,10 @@ CFLAGS_traps.o += -mfixed-range=f2-f5,f16-f31
|
|||
# The gate DSO image is built using a special linker script.
|
||||
include $(src)/Makefile.gate
|
||||
|
||||
# Calculate NR_IRQ = max(IA64_NATIVE_NR_IRQS, XEN_NR_IRQS, ...) based on config
|
||||
define sed-y
|
||||
"/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"
|
||||
endef
|
||||
quiet_cmd_nr_irqs = GEN $@
|
||||
define cmd_nr_irqs
|
||||
(set -e; \
|
||||
echo "#ifndef __ASM_NR_IRQS_H__"; \
|
||||
echo "#define __ASM_NR_IRQS_H__"; \
|
||||
echo "/*"; \
|
||||
echo " * DO NOT MODIFY."; \
|
||||
echo " *"; \
|
||||
echo " * This file was generated by Kbuild"; \
|
||||
echo " *"; \
|
||||
echo " */"; \
|
||||
echo ""; \
|
||||
sed -ne $(sed-y) $<; \
|
||||
echo ""; \
|
||||
echo "#endif" ) > $@
|
||||
endef
|
||||
|
||||
# We use internal kbuild rules to avoid the "is up to date" message from make
|
||||
arch/$(SRCARCH)/kernel/nr-irqs.s: arch/$(SRCARCH)/kernel/nr-irqs.c
|
||||
$(Q)mkdir -p $(dir $@)
|
||||
$(call if_changed_dep,cc_s_c)
|
||||
|
||||
include/generated/nr-irqs.h: arch/$(SRCARCH)/kernel/nr-irqs.s
|
||||
$(Q)mkdir -p $(dir $@)
|
||||
$(call cmd,nr_irqs)
|
||||
include/generated/nr-irqs.h: arch/$(SRCARCH)/kernel/nr-irqs.s FORCE
|
||||
$(call filechk,offsets,__ASM_NR_IRQS_H__)
|
||||
|
|
|
@ -296,11 +296,6 @@ config X86_32_LAZY_GS
|
|||
def_bool y
|
||||
depends on X86_32 && !CC_STACKPROTECTOR
|
||||
|
||||
config ARCH_HWEIGHT_CFLAGS
|
||||
string
|
||||
default "-fcall-saved-ecx -fcall-saved-edx" if X86_32
|
||||
default "-fcall-saved-rdi -fcall-saved-rsi -fcall-saved-rdx -fcall-saved-rcx -fcall-saved-r8 -fcall-saved-r9 -fcall-saved-r10 -fcall-saved-r11" if X86_64
|
||||
|
||||
config ARCH_SUPPORTS_UPROBES
|
||||
def_bool y
|
||||
|
||||
|
|
|
@ -11,6 +11,16 @@ else
|
|||
KBUILD_DEFCONFIG := $(ARCH)_defconfig
|
||||
endif
|
||||
|
||||
# For gcc stack alignment is specified with -mpreferred-stack-boundary,
|
||||
# clang has the option -mstack-alignment for that purpose.
|
||||
ifneq ($(call cc-option, -mpreferred-stack-boundary=4),)
|
||||
cc_stack_align4 := -mpreferred-stack-boundary=2
|
||||
cc_stack_align8 := -mpreferred-stack-boundary=3
|
||||
else ifneq ($(call cc-option, -mstack-alignment=16),)
|
||||
cc_stack_align4 := -mstack-alignment=4
|
||||
cc_stack_align8 := -mstack-alignment=8
|
||||
endif
|
||||
|
||||
# How to compile the 16-bit code. Note we always compile for -march=i386;
|
||||
# that way we can complain to the user if the CPU is insufficient.
|
||||
#
|
||||
|
@ -24,10 +34,11 @@ REALMODE_CFLAGS := $(M16_CFLAGS) -g -Os -D__KERNEL__ \
|
|||
-DDISABLE_BRANCH_PROFILING \
|
||||
-Wall -Wstrict-prototypes -march=i386 -mregparm=3 \
|
||||
-fno-strict-aliasing -fomit-frame-pointer -fno-pic \
|
||||
-mno-mmx -mno-sse \
|
||||
$(call cc-option, -ffreestanding) \
|
||||
$(call cc-option, -fno-stack-protector) \
|
||||
$(call cc-option, -mpreferred-stack-boundary=2)
|
||||
-mno-mmx -mno-sse
|
||||
|
||||
REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -ffreestanding)
|
||||
REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -fno-stack-protector)
|
||||
REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), $(cc_stack_align4))
|
||||
export REALMODE_CFLAGS
|
||||
|
||||
# BITS is used as extension for files which are available in a 32 bit
|
||||
|
@ -64,8 +75,10 @@ ifeq ($(CONFIG_X86_32),y)
|
|||
# with nonstandard options
|
||||
KBUILD_CFLAGS += -fno-pic
|
||||
|
||||
# prevent gcc from keeping the stack 16 byte aligned
|
||||
KBUILD_CFLAGS += $(call cc-option,-mpreferred-stack-boundary=2)
|
||||
# Align the stack to the register width instead of using the default
|
||||
# alignment of 16 bytes. This reduces stack usage and the number of
|
||||
# alignment instructions.
|
||||
KBUILD_CFLAGS += $(call cc-option,$(cc_stack_align4))
|
||||
|
||||
# Disable unit-at-a-time mode on pre-gcc-4.0 compilers, it makes gcc use
|
||||
# a lot more stack due to the lack of sharing of stacklots:
|
||||
|
@ -88,10 +101,10 @@ else
|
|||
KBUILD_CFLAGS += -m64
|
||||
|
||||
# Align jump targets to 1 byte, not the default 16 bytes:
|
||||
KBUILD_CFLAGS += -falign-jumps=1
|
||||
KBUILD_CFLAGS += $(call cc-option,-falign-jumps=1)
|
||||
|
||||
# Pack loops tightly as well:
|
||||
KBUILD_CFLAGS += -falign-loops=1
|
||||
KBUILD_CFLAGS += $(call cc-option,-falign-loops=1)
|
||||
|
||||
# Don't autogenerate traditional x87 instructions
|
||||
KBUILD_CFLAGS += $(call cc-option,-mno-80387)
|
||||
|
@ -99,8 +112,14 @@ else
|
|||
|
||||
KBUILD_CFLAGS += -fno-pic
|
||||
|
||||
# Use -mpreferred-stack-boundary=3 if supported.
|
||||
KBUILD_CFLAGS += $(call cc-option,-mpreferred-stack-boundary=3)
|
||||
# By default gcc and clang use a stack alignment of 16 bytes for x86.
|
||||
# However the standard kernel entry on x86-64 leaves the stack on an
|
||||
# 8-byte boundary. If the compiler isn't informed about the actual
|
||||
# alignment it will generate extra alignment instructions for the
|
||||
# default alignment which keep the stack *mis*aligned.
|
||||
# Furthermore an alignment to the register width reduces stack usage
|
||||
# and the number of alignment instructions.
|
||||
KBUILD_CFLAGS += $(call cc-option,$(cc_stack_align8))
|
||||
|
||||
# Use -mskip-rax-setup if supported.
|
||||
KBUILD_CFLAGS += $(call cc-option,-mskip-rax-setup)
|
||||
|
|
|
@ -94,7 +94,7 @@ static unsigned long get_random_long(void)
|
|||
}
|
||||
|
||||
/* Circular multiply for better bit diffusion */
|
||||
asm("mul %3"
|
||||
asm(_ASM_MUL "%3"
|
||||
: "=a" (random), "=d" (raw)
|
||||
: "a" (random), "rm" (mix_const));
|
||||
random += raw;
|
||||
|
|
|
@ -16,6 +16,15 @@
|
|||
#include "ctype.h"
|
||||
#include "string.h"
|
||||
|
||||
/*
|
||||
* Undef these macros so that the functions that we provide
|
||||
* here will have the correct names regardless of how string.h
|
||||
* may have chosen to #define them.
|
||||
*/
|
||||
#undef memcpy
|
||||
#undef memset
|
||||
#undef memcmp
|
||||
|
||||
int memcmp(const void *s1, const void *s2, size_t len)
|
||||
{
|
||||
u8 diff;
|
||||
|
|
|
@ -65,7 +65,6 @@
|
|||
#include <linux/linkage.h>
|
||||
#include <asm/inst.h>
|
||||
|
||||
#define CONCAT(a,b) a##b
|
||||
#define VMOVDQ vmovdqu
|
||||
|
||||
#define xdata0 %xmm0
|
||||
|
@ -92,8 +91,6 @@
|
|||
#define num_bytes %r8
|
||||
|
||||
#define tmp %r10
|
||||
#define DDQ(i) CONCAT(ddq_add_,i)
|
||||
#define XMM(i) CONCAT(%xmm, i)
|
||||
#define DDQ_DATA 0
|
||||
#define XDATA 1
|
||||
#define KEY_128 1
|
||||
|
@ -131,12 +128,12 @@ ddq_add_8:
|
|||
/* generate a unique variable for ddq_add_x */
|
||||
|
||||
.macro setddq n
|
||||
var_ddq_add = DDQ(\n)
|
||||
var_ddq_add = ddq_add_\n
|
||||
.endm
|
||||
|
||||
/* generate a unique variable for xmm register */
|
||||
.macro setxdata n
|
||||
var_xdata = XMM(\n)
|
||||
var_xdata = %xmm\n
|
||||
.endm
|
||||
|
||||
/* club the numeric 'id' to the symbol 'name' */
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
#define _ASM_X86_HWEIGHT_H
|
||||
|
||||
#ifdef CONFIG_64BIT
|
||||
/* popcnt %edi, %eax -- redundant REX prefix for alignment */
|
||||
#define POPCNT32 ".byte 0xf3,0x40,0x0f,0xb8,0xc7"
|
||||
/* popcnt %edi, %eax */
|
||||
#define POPCNT32 ".byte 0xf3,0x0f,0xb8,0xc7"
|
||||
/* popcnt %rdi, %rax */
|
||||
#define POPCNT64 ".byte 0xf3,0x48,0x0f,0xb8,0xc7"
|
||||
#define REG_IN "D"
|
||||
|
@ -15,19 +15,15 @@
|
|||
#define REG_OUT "a"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* __sw_hweightXX are called from within the alternatives below
|
||||
* and callee-clobbered registers need to be taken care of. See
|
||||
* ARCH_HWEIGHT_CFLAGS in <arch/x86/Kconfig> for the respective
|
||||
* compiler switches.
|
||||
*/
|
||||
#define __HAVE_ARCH_SW_HWEIGHT
|
||||
|
||||
static __always_inline unsigned int __arch_hweight32(unsigned int w)
|
||||
{
|
||||
unsigned int res = 0;
|
||||
unsigned int res;
|
||||
|
||||
asm (ALTERNATIVE("call __sw_hweight32", POPCNT32, X86_FEATURE_POPCNT)
|
||||
: "="REG_OUT (res)
|
||||
: REG_IN (w));
|
||||
: "="REG_OUT (res)
|
||||
: REG_IN (w));
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -51,11 +47,11 @@ static inline unsigned long __arch_hweight64(__u64 w)
|
|||
#else
|
||||
static __always_inline unsigned long __arch_hweight64(__u64 w)
|
||||
{
|
||||
unsigned long res = 0;
|
||||
unsigned long res;
|
||||
|
||||
asm (ALTERNATIVE("call __sw_hweight64", POPCNT64, X86_FEATURE_POPCNT)
|
||||
: "="REG_OUT (res)
|
||||
: REG_IN (w));
|
||||
: "="REG_OUT (res)
|
||||
: REG_IN (w));
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#define _ASM_ADD __ASM_SIZE(add)
|
||||
#define _ASM_SUB __ASM_SIZE(sub)
|
||||
#define _ASM_XADD __ASM_SIZE(xadd)
|
||||
#define _ASM_MUL __ASM_SIZE(mul)
|
||||
|
||||
#define _ASM_AX __ASM_REG(ax)
|
||||
#define _ASM_BX __ASM_REG(bx)
|
||||
|
|
|
@ -42,3 +42,5 @@ EXPORT_SYMBOL(empty_zero_page);
|
|||
EXPORT_SYMBOL(___preempt_schedule);
|
||||
EXPORT_SYMBOL(___preempt_schedule_notrace);
|
||||
#endif
|
||||
|
||||
EXPORT_SYMBOL(__sw_hweight32);
|
||||
|
|
|
@ -42,6 +42,9 @@ EXPORT_SYMBOL(clear_page);
|
|||
|
||||
EXPORT_SYMBOL(csum_partial);
|
||||
|
||||
EXPORT_SYMBOL(__sw_hweight32);
|
||||
EXPORT_SYMBOL(__sw_hweight64);
|
||||
|
||||
/*
|
||||
* Export string functions. We normally rely on gcc builtin for most of these,
|
||||
* but gcc sometimes decides not to inline them.
|
||||
|
|
|
@ -22,7 +22,7 @@ lib-y += memcpy_$(BITS).o
|
|||
lib-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o
|
||||
lib-$(CONFIG_INSTRUCTION_DECODER) += insn.o inat.o
|
||||
|
||||
obj-y += msr.o msr-reg.o msr-reg-export.o
|
||||
obj-y += msr.o msr-reg.o msr-reg-export.o hweight.o
|
||||
|
||||
ifeq ($(CONFIG_X86_32),y)
|
||||
obj-y += atomic64_32.o
|
||||
|
|
79
arch/x86/lib/hweight.S
Normal file
79
arch/x86/lib/hweight.S
Normal file
|
@ -0,0 +1,79 @@
|
|||
#include <linux/linkage.h>
|
||||
|
||||
#include <asm/asm.h>
|
||||
|
||||
/*
|
||||
* unsigned int __sw_hweight32(unsigned int w)
|
||||
* %rdi: w
|
||||
*/
|
||||
ENTRY(__sw_hweight32)
|
||||
|
||||
#ifdef CONFIG_X86_64
|
||||
movl %edi, %eax # w
|
||||
#endif
|
||||
__ASM_SIZE(push,) %__ASM_REG(dx)
|
||||
movl %eax, %edx # w -> t
|
||||
shrl %edx # t >>= 1
|
||||
andl $0x55555555, %edx # t &= 0x55555555
|
||||
subl %edx, %eax # w -= t
|
||||
|
||||
movl %eax, %edx # w -> t
|
||||
shrl $2, %eax # w_tmp >>= 2
|
||||
andl $0x33333333, %edx # t &= 0x33333333
|
||||
andl $0x33333333, %eax # w_tmp &= 0x33333333
|
||||
addl %edx, %eax # w = w_tmp + t
|
||||
|
||||
movl %eax, %edx # w -> t
|
||||
shrl $4, %edx # t >>= 4
|
||||
addl %edx, %eax # w_tmp += t
|
||||
andl $0x0f0f0f0f, %eax # w_tmp &= 0x0f0f0f0f
|
||||
imull $0x01010101, %eax, %eax # w_tmp *= 0x01010101
|
||||
shrl $24, %eax # w = w_tmp >> 24
|
||||
__ASM_SIZE(pop,) %__ASM_REG(dx)
|
||||
ret
|
||||
ENDPROC(__sw_hweight32)
|
||||
|
||||
ENTRY(__sw_hweight64)
|
||||
#ifdef CONFIG_X86_64
|
||||
pushq %rdi
|
||||
pushq %rdx
|
||||
|
||||
movq %rdi, %rdx # w -> t
|
||||
movabsq $0x5555555555555555, %rax
|
||||
shrq %rdx # t >>= 1
|
||||
andq %rdx, %rax # t &= 0x5555555555555555
|
||||
movabsq $0x3333333333333333, %rdx
|
||||
subq %rax, %rdi # w -= t
|
||||
|
||||
movq %rdi, %rax # w -> t
|
||||
shrq $2, %rdi # w_tmp >>= 2
|
||||
andq %rdx, %rax # t &= 0x3333333333333333
|
||||
andq %rdi, %rdx # w_tmp &= 0x3333333333333333
|
||||
addq %rdx, %rax # w = w_tmp + t
|
||||
|
||||
movq %rax, %rdx # w -> t
|
||||
shrq $4, %rdx # t >>= 4
|
||||
addq %rdx, %rax # w_tmp += t
|
||||
movabsq $0x0f0f0f0f0f0f0f0f, %rdx
|
||||
andq %rdx, %rax # w_tmp &= 0x0f0f0f0f0f0f0f0f
|
||||
movabsq $0x0101010101010101, %rdx
|
||||
imulq %rdx, %rax # w_tmp *= 0x0101010101010101
|
||||
shrq $56, %rax # w = w_tmp >> 56
|
||||
|
||||
popq %rdx
|
||||
popq %rdi
|
||||
ret
|
||||
#else /* CONFIG_X86_32 */
|
||||
/* We're getting an u64 arg in (%eax,%edx): unsigned long hweight64(__u64 w) */
|
||||
pushl %ecx
|
||||
|
||||
call __sw_hweight32
|
||||
movl %eax, %ecx # stash away result
|
||||
movl %edx, %eax # second part of input
|
||||
call __sw_hweight32
|
||||
addl %ecx, %eax # result
|
||||
|
||||
popl %ecx
|
||||
ret
|
||||
#endif
|
||||
ENDPROC(__sw_hweight64)
|
|
@ -10,7 +10,7 @@ cflags-$(CONFIG_X86) += -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2 \
|
|||
-fPIC -fno-strict-aliasing -mno-red-zone \
|
||||
-mno-mmx -mno-sse
|
||||
|
||||
cflags-$(CONFIG_ARM64) := $(subst -pg,,$(KBUILD_CFLAGS))
|
||||
cflags-$(CONFIG_ARM64) := $(subst -pg,,$(KBUILD_CFLAGS)) -fpie
|
||||
cflags-$(CONFIG_ARM) := $(subst -pg,,$(KBUILD_CFLAGS)) \
|
||||
-fno-builtin -fpic -mno-single-pic-base
|
||||
|
||||
|
|
|
@ -9,9 +9,17 @@
|
|||
* published by the Free Software Foundation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* To prevent the compiler from emitting GOT-indirected (and thus absolute)
|
||||
* references to the section markers, override their visibility as 'hidden'
|
||||
*/
|
||||
#pragma GCC visibility push(hidden)
|
||||
#include <asm/sections.h>
|
||||
#pragma GCC visibility pop
|
||||
|
||||
#include <linux/efi.h>
|
||||
#include <asm/efi.h>
|
||||
#include <asm/sections.h>
|
||||
|
||||
#include "efistub.h"
|
||||
|
||||
|
|
|
@ -10,3 +10,8 @@
|
|||
#undef uninitialized_var
|
||||
#define uninitialized_var(x) x = *(&(x))
|
||||
#endif
|
||||
|
||||
/* same as gcc, this was present in clang-2.6 so we can assume it works
|
||||
* with any version that can compile the kernel
|
||||
*/
|
||||
#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
|
||||
|
|
|
@ -66,18 +66,22 @@
|
|||
|
||||
/*
|
||||
* Force always-inline if the user requests it so via the .config,
|
||||
* or if gcc is too old:
|
||||
* or if gcc is too old.
|
||||
* GCC does not warn about unused static inline functions for
|
||||
* -Wunused-function. This turns out to avoid the need for complex #ifdef
|
||||
* directives. Suppress the warning in clang as well by using "unused"
|
||||
* function attribute, which is redundant but not harmful for gcc.
|
||||
*/
|
||||
#if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) || \
|
||||
!defined(CONFIG_OPTIMIZE_INLINING) || (__GNUC__ < 4)
|
||||
#define inline inline __attribute__((always_inline)) notrace
|
||||
#define __inline__ __inline__ __attribute__((always_inline)) notrace
|
||||
#define __inline __inline __attribute__((always_inline)) notrace
|
||||
#define inline inline __attribute__((always_inline,unused)) notrace
|
||||
#define __inline__ __inline__ __attribute__((always_inline,unused)) notrace
|
||||
#define __inline __inline __attribute__((always_inline,unused)) notrace
|
||||
#else
|
||||
/* A lot of inline functions can cause havoc with function tracing */
|
||||
#define inline inline notrace
|
||||
#define __inline__ __inline__ notrace
|
||||
#define __inline __inline notrace
|
||||
#define inline inline __attribute__((unused)) notrace
|
||||
#define __inline__ __inline__ __attribute__((unused)) notrace
|
||||
#define __inline __inline __attribute__((unused)) notrace
|
||||
#endif
|
||||
|
||||
#define __always_inline inline __attribute__((always_inline))
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
#define __LINUX_KBUILD_H
|
||||
|
||||
#define DEFINE(sym, val) \
|
||||
asm volatile("\n->" #sym " %0 " #val : : "i" (val))
|
||||
asm volatile("\n.ascii \"->" #sym " %0 " #val "\"" : : "i" (val))
|
||||
|
||||
#define BLANK() asm volatile("\n->" : : )
|
||||
#define BLANK() asm volatile("\n.ascii \"->\"" : : )
|
||||
|
||||
#define OFFSET(sym, str, mem) \
|
||||
DEFINE(sym, offsetof(struct str, mem))
|
||||
|
||||
#define COMMENT(x) \
|
||||
asm volatile("\n->#" x)
|
||||
asm volatile("\n.ascii \"->#" x "\"")
|
||||
|
||||
#endif
|
||||
|
|
|
@ -125,13 +125,13 @@ extern void cleanup_module(void);
|
|||
|
||||
/* Each module must use one module_init(). */
|
||||
#define module_init(initfn) \
|
||||
static inline initcall_t __inittest(void) \
|
||||
static inline initcall_t __maybe_unused __inittest(void) \
|
||||
{ return initfn; } \
|
||||
int init_module(void) __attribute__((alias(#initfn)));
|
||||
|
||||
/* This is only required if you want to be unloadable. */
|
||||
#define module_exit(exitfn) \
|
||||
static inline exitcall_t __exittest(void) \
|
||||
static inline exitcall_t __maybe_unused __exittest(void) \
|
||||
{ return exitfn; } \
|
||||
void cleanup_module(void) __attribute__((alias(#exitfn)));
|
||||
|
||||
|
|
|
@ -58,8 +58,6 @@ obj-$(CONFIG_HAS_IOMEM) += iomap_copy.o devres.o
|
|||
obj-$(CONFIG_CHECK_SIGNATURE) += check_signature.o
|
||||
obj-$(CONFIG_DEBUG_LOCKING_API_SELFTESTS) += locking-selftest.o
|
||||
|
||||
GCOV_PROFILE_hweight.o := n
|
||||
CFLAGS_hweight.o = $(subst $(quote),,$(CONFIG_ARCH_HWEIGHT_CFLAGS))
|
||||
obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
|
||||
|
||||
obj-$(CONFIG_BTREE) += btree.o
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
* The Hamming Weight of a number is the total number of bits set in it.
|
||||
*/
|
||||
|
||||
#ifndef __HAVE_ARCH_SW_HWEIGHT
|
||||
unsigned int __sw_hweight32(unsigned int w)
|
||||
{
|
||||
#ifdef CONFIG_ARCH_HAS_FAST_MULTIPLIER
|
||||
|
@ -25,6 +26,7 @@ unsigned int __sw_hweight32(unsigned int w)
|
|||
#endif
|
||||
}
|
||||
EXPORT_SYMBOL(__sw_hweight32);
|
||||
#endif
|
||||
|
||||
unsigned int __sw_hweight16(unsigned int w)
|
||||
{
|
||||
|
@ -43,6 +45,7 @@ unsigned int __sw_hweight8(unsigned int w)
|
|||
}
|
||||
EXPORT_SYMBOL(__sw_hweight8);
|
||||
|
||||
#ifndef __HAVE_ARCH_SW_HWEIGHT
|
||||
unsigned long __sw_hweight64(__u64 w)
|
||||
{
|
||||
#if BITS_PER_LONG == 32
|
||||
|
@ -65,3 +68,4 @@ unsigned long __sw_hweight64(__u64 w)
|
|||
#endif
|
||||
}
|
||||
EXPORT_SYMBOL(__sw_hweight64);
|
||||
#endif
|
||||
|
|
|
@ -107,16 +107,30 @@ as-option = $(call try-run,\
|
|||
as-instr = $(call try-run,\
|
||||
printf "%b\n" "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))
|
||||
|
||||
# __cc-option
|
||||
# Usage: MY_CFLAGS += $(call __cc-option,$(CC),$(MY_CFLAGS),-march=winchip-c6,-march=i586)
|
||||
__cc-option = $(call try-run,\
|
||||
$(1) -Werror $(2) $(3) -c -x c /dev/null -o "$$TMP",$(3),$(4))
|
||||
|
||||
# Do not attempt to build with gcc plugins during cc-option tests.
|
||||
# (And this uses delayed resolution so the flags will be up to date.)
|
||||
CC_OPTION_CFLAGS = $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
|
||||
|
||||
# cc-option
|
||||
# Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
|
||||
|
||||
cc-option = $(call try-run,\
|
||||
$(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2))
|
||||
cc-option = $(call __cc-option, $(CC),\
|
||||
$(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS),$(1),$(2))
|
||||
|
||||
# hostcc-option
|
||||
# Usage: cflags-y += $(call hostcc-option,-march=winchip-c6,-march=i586)
|
||||
hostcc-option = $(call __cc-option, $(HOSTCC),\
|
||||
$(HOSTCFLAGS) $(HOST_EXTRACFLAGS),$(1),$(2))
|
||||
|
||||
# cc-option-yn
|
||||
# Usage: flag := $(call cc-option-yn,-march=winchip-c6)
|
||||
cc-option-yn = $(call try-run,\
|
||||
$(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n)
|
||||
$(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n)
|
||||
|
||||
# cc-option-align
|
||||
# Prefix align with either -falign or -malign
|
||||
|
@ -126,7 +140,7 @@ cc-option-align = $(subst -functions=0,,\
|
|||
# cc-disable-warning
|
||||
# Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable)
|
||||
cc-disable-warning = $(call try-run,\
|
||||
$(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
|
||||
$(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
|
||||
|
||||
# cc-name
|
||||
# Expands to either gcc or clang
|
||||
|
|
|
@ -174,6 +174,14 @@ cmd_cc_symtypes_c = \
|
|||
$(obj)/%.symtypes : $(src)/%.c FORCE
|
||||
$(call cmd,cc_symtypes_c)
|
||||
|
||||
# LLVM assembly
|
||||
# Generate .ll files from .c
|
||||
quiet_cmd_cc_ll_c = CC $(quiet_modtag) $@
|
||||
cmd_cc_ll_c = $(CC) $(c_flags) -emit-llvm -S -o $@ $<
|
||||
|
||||
$(obj)/%.ll: $(src)/%.c FORCE
|
||||
$(call if_changed_dep,cc_ll_c)
|
||||
|
||||
# C (.c) files
|
||||
# The C file is compiled and updated dependency information is generated.
|
||||
# (See cmd_cc_o_c + relevant part of rule_cc_o_c)
|
||||
|
|
|
@ -61,7 +61,6 @@ ifeq ($(cc-name),clang)
|
|||
KBUILD_CFLAGS += $(call cc-disable-warning, initializer-overrides)
|
||||
KBUILD_CFLAGS += $(call cc-disable-warning, unused-value)
|
||||
KBUILD_CFLAGS += $(call cc-disable-warning, format)
|
||||
KBUILD_CFLAGS += $(call cc-disable-warning, unknown-warning-option)
|
||||
KBUILD_CFLAGS += $(call cc-disable-warning, sign-compare)
|
||||
KBUILD_CFLAGS += $(call cc-disable-warning, format-zero-length)
|
||||
KBUILD_CFLAGS += $(call cc-disable-warning, uninitialized)
|
||||
|
|
|
@ -394,3 +394,34 @@ quiet_cmd_xzmisc = XZMISC $@
|
|||
cmd_xzmisc = (cat $(filter-out FORCE,$^) | \
|
||||
xz --check=crc32 --lzma2=dict=1MiB) > $@ || \
|
||||
(rm -f $@ ; false)
|
||||
|
||||
# ASM offsets
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# Default sed regexp - multiline due to syntax constraints
|
||||
#
|
||||
# Use [:space:] because LLVM's integrated assembler inserts <tab> around
|
||||
# the .ascii directive whereas GCC keeps the <space> as-is.
|
||||
define sed-offsets
|
||||
's:^[[:space:]]*\.ascii[[:space:]]*"\(.*\)".*:\1:; \
|
||||
/^->/{s:->#\(.*\):/* \1 */:; \
|
||||
s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
|
||||
s:->::; p;}'
|
||||
endef
|
||||
|
||||
# Use filechk to avoid rebuilds when a header changes, but the resulting file
|
||||
# does not
|
||||
define filechk_offsets
|
||||
(set -e; \
|
||||
echo "#ifndef $2"; \
|
||||
echo "#define $2"; \
|
||||
echo "/*"; \
|
||||
echo " * DO NOT MODIFY."; \
|
||||
echo " *"; \
|
||||
echo " * This file was generated by Kbuild"; \
|
||||
echo " */"; \
|
||||
echo ""; \
|
||||
sed -ne $(sed-offsets); \
|
||||
echo ""; \
|
||||
echo "#endif" )
|
||||
endef
|
||||
|
|
|
@ -5,32 +5,8 @@ modpost-objs := modpost.o file2alias.o sumversion.o
|
|||
|
||||
devicetable-offsets-file := devicetable-offsets.h
|
||||
|
||||
define sed-y
|
||||
"/^->/{s:->#\(.*\):/* \1 */:; \
|
||||
s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
|
||||
s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
|
||||
s:->::; p;}"
|
||||
endef
|
||||
|
||||
quiet_cmd_offsets = GEN $@
|
||||
define cmd_offsets
|
||||
(set -e; \
|
||||
echo "#ifndef __DEVICETABLE_OFFSETS_H__"; \
|
||||
echo "#define __DEVICETABLE_OFFSETS_H__"; \
|
||||
echo "/*"; \
|
||||
echo " * DO NOT MODIFY."; \
|
||||
echo " *"; \
|
||||
echo " * This file was generated by Kbuild"; \
|
||||
echo " *"; \
|
||||
echo " */"; \
|
||||
echo ""; \
|
||||
sed -ne $(sed-y) $<; \
|
||||
echo ""; \
|
||||
echo "#endif" ) > $@
|
||||
endef
|
||||
|
||||
$(obj)/$(devicetable-offsets-file): $(obj)/devicetable-offsets.s
|
||||
$(call if_changed,offsets)
|
||||
$(obj)/$(devicetable-offsets-file): $(obj)/devicetable-offsets.s FORCE
|
||||
$(call filechk,offsets,__DEVICETABLE_OFFSETS_H__)
|
||||
|
||||
targets += $(devicetable-offsets-file) devicetable-offsets.s
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue