Merge branch 'tracking-llvm' into merge-linux-linaro-core-tracking

This commit is contained in:
Andrey Konovalov
2014-04-02 22:24:29 +04:00
51 changed files with 463 additions and 215 deletions

View File

@@ -1,5 +1,6 @@
*.a
*.aux
*.bc
*.bin
*.bz2
*.cis
@@ -21,6 +22,7 @@
*.i
*.jpeg
*.ko
*.ll
*.log
*.lst
*.lzma
@@ -35,6 +37,7 @@
*.out
*.patch
*.pdf
*.plist
*.png
*.pot
*.ps

View File

@@ -247,6 +247,11 @@ HOSTCXX = g++
HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
HOSTCXXFLAGS = -O2
ifeq ($(shell $(HOSTCC) -v 2>&1 | grep -c "clang version"), 1)
HOSTCFLAGS += -Wno-unused-value -Wno-unused-parameter \
-Wno-missing-field-initializers -fno-delete-null-pointer-checks
endif
# Decide whether to build built-in, modular, or both.
# Normally, just do built-in.
@@ -323,6 +328,14 @@ endif
export quiet Q KBUILD_VERBOSE
ifneq ($(CC),)
ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang version"), 1)
COMPILER := clang
else
COMPILER := gcc
endif
export COMPILER
endif
# Look for make include files relative to root of kernel src
MAKEFLAGS += --include-dir=$(srctree)
@@ -382,10 +395,11 @@ KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
-fno-strict-aliasing -fno-common \
-Werror-implicit-function-declaration \
-Wno-format-security \
-fno-delete-null-pointer-checks
$(call cc-option,-no-integrated-as,) \
$(call cc-option,-fno-delete-null-pointer-checks,)
KBUILD_AFLAGS_KERNEL :=
KBUILD_CFLAGS_KERNEL :=
KBUILD_AFLAGS := -D__ASSEMBLY__
KBUILD_AFLAGS := -D__ASSEMBLY__ $(call cc-option,-no-integrated-as,)
KBUILD_AFLAGS_MODULE := -DMODULE
KBUILD_CFLAGS_MODULE := -DMODULE
KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds
@@ -622,9 +636,24 @@ endif
endif
KBUILD_CFLAGS += $(stackp-flag)
ifeq ($(COMPILER),clang)
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)
# 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
# source of a reference will be _MergedGlobals and not on of the whitelisted names.
# See modpost pattern 2
KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,)
else
# This warning generated too much noise in a regular build.
# Use make W=1 to enable this warning (see scripts/Makefile.build)
KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
endif
ifdef CONFIG_FRAME_POINTER
KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
@@ -641,7 +670,7 @@ endif
ifdef CONFIG_DEBUG_INFO
KBUILD_CFLAGS += -g
KBUILD_AFLAGS += -Wa,--gdwarf-2
KBUILD_AFLAGS += -Wa,-gdwarf-2
endif
ifdef CONFIG_DEBUG_INFO_REDUCED

View File

@@ -23,6 +23,14 @@ OBJCOPYFLAGS :=-O binary -R .comment -S
GZFLAGS :=-9
#KBUILD_CFLAGS +=-pipe
ifeq ($(COMPILER),clang)
# Clang options
ifneq ($(CROSS_COMPILE),)
KBUILD_CPPFLAGS += -target $(CROSS_COMPILE:-=)
endif
KBUILD_CFLAGS += -fno-builtin -Wno-asm-operand-widths -Xassembler -mno-warn-deprecated
endif
# Never generate .eh_frame
KBUILD_CFLAGS += $(call cc-option,-fno-dwarf2-cfi-asm)
@@ -41,11 +49,11 @@ KBUILD_CFLAGS +=-fno-omit-frame-pointer -mapcs -mno-sched-prolog
endif
ifeq ($(CONFIG_CPU_BIG_ENDIAN),y)
KBUILD_CPPFLAGS += -mbig-endian
KBUILD_CPPFLAGS += $(call cc-option,-mbig-endian,)
AS += -EB
LD += -EB
else
KBUILD_CPPFLAGS += -mlittle-endian
KBUILD_CPPFLAGS += $(call cc-option,-mlittle-endian,)
AS += -EL
LD += -EL
endif
@@ -96,7 +104,7 @@ tune-$(CONFIG_CPU_V6K) =$(call cc-option,-mtune=arm1136j-s,-mtune=strongarm)
tune-y := $(tune-y)
ifeq ($(CONFIG_AEABI),y)
CFLAGS_ABI :=-mabi=aapcs-linux -mno-thumb-interwork -mfpu=vfp
CFLAGS_ABI :=-mabi=aapcs-linux $(call cc-option,-mno-thumb-interwork,) -mfpu=vfp
else
CFLAGS_ABI :=$(call cc-option,-mapcs-32,-mabi=apcs-gnu) $(call cc-option,-mno-thumb-interwork,)
endif
@@ -120,7 +128,7 @@ AFLAGS_ISA :=$(CFLAGS_ISA)
endif
# Need -Uarm for gcc < 3.x
KBUILD_CFLAGS +=$(CFLAGS_ABI) $(CFLAGS_ISA) $(arch-y) $(tune-y) $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,)) -msoft-float -Uarm
KBUILD_CFLAGS +=$(CFLAGS_ABI) $(CFLAGS_ISA) $(arch-y) $(tune-y) $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,)) -msoft-float $(call cc-option, -Uarm,)
KBUILD_AFLAGS +=$(CFLAGS_ABI) $(AFLAGS_ISA) $(arch-y) $(tune-y) -include asm/unified.h -msoft-float
CHECKFLAGS += -D__arm__

View File

@@ -121,7 +121,7 @@ ORIG_CFLAGS := $(KBUILD_CFLAGS)
KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS))
endif
ccflags-y := -fpic -mno-single-pic-base -fno-builtin -I$(obj)
ccflags-y := -fpic $(call cc-option,-mno-single-pic-base,) -fno-builtin -I$(obj)
asflags-y := -DZIMAGE
# Supply kernel BSS size to the decompressor via a linker symbol.

View File

@@ -11,5 +11,37 @@
*/
#define __asmeq(x, y) ".ifnc " x "," y " ; .err ; .endif\n\t"
#if defined(CONFIG_SMP) && !defined(CONFIG_CPU_V6)
/*
* Read TPIDRPRW.
* GCC requires a workaround as it does not treat a "memory" clobber on a
* non-volatile asm block as a side-effect.
* We want to allow caching the value, so for GCC avoid using volatile and
* instead use a fake stack read to hazard against barrier().
*/
#if defined(__clang__)
static inline unsigned long read_TPIDRPRW(void)
{
unsigned long off;
/*
* Read TPIDRPRW.
*/
asm("mrc p15, 0, %0, c13, c0, 4" : "=r" (off) : : "memory");
return off;
}
#else
static inline unsigned long read_TPIDRPRW(void)
{
unsigned long off;
register unsigned long *sp asm ("sp");
asm("mrc p15, 0, %0, c13, c0, 4" : "=r" (off) : "Q" (*sp));
return off;
}
#endif
#endif
#endif /* __ASM_ARM_COMPILER_H */

View File

@@ -45,7 +45,7 @@ void *return_address(unsigned int);
#else
extern inline void *return_address(unsigned int level)
static inline void *return_address(unsigned int level)
{
return NULL;
}

View File

@@ -130,22 +130,22 @@
#endif
#ifndef __ASSEMBLER__
extern inline void nop_flush_icache_all(void) { }
extern inline void nop_flush_kern_cache_all(void) { }
extern inline void nop_flush_kern_cache_louis(void) { }
extern inline void nop_flush_user_cache_all(void) { }
extern inline void nop_flush_user_cache_range(unsigned long a,
static inline void nop_flush_icache_all(void) { }
static inline void nop_flush_kern_cache_all(void) { }
static inline void nop_flush_kern_cache_louis(void) { }
static inline void nop_flush_user_cache_all(void) { }
static inline void nop_flush_user_cache_range(unsigned long a,
unsigned long b, unsigned int c) { }
extern inline void nop_coherent_kern_range(unsigned long a, unsigned long b) { }
extern inline int nop_coherent_user_range(unsigned long a,
static inline void nop_coherent_kern_range(unsigned long a, unsigned long b) { }
static inline int nop_coherent_user_range(unsigned long a,
unsigned long b) { return 0; }
extern inline void nop_flush_kern_dcache_area(void *a, size_t s) { }
static inline void nop_flush_kern_dcache_area(void *a, size_t s) { }
extern inline void nop_dma_flush_range(const void *a, const void *b) { }
static inline void nop_dma_flush_range(const void *a, const void *b) { }
extern inline void nop_dma_map_area(const void *s, size_t l, int f) { }
extern inline void nop_dma_unmap_area(const void *s, size_t l, int f) { }
static inline void nop_dma_map_area(const void *s, size_t l, int f) { }
static inline void nop_dma_unmap_area(const void *s, size_t l, int f) { }
#endif
#ifndef MULTI_CACHE

View File

@@ -27,21 +27,10 @@ static inline void set_my_cpu_offset(unsigned long off)
asm volatile("mcr p15, 0, %0, c13, c0, 4" : : "r" (off) : "memory");
}
static inline unsigned long __my_cpu_offset(void)
{
unsigned long off;
register unsigned long *sp asm ("sp");
#include "asm/compiler.h"
/*
* Read TPIDRPRW.
* We want to allow caching the value, so avoid using volatile and
* instead use a fake stack read to hazard against barrier().
*/
asm("mrc p15, 0, %0, c13, c0, 4" : "=r" (off) : "Q" (*sp));
#define __my_cpu_offset read_TPIDRPRW()
return off;
}
#define __my_cpu_offset __my_cpu_offset()
#else
#define set_my_cpu_offset(x) do {} while(0)

View File

@@ -144,9 +144,9 @@ static inline unsigned long user_stack_pointer(struct pt_regs *regs)
return regs->ARM_sp;
}
#define current_pt_regs(void) ({ \
register unsigned long sp asm ("sp"); \
(struct pt_regs *)((sp | (THREAD_SIZE - 1)) - 7) - 1; \
#define current_pt_regs(void) ({ \
(struct pt_regs *)(((unsigned long)(__builtin_stack_pointer()) \
| (THREAD_SIZE - 1)) - 7) - 1; \
})
#endif /* __ASSEMBLY__ */

View File

@@ -99,6 +99,25 @@ struct thread_info {
#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)
/*
* how to get the current stack pointer in C
*/
#if defined(CONFIG_BUILTIN_STACK_POINTER)
/* compiler has __builtin_stack_pointer support already */
#elif defined(__clang__)
#define __builtin_stack_pointer() ({ \
unsigned long current_sp; \
asm ("mov %0, sp" : "=r" (current_sp)); \
current_sp; \
})
#define current_stack_pointer __builtin_stack_pointer()
#else /* gcc */
register unsigned long current_stack_pointer asm ("sp");
#define __builtin_stack_pointer() current_stack_pointer
#endif
/*
* how to get the thread information struct from C
*/
@@ -106,8 +125,9 @@ static inline struct thread_info *current_thread_info(void) __attribute_const__;
static inline struct thread_info *current_thread_info(void)
{
register unsigned long sp asm ("sp");
return (struct thread_info *)(sp & ~(THREAD_SIZE - 1));
return (struct thread_info *)
((u32)(__builtin_stack_pointer())
& ~(THREAD_SIZE - 1));
}
#define thread_saved_pc(tsk) \

View File

@@ -39,13 +39,12 @@ void *return_address(unsigned int level)
{
struct return_address_data data;
struct stackframe frame;
register unsigned long current_sp asm ("sp");
data.level = level + 2;
data.addr = NULL;
frame.fp = (unsigned long)__builtin_frame_address(0);
frame.sp = current_sp;
frame.sp = __builtin_stack_pointer();
frame.lr = (unsigned long)__builtin_return_address(0);
frame.pc = (unsigned long)return_address;
@@ -63,11 +62,6 @@ void *return_address(unsigned int level)
#warning "TODO: return_address should use unwind tables"
#endif
void *return_address(unsigned int level)
{
return NULL;
}
#endif /* if defined(CONFIG_FRAME_POINTER) && !defined(CONFIG_ARM_UNWIND) / else */
EXPORT_SYMBOL_GPL(return_address);

View File

@@ -109,11 +109,9 @@ void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
frame.pc = thread_saved_pc(tsk);
#endif
} else {
register unsigned long current_sp asm ("sp");
data.no_sched_functions = 0;
frame.fp = (unsigned long)__builtin_frame_address(0);
frame.sp = current_sp;
frame.sp = __builtin_stack_pointer();
frame.lr = (unsigned long)__builtin_return_address(0);
frame.pc = (unsigned long)save_stack_trace_tsk;
}

View File

@@ -31,7 +31,7 @@
#warning Your compiler does not have EABI support.
#warning ARM unwind is known to compile only with EABI compilers.
#warning Change compiler or disable ARM_UNWIND option.
#elif (__GNUC__ == 4 && __GNUC_MINOR__ <= 2)
#elif (__GNUC__ == 4 && __GNUC_MINOR__ <= 2) && !defined(__clang__)
#warning Your compiler is too buggy; it is known to not compile ARM unwind support.
#warning Change compiler or disable ARM_UNWIND option.
#endif
@@ -408,7 +408,6 @@ int unwind_frame(struct stackframe *frame)
void unwind_backtrace(struct pt_regs *regs, struct task_struct *tsk)
{
struct stackframe frame;
register unsigned long current_sp asm ("sp");
pr_debug("%s(regs = %p tsk = %p)\n", __func__, regs, tsk);
@@ -424,7 +423,7 @@ void unwind_backtrace(struct pt_regs *regs, struct task_struct *tsk)
? regs->ARM_pc : regs->ARM_lr;
} else if (tsk == current) {
frame.fp = (unsigned long)__builtin_frame_address(0);
frame.sp = current_sp;
frame.sp = __builtin_stack_pointer();
frame.lr = (unsigned long)__builtin_return_address(0);
frame.pc = (unsigned long)unwind_backtrace;
} else {

View File

@@ -15,6 +15,10 @@ lib-y := backtrace.o changebit.o csumipv6.o csumpartial.o \
io-readsb.o io-writesb.o io-readsl.o io-writesl.o \
call_with_stack.o bswapsdi2.o
ifeq ($(COMPILER),clang)
lib-y += eabi.o
endif
mmu-y := clear_user.o copy_page.o getuser.o putuser.o
# the code in uaccess.S is not preemption safe and

32
arch/arm/lib/eabi.c Normal file
View File

@@ -0,0 +1,32 @@
/*
* linux/lib/eabi.c
*
* Copyright (C) 2012 Mark Charlebois
*/
/*
* EABI routines
*/
#include <linux/types.h>
#include <linux/string.h>
#include <linux/ctype.h>
#include <linux/export.h>
void __aeabi_memcpy(void *dest, const void *src, size_t n)
{
(void)memcpy(dest, src, n);
}
EXPORT_SYMBOL(__aeabi_memcpy);
void __aeabi_memmove(void *dest, const void *src, size_t n)
{
(void)memmove(dest, src, n);
}
EXPORT_SYMBOL(__aeabi_memmove);
void __aeabi_memset(void *s, size_t n, int c)
{
(void)memset(s, c, n);
}
EXPORT_SYMBOL(__aeabi_memset);

View File

@@ -19,13 +19,20 @@ LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
KBUILD_DEFCONFIG := defconfig
KBUILD_CFLAGS += -mgeneral-regs-only
ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
KBUILD_CPPFLAGS += -mbig-endian
ifeq ($(COMPILER),clang)
# Clang options
KBUILD_CPPFLAGS += $(call cc-option,-target $(CROSS_COMPILE:-=),)
KBUILD_CFLAGS += $(call cc-option,-fno-builtin,)
KBUILD_CFLAGS += $(call cc-disable-warning,asm-operand-widths)
endif
KBUILD_CFLAGS += $(call cc-option,-mgeneral-regs-only,)
ifeq ($(CONFIG_CPU_BG_ENDIAN), y)
KBUILD_CPPFLAGS += $(call cc-option,-mbig-endian,)
AS += -EB
LD += -EB
else
KBUILD_CPPFLAGS += -mlittle-endian
KBUILD_CPPFLAGS += $(call cc-option,-mlittle-endian,)
AS += -EL
LD += -EL
endif

View File

@@ -37,19 +37,19 @@ void arch_timer_reg_write_cp15(int access, enum arch_timer_reg reg, u32 val)
if (access == ARCH_TIMER_PHYS_ACCESS) {
switch (reg) {
case ARCH_TIMER_REG_CTRL:
asm volatile("msr cntp_ctl_el0, %0" : : "r" (val));
asm volatile("msr cntp_ctl_el0, %0" : : "r" ((u64)val));
break;
case ARCH_TIMER_REG_TVAL:
asm volatile("msr cntp_tval_el0, %0" : : "r" (val));
asm volatile("msr cntp_tval_el0, %0" : : "r" ((u64)val));
break;
}
} else if (access == ARCH_TIMER_VIRT_ACCESS) {
switch (reg) {
case ARCH_TIMER_REG_CTRL:
asm volatile("msr cntv_ctl_el0, %0" : : "r" (val));
asm volatile("msr cntv_ctl_el0, %0" : : "r" ((u64)val));
break;
case ARCH_TIMER_REG_TVAL:
asm volatile("msr cntv_tval_el0, %0" : : "r" (val));
asm volatile("msr cntv_tval_el0, %0" : : "r" ((u64)val));
break;
}
}
@@ -60,7 +60,7 @@ void arch_timer_reg_write_cp15(int access, enum arch_timer_reg reg, u32 val)
static __always_inline
u32 arch_timer_reg_read_cp15(int access, enum arch_timer_reg reg)
{
u32 val;
u64 val;
if (access == ARCH_TIMER_PHYS_ACCESS) {
switch (reg) {
@@ -82,7 +82,7 @@ u32 arch_timer_reg_read_cp15(int access, enum arch_timer_reg reg)
}
}
return val;
return (u32)val;
}
static inline u32 arch_timer_get_cntfrq(void)

View File

@@ -64,6 +64,7 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
: "memory");
break;
default:
ret = 0;
BUILD_BUG();
}
@@ -141,6 +142,7 @@ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
break;
default:
res = 0;
BUILD_BUG();
}

View File

@@ -108,7 +108,7 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
int ret = 0;
u32 val, tmp;
if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
if (uaddr == 0 || !access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
return -EFAULT;
asm volatile("// futex_atomic_cmpxchg_inatomic\n"

View File

@@ -68,6 +68,15 @@ struct thread_info {
#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)
/*
* how to get the current stack pointer from C
*/
#define current_stack_pointer ({ \
unsigned long current_sp; \
asm ("mov %0, sp" : "=r" (current_sp)); \
current_sp; \
})
/*
* how to get the thread information struct from C
*/
@@ -75,8 +84,9 @@ static inline struct thread_info *current_thread_info(void) __attribute_const__;
static inline struct thread_info *current_thread_info(void)
{
register unsigned long sp asm ("sp");
return (struct thread_info *)(sp & ~(THREAD_SIZE - 1));
return (struct thread_info *)
((u64)(__builtin_frame_address(0))
& ~(THREAD_SIZE - 1));
}
#define thread_saved_pc(tsk) \

View File

@@ -93,7 +93,7 @@ static inline void set_fs(mm_segment_t fs)
__chk_user_ptr(addr); \
asm("adds %1, %1, %3; ccmp %1, %4, #2, cc; cset %0, cc" \
: "=&r" (flag), "=&r" (roksum) \
: "1" (addr), "Ir" (size), \
: "1" (addr), "r" ((u64)size), \
"r" (current_thread_info()->addr_limit) \
: "cc"); \
flag; \

View File

@@ -52,15 +52,15 @@ static void mdscr_write(u32 mdscr)
{
unsigned long flags;
local_dbg_save(flags);
asm volatile("msr mdscr_el1, %0" :: "r" (mdscr));
asm volatile("msr mdscr_el1, %0" :: "r" ((u64)mdscr));
local_dbg_restore(flags);
}
static u32 mdscr_read(void)
{
u32 mdscr;
u64 mdscr;
asm volatile("mrs %0, mdscr_el1" : "=r" (mdscr));
return mdscr;
return (u32)mdscr;
}
/*
@@ -136,7 +136,7 @@ void disable_debug_monitors(enum debug_el el)
*/
static void clear_os_lock(void *unused)
{
asm volatile("msr oslar_el1, %0" : : "r" (0));
asm volatile("msr oslar_el1, %0" : : "r" ((u64)0));
isb();
}

View File

@@ -844,16 +844,16 @@ static const unsigned armv8_pmuv3_perf_cache_map[PERF_COUNT_HW_CACHE_MAX]
static inline u32 armv8pmu_pmcr_read(void)
{
u32 val;
u64 val;
asm volatile("mrs %0, pmcr_el0" : "=r" (val));
return val;
return (u32)val;
}
static inline void armv8pmu_pmcr_write(u32 val)
{
val &= ARMV8_PMCR_MASK;
isb();
asm volatile("msr pmcr_el0, %0" :: "r" (val));
asm volatile("msr pmcr_el0, %0" :: "r" ((u64)val));
}
static inline int armv8pmu_has_overflowed(u32 pmovsr)
@@ -893,7 +893,7 @@ static inline int armv8pmu_select_counter(int idx)
}
counter = ARMV8_IDX_TO_COUNTER(idx);
asm volatile("msr pmselr_el0, %0" :: "r" (counter));
asm volatile("msr pmselr_el0, %0" :: "r" ((u64)counter));
isb();
return idx;
@@ -901,7 +901,7 @@ static inline int armv8pmu_select_counter(int idx)
static inline u32 armv8pmu_read_counter(int idx)
{
u32 value = 0;
u64 value = 0;
if (!armv8pmu_counter_valid(idx))
pr_err("CPU%u reading wrong counter %d\n",
@@ -911,7 +911,7 @@ static inline u32 armv8pmu_read_counter(int idx)
else if (armv8pmu_select_counter(idx) == idx)
asm volatile("mrs %0, pmxevcntr_el0" : "=r" (value));
return value;
return (u32)value;
}
static inline void armv8pmu_write_counter(int idx, u32 value)
@@ -920,16 +920,16 @@ static inline void armv8pmu_write_counter(int idx, u32 value)
pr_err("CPU%u writing wrong counter %d\n",
smp_processor_id(), idx);
else if (idx == ARMV8_IDX_CYCLE_COUNTER)
asm volatile("msr pmccntr_el0, %0" :: "r" (value));
asm volatile("msr pmccntr_el0, %0" :: "r" ((u64)value));
else if (armv8pmu_select_counter(idx) == idx)
asm volatile("msr pmxevcntr_el0, %0" :: "r" (value));
asm volatile("msr pmxevcntr_el0, %0" :: "r" ((u64)value));
}
static inline void armv8pmu_write_evtype(int idx, u32 val)
{
if (armv8pmu_select_counter(idx) == idx) {
val &= ARMV8_EVTYPE_MASK;
asm volatile("msr pmxevtyper_el0, %0" :: "r" (val));
asm volatile("msr pmxevtyper_el0, %0" :: "r" ((u64)val));
}
}
@@ -944,7 +944,7 @@ static inline int armv8pmu_enable_counter(int idx)
}
counter = ARMV8_IDX_TO_COUNTER(idx);
asm volatile("msr pmcntenset_el0, %0" :: "r" (BIT(counter)));
asm volatile("msr pmcntenset_el0, %0" :: "r" ((u64)BIT(counter)));
return idx;
}
@@ -959,7 +959,7 @@ static inline int armv8pmu_disable_counter(int idx)
}
counter = ARMV8_IDX_TO_COUNTER(idx);
asm volatile("msr pmcntenclr_el0, %0" :: "r" (BIT(counter)));
asm volatile("msr pmcntenclr_el0, %0" :: "r" ((u64)BIT(counter)));
return idx;
}
@@ -974,7 +974,7 @@ static inline int armv8pmu_enable_intens(int idx)
}
counter = ARMV8_IDX_TO_COUNTER(idx);
asm volatile("msr pmintenset_el1, %0" :: "r" (BIT(counter)));
asm volatile("msr pmintenset_el1, %0" :: "r" ((u64)BIT(counter)));
return idx;
}
@@ -989,17 +989,17 @@ static inline int armv8pmu_disable_intens(int idx)
}
counter = ARMV8_IDX_TO_COUNTER(idx);
asm volatile("msr pmintenclr_el1, %0" :: "r" (BIT(counter)));
asm volatile("msr pmintenclr_el1, %0" :: "r" ((u64)BIT(counter)));
isb();
/* Clear the overflow flag in case an interrupt is pending. */
asm volatile("msr pmovsclr_el0, %0" :: "r" (BIT(counter)));
asm volatile("msr pmovsclr_el0, %0" :: "r" ((u64)BIT(counter)));
isb();
return idx;
}
static inline u32 armv8pmu_getreset_flags(void)
{
u32 value;
u64 value;
/* Read */
asm volatile("mrs %0, pmovsclr_el0" : "=r" (value));
@@ -1008,7 +1008,7 @@ static inline u32 armv8pmu_getreset_flags(void)
value &= ARMV8_OVSR_MASK;
asm volatile("msr pmovsclr_el0, %0" :: "r" (value));
return value;
return (u32)value;
}
static void armv8pmu_enable_event(struct hw_perf_event *hwc, int idx)
@@ -1217,7 +1217,7 @@ static void armv8pmu_reset(void *info)
armv8pmu_pmcr_write(ARMV8_PMCR_P | ARMV8_PMCR_C);
/* Disable access from userspace. */
asm volatile("msr pmuserenr_el0, %0" :: "r" (0));
asm volatile("msr pmuserenr_el0, %0" :: "r" ((u64)0));
}
static int armv8_pmuv3_map_event(struct perf_event *event)

View File

@@ -111,10 +111,9 @@ void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
frame.sp = thread_saved_sp(tsk);
frame.pc = thread_saved_pc(tsk);
} else {
register unsigned long current_sp asm("sp");
data.no_sched_functions = 0;
frame.fp = (unsigned long)__builtin_frame_address(0);
frame.sp = current_sp;
frame.sp = current_stack_pointer;
frame.pc = (unsigned long)save_stack_trace_tsk;
}

View File

@@ -132,7 +132,6 @@ static void dump_instr(const char *lvl, struct pt_regs *regs)
static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
{
struct stackframe frame;
const register unsigned long current_sp asm ("sp");
pr_debug("%s(regs = %p tsk = %p)\n", __func__, regs, tsk);
@@ -145,7 +144,7 @@ static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
frame.pc = regs->pc;
} else if (tsk == current) {
frame.fp = (unsigned long)__builtin_frame_address(0);
frame.sp = current_sp;
frame.sp = current_stack_pointer;
frame.pc = (unsigned long)dump_backtrace;
} else {
/*
@@ -341,6 +340,15 @@ void __pgd_error(const char *file, int line, unsigned long val)
printk("%s:%d: bad pgd %016lx.\n", file, line, val);
}
void abort(void)
{
BUG();
/* if that doesn't kill us, halt */
panic("Oops failed to kill thread");
}
EXPORT_SYMBOL(abort);
void __init trap_init(void)
{
return;

View File

@@ -2,3 +2,7 @@ lib-y := bitops.o clear_user.o delay.o copy_from_user.o \
copy_to_user.o copy_in_user.o copy_page.o \
clear_page.o memchr.o memcpy.o memmove.o memset.o \
strchr.o strrchr.o
ifeq ($(COMPILER),clang)
lib-y += eabi.o
endif

32
arch/arm64/lib/eabi.c Normal file
View File

@@ -0,0 +1,32 @@
/*
* linux/lib/eabi.c
*
* Copyright (C) 2012 Mark Charlebois
*/
/*
* EABI routines
*/
#include <linux/types.h>
#include <linux/string.h>
#include <linux/ctype.h>
#include <linux/export.h>
void __aeabi_memcpy(void *dest, const void *src, size_t n)
{
(void)memcpy(dest, src, n);
}
EXPORT_SYMBOL(__aeabi_memcpy);
void __aeabi_memmove(void *dest, const void *src, size_t n)
{
(void)memmove(dest, src, n);
}
EXPORT_SYMBOL(__aeabi_memmove);
void __aeabi_memset(void *s, size_t n, int c)
{
(void)memset(s, c, n);
}
EXPORT_SYMBOL(__aeabi_memset);

View File

@@ -98,7 +98,7 @@ static int __init early_cachepolicy(char *p)
*/
asm volatile(
" mrs %0, mair_el1\n"
" bfi %0, %1, #%2, #8\n"
" bfi %0, %1, %2, #8\n"
" msr mair_el1, %0\n"
" isb\n"
: "=&r" (tmp)

View File

@@ -19,6 +19,7 @@ endif
# attempt to ensure that our asm(".code16gcc") is first in the asm
# output.
CODE16GCC_CFLAGS := -m32 -include $(srctree)/arch/x86/boot/code16gcc.h \
$(call cc-option, -no-integrated-as,)\
$(call cc-option, -fno-toplevel-reorder,\
$(call cc-option, -fno-unit-at-a-time))
M16_CFLAGS := $(call cc-option, -m16, $(CODE16GCC_CFLAGS))
@@ -108,7 +109,7 @@ else
# this works around some issues with generating unwind tables in older gccs
# newer gccs do it by default
KBUILD_CFLAGS += -maccumulate-outgoing-args
KBUILD_CFLAGS += $(call cc-option,-maccumulate-outgoing-args)
endif
# Make sure compiler does not have buggy stack-protector support.

View File

@@ -55,6 +55,15 @@ KBUILD_CFLAGS := $(USERINCLUDE) $(REALMODE_CFLAGS) -D_SETUP
KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
GCOV_PROFILE := n
# For clang we need to rely on no-integrated-as for .code16 . We use gas.
ifeq ($(COMPILER),clang)
KBUILD_CFLAGS += -Wno-unused-value -Wno-unused-parameter -mno-sse \
$(call cc-option,-no-integrated-as,)
KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
endif
$(obj)/bzImage: asflags-y := $(SVGA_MODE)
quiet_cmd_image = BUILD $@

View File

@@ -231,8 +231,10 @@ void *copy_from_gs(void *dst, addr_t src, size_t len);
void *memcpy(void *dst, void *src, size_t len);
void *memset(void *dst, int c, size_t len);
#ifndef __clang__ /* PR18415 */
#define memcpy(d,s,l) __builtin_memcpy(d,s,l)
#define memset(d,c,l) __builtin_memset(d,c,l)
#endif
/* a20.c */
int enable_a20(void);

View File

@@ -63,8 +63,13 @@ static int detect_memory_e820(void)
count = 0;
break;
}
#ifdef __clang__
/* PR18415 */
memcpy(desc, &buf, sizeof(*desc));
desc++;
#else
*desc++ = buf;
#endif
count++;
} while (ireg.ebx && count < ARRAY_SIZE(boot_params.e820_map));

View File

@@ -163,10 +163,10 @@ struct thread_info {
*/
#ifndef __ASSEMBLY__
#define current_stack_pointer ({ \
unsigned long sp; \
asm("mov %%esp,%0" : "=g" (sp)); \
sp; \
#define current_stack_pointer ({ \
register unsigned long sp asm("esp") __used; \
asm("" : "=r" (sp)); \
sp; \
})
/* how to get the thread information struct from C */

View File

@@ -19,6 +19,14 @@ wakeup-objs += video-vga.o
wakeup-objs += video-vesa.o
wakeup-objs += video-bios.o
# For clang, we need to enforce not to use the integrated assembler
AFLAGS_wakeup_asm.o = $(call cc-option,-no-integrated-as,)
AFLAGS_bioscall.o = $(call cc-option,-no-integrated-as,)
AFLAGS_copy.o = $(call cc-option,-no-integrated-as,)
AFLAGS_trampoline_32.o = $(call cc-option,-no-integrated-as,)
AFLAGS_trampoline_64.o = $(call cc-option,-no-integrated-as,)
AFLAGS_reboot_32.o = $(call cc-option,-no-integrated-as,)
realmode-y += header.o
realmode-y += trampoline_$(BITS).o
realmode-y += stack.o

View File

@@ -4,7 +4,7 @@
#ifndef CONFIG_X86_32
/*XXX: we need them because they would be exported by x86_64 */
#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __GNUC__ > 4
#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __GNUC__ > 4 || defined(__clang__)
EXPORT_SYMBOL(memcpy);
#else
EXPORT_SYMBOL(__memcpy);

View File

@@ -52,20 +52,19 @@ static int hmac_setkey(struct crypto_shash *parent,
struct hmac_ctx *ctx = align_ptr(opad + ss,
crypto_tfm_ctx_alignment());
struct crypto_shash *hash = ctx->hash;
struct {
struct shash_desc shash;
char ctx[crypto_shash_descsize(hash)];
} desc;
char desc[sizeof(struct shash_desc) + crypto_shash_descsize(hash)
+ CRYPTO_MINALIGN] CRYPTO_MINALIGN_ATTR;
struct shash_desc *shash = (struct shash_desc *)desc;
unsigned int i;
desc.shash.tfm = hash;
desc.shash.flags = crypto_shash_get_flags(parent) &
CRYPTO_TFM_REQ_MAY_SLEEP;
shash->tfm = hash;
shash->flags = crypto_shash_get_flags(parent)
& CRYPTO_TFM_REQ_MAY_SLEEP;
if (keylen > bs) {
int err;
err = crypto_shash_digest(&desc.shash, inkey, keylen, ipad);
err = crypto_shash_digest(shash, inkey, keylen, ipad);
if (err)
return err;
@@ -81,12 +80,12 @@ static int hmac_setkey(struct crypto_shash *parent,
opad[i] ^= 0x5c;
}
return crypto_shash_init(&desc.shash) ?:
crypto_shash_update(&desc.shash, ipad, bs) ?:
crypto_shash_export(&desc.shash, ipad) ?:
crypto_shash_init(&desc.shash) ?:
crypto_shash_update(&desc.shash, opad, bs) ?:
crypto_shash_export(&desc.shash, opad);
return crypto_shash_init(shash) ?:
crypto_shash_update(shash, ipad, bs) ?:
crypto_shash_export(shash, ipad) ?:
crypto_shash_init(shash) ?:
crypto_shash_update(shash, opad, bs) ?:
crypto_shash_export(shash, opad);
}
static int hmac_export(struct shash_desc *pdesc, void *out)

View File

@@ -67,7 +67,8 @@ EXPORT_SYMBOL_GPL(crypto_shash_setkey);
static inline unsigned int shash_align_buffer_size(unsigned len,
unsigned long mask)
{
return len + (mask & ~(__alignof__(u8 __attribute__ ((aligned))) - 1));
typedef u8 __attribute__ ((aligned)) u8_aligned;
return len + (mask & ~(__alignof__(u8_aligned) - 1));
}
static int shash_update_unaligned(struct shash_desc *desc, const u8 *data,

View File

@@ -1663,16 +1663,17 @@ static int alg_test_crc32c(const struct alg_test_desc *desc,
}
do {
struct {
struct shash_desc shash;
char ctx[crypto_shash_descsize(tfm)];
} sdesc;
char sdesc[sizeof(struct shash_desc)
+ crypto_shash_descsize(tfm)
+ CRYPTO_MINALIGN] CRYPTO_MINALIGN_ATTR;
struct shash_desc *shash = (struct shash_desc *)sdesc;
u32 *ctx = (u32 *)shash_desc_ctx(shash);
sdesc.shash.tfm = tfm;
sdesc.shash.flags = 0;
shash->tfm = tfm;
shash->flags = 0;
*(u32 *)sdesc.ctx = le32_to_cpu(420553207);
err = crypto_shash_final(&sdesc.shash, (u8 *)&val);
*ctx = le32_to_cpu(420553207);
err = crypto_shash_final(shash, (u8 *)&val);
if (err) {
printk(KERN_ERR "alg: crc32c: Operation failed for "
"%s: %d\n", driver, err);

View File

@@ -543,29 +543,29 @@ static int crypt_iv_lmk_one(struct crypt_config *cc, u8 *iv,
u8 *data)
{
struct iv_lmk_private *lmk = &cc->iv_gen_private.lmk;
struct {
struct shash_desc desc;
char ctx[crypto_shash_descsize(lmk->hash_tfm)];
} sdesc;
char sdesc[sizeof(struct shash_desc)
+ crypto_shash_descsize(lmk->hash_tfm)
+ CRYPTO_MINALIGN] CRYPTO_MINALIGN_ATTR;
struct shash_desc *desc = (struct shash_desc *)sdesc;
struct md5_state md5state;
__le32 buf[4];
int i, r;
sdesc.desc.tfm = lmk->hash_tfm;
sdesc.desc.flags = CRYPTO_TFM_REQ_MAY_SLEEP;
desc->tfm = lmk->hash_tfm;
desc->flags = CRYPTO_TFM_REQ_MAY_SLEEP;
r = crypto_shash_init(&sdesc.desc);
r = crypto_shash_init(desc);
if (r)
return r;
if (lmk->seed) {
r = crypto_shash_update(&sdesc.desc, lmk->seed, LMK_SEED_SIZE);
r = crypto_shash_update(desc, lmk->seed, LMK_SEED_SIZE);
if (r)
return r;
}
/* Sector is always 512B, block size 16, add data of blocks 1-31 */
r = crypto_shash_update(&sdesc.desc, data + 16, 16 * 31);
r = crypto_shash_update(desc, data + 16, 16 * 31);
if (r)
return r;
@@ -574,12 +574,12 @@ static int crypt_iv_lmk_one(struct crypt_config *cc, u8 *iv,
buf[1] = cpu_to_le32((((u64)dmreq->iv_sector >> 32) & 0x00FFFFFF) | 0x80000000);
buf[2] = cpu_to_le32(4024);
buf[3] = 0;
r = crypto_shash_update(&sdesc.desc, (u8 *)buf, sizeof(buf));
r = crypto_shash_update(desc, (u8 *)buf, sizeof(buf));
if (r)
return r;
/* No MD5 padding here */
r = crypto_shash_export(&sdesc.desc, &md5state);
r = crypto_shash_export(desc, &md5state);
if (r)
return r;

View File

@@ -2321,54 +2321,56 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
}
}
#define TPACPI_COMPARE_KEY(__scancode, __member) \
do { \
if ((event_mask & (1 << __scancode)) && \
oldn->__member != newn->__member) \
tpacpi_hotkey_send_key(__scancode); \
} while (0)
#define TPACPI_MAY_SEND_KEY(__scancode) \
do { \
if (event_mask & (1 << __scancode)) \
tpacpi_hotkey_send_key(__scancode); \
} while (0)
static void issue_volchange(const unsigned int oldvol,
const unsigned int newvol,
const u32 event_mask)
{
unsigned int i = oldvol;
while (i > newvol) {
TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
i--;
}
while (i < newvol) {
TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
i++;
}
}
static void issue_brightnesschange(const unsigned int oldbrt,
const unsigned int newbrt,
const u32 event_mask)
{
unsigned int i = oldbrt;
while (i > newbrt) {
TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
i--;
}
while (i < newbrt) {
TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
i++;
}
}
static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
struct tp_nvram_state *newn,
const u32 event_mask)
{
#define TPACPI_COMPARE_KEY(__scancode, __member) \
do { \
if ((event_mask & (1 << __scancode)) && \
oldn->__member != newn->__member) \
tpacpi_hotkey_send_key(__scancode); \
} while (0)
#define TPACPI_MAY_SEND_KEY(__scancode) \
do { \
if (event_mask & (1 << __scancode)) \
tpacpi_hotkey_send_key(__scancode); \
} while (0)
void issue_volchange(const unsigned int oldvol,
const unsigned int newvol)
{
unsigned int i = oldvol;
while (i > newvol) {
TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
i--;
}
while (i < newvol) {
TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
i++;
}
}
void issue_brightnesschange(const unsigned int oldbrt,
const unsigned int newbrt)
{
unsigned int i = oldbrt;
while (i > newbrt) {
TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
i--;
}
while (i < newbrt) {
TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
i++;
}
}
TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
@@ -2402,7 +2404,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
oldn->volume_level != newn->volume_level) {
/* recently muted, or repeated mute keypress, or
* multiple presses ending in mute */
issue_volchange(oldn->volume_level, newn->volume_level);
issue_volchange(oldn->volume_level, newn->volume_level,
event_mask);
TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
}
} else {
@@ -2412,7 +2415,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
}
if (oldn->volume_level != newn->volume_level) {
issue_volchange(oldn->volume_level, newn->volume_level);
issue_volchange(oldn->volume_level, newn->volume_level,
event_mask);
} else if (oldn->volume_toggle != newn->volume_toggle) {
/* repeated vol up/down keypress at end of scale ? */
if (newn->volume_level == 0)
@@ -2425,7 +2429,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
/* handle brightness */
if (oldn->brightness_level != newn->brightness_level) {
issue_brightnesschange(oldn->brightness_level,
newn->brightness_level);
newn->brightness_level, event_mask);
} else if (oldn->brightness_toggle != newn->brightness_toggle) {
/* repeated key presses that didn't change state */
if (newn->brightness_level == 0)

View File

@@ -4,7 +4,8 @@
#include <linux/types.h>
#include <linux/irqflags.h>
extern unsigned long wrong_size_cmpxchg(volatile void *ptr);
extern unsigned long wrong_size_cmpxchg(volatile void *ptr)
__noreturn;
/*
* Generic version of __cmpxchg_local (disables interrupts). Takes an unsigned

View File

@@ -0,0 +1,12 @@
#ifndef __LINUX_COMPILER_H
#error "Please don't include <linux/compiler-clang.h> directly, include <linux/compiler.h> instead."
#endif
/* Some compiler specific definitions are overwritten here
* for Clang compiler
*/
#ifdef uninitialized_var
#undef uninitialized_var
#define uninitialized_var(x) x = *(&(x))
#endif

View File

@@ -63,6 +63,13 @@ extern void __chk_io_ptr(const volatile void __iomem *);
# include <linux/compiler-intel.h>
#endif
/* Clang compiler defines __GNUC__. So we will overwrite implementations
* coming from above header files here
*/
#ifdef __clang__
#include <linux/compiler-clang.h>
#endif
/*
* Generic compiler-dependent macros required for kernel
* build go below this comment. Actual compiler/compiler version

View File

@@ -548,6 +548,11 @@ struct amba_id {
* See documentation of "x86_match_cpu" for details.
*/
/*
* MODULE_DEVICE_TABLE expects this struct to be called x86cpu_device_id.
* Although gcc seems to ignore this error, clang fails without this define.
*/
#define x86cpu_device_id x86_cpu_id
struct x86_cpu_id {
__u16 vendor;
__u16 family;

View File

@@ -346,7 +346,7 @@ static inline void destroy_params(const struct kernel_param *params,
/* The macros to do compile-time type checking stolen from Jakub
Jelinek, who IIRC came up with this idea for the 2.4 module init code. */
#define __param_check(name, p, type) \
static inline type *__check_##name(void) { return(p); }
static inline type __always_unused *__check_##name(void) { return(p); }
extern struct kernel_param_ops param_ops_byte;
extern int param_set_byte(const char *val, const struct kernel_param *kp);

View File

@@ -46,7 +46,9 @@ obj-$(CONFIG_CHECK_SIGNATURE) += check_signature.o
obj-$(CONFIG_DEBUG_LOCKING_API_SELFTESTS) += locking-selftest.o
GCOV_PROFILE_hweight.o := n
ifneq ($(COMPILER),clang)
CFLAGS_hweight.o = $(subst $(quote),,$(CONFIG_ARCH_HWEIGHT_CFLAGS))
endif
obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
obj-$(CONFIG_BTREE) += btree.o

View File

@@ -41,20 +41,20 @@ static struct crypto_shash *tfm;
u32 crc32c(u32 crc, const void *address, unsigned int length)
{
struct {
struct shash_desc shash;
char ctx[crypto_shash_descsize(tfm)];
} desc;
char desc[sizeof(struct shash_desc) + crypto_shash_descsize(tfm)
+ CRYPTO_MINALIGN] CRYPTO_MINALIGN_ATTR;
struct shash_desc *shash = (struct shash_desc *)desc;
u32 *ctx = (u32 *)shash_desc_ctx(shash);
int err;
desc.shash.tfm = tfm;
desc.shash.flags = 0;
*(u32 *)desc.ctx = crc;
shash->tfm = tfm;
shash->flags = 0;
*ctx = crc;
err = crypto_shash_update(&desc.shash, address, length);
err = crypto_shash_update(shash, address, length);
BUG_ON(err);
return *(u32 *)desc.ctx;
return *ctx;
}
EXPORT_SYMBOL(crc32c);

View File

@@ -23,12 +23,12 @@ void ieee80211_aes_ccm_encrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
u8 *data, size_t data_len, u8 *mic)
{
struct scatterlist assoc, pt, ct[2];
struct {
struct aead_request req;
u8 priv[crypto_aead_reqsize(tfm)];
} aead_req;
memset(&aead_req, 0, sizeof(aead_req));
char aead_req_data[sizeof(struct aead_request) +
crypto_aead_reqsize(tfm)]
__aligned(__alignof__(struct aead_request));
struct aead_request *aead_req = (void *) aead_req_data;
memset(aead_req, 0, sizeof(aead_req_data));
sg_init_one(&pt, data, data_len);
sg_init_one(&assoc, &aad[2], be16_to_cpup((__be16 *)aad));
@@ -36,23 +36,22 @@ void ieee80211_aes_ccm_encrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
sg_set_buf(&ct[0], data, data_len);
sg_set_buf(&ct[1], mic, IEEE80211_CCMP_MIC_LEN);
aead_request_set_tfm(&aead_req.req, tfm);
aead_request_set_assoc(&aead_req.req, &assoc, assoc.length);
aead_request_set_crypt(&aead_req.req, &pt, ct, data_len, b_0);
aead_request_set_tfm(aead_req, tfm);
aead_request_set_assoc(aead_req, &assoc, assoc.length);
aead_request_set_crypt(aead_req, &pt, ct, data_len, b_0);
crypto_aead_encrypt(&aead_req.req);
crypto_aead_encrypt(aead_req);
}
int ieee80211_aes_ccm_decrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
u8 *data, size_t data_len, u8 *mic)
{
struct scatterlist assoc, pt, ct[2];
struct {
struct aead_request req;
u8 priv[crypto_aead_reqsize(tfm)];
} aead_req;
memset(&aead_req, 0, sizeof(aead_req));
char aead_req_data[sizeof(struct aead_request) +
crypto_aead_reqsize(tfm)]
__aligned(__alignof__(struct aead_request));
struct aead_request *aead_req = (void *) aead_req_data;
memset(aead_req, 0, sizeof(aead_req_data));
sg_init_one(&pt, data, data_len);
sg_init_one(&assoc, &aad[2], be16_to_cpup((__be16 *)aad));
@@ -60,12 +59,12 @@ int ieee80211_aes_ccm_decrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
sg_set_buf(&ct[0], data, data_len);
sg_set_buf(&ct[1], mic, IEEE80211_CCMP_MIC_LEN);
aead_request_set_tfm(&aead_req.req, tfm);
aead_request_set_assoc(&aead_req.req, &assoc, assoc.length);
aead_request_set_crypt(&aead_req.req, ct, &pt,
aead_request_set_tfm(aead_req, tfm);
aead_request_set_assoc(aead_req, &assoc, assoc.length);
aead_request_set_crypt(aead_req, ct, &pt,
data_len + IEEE80211_CCMP_MIC_LEN, b_0);
return crypto_aead_decrypt(&aead_req.req);
return crypto_aead_decrypt(aead_req);
}
struct crypto_aead *ieee80211_aes_key_setup_encrypt(const u8 key[])

View File

@@ -5,23 +5,35 @@
* they serve as the hanging-off data accessed through repl.data[].
*/
/* tbl has the following structure equivalent, but is C99 compliant:
* struct {
* struct type##_replace repl;
* struct type##_standard entries[nhooks];
* struct type##_error term;
* } *tbl;
*/
#define xt_alloc_initial_table(type, typ2) ({ \
unsigned int hook_mask = info->valid_hooks; \
unsigned int nhooks = hweight32(hook_mask); \
unsigned int bytes = 0, hooknum = 0, i = 0; \
struct { \
struct type##_replace repl; \
struct type##_standard entries[nhooks]; \
struct type##_error term; \
} *tbl = kzalloc(sizeof(*tbl), GFP_KERNEL); \
struct type##_standard entries[]; \
} *tbl; \
struct type##_error *term; \
size_t term_offset = (offsetof(typeof(*tbl), entries[nhooks]) + \
__alignof__(*term) - 1) & ~(__alignof__(*term) - 1); \
tbl = kzalloc(term_offset + sizeof(*term), GFP_KERNEL); \
if (tbl == NULL) \
return NULL; \
term = (struct type##_error *)&(((char *)tbl)[term_offset]); \
strncpy(tbl->repl.name, info->name, sizeof(tbl->repl.name)); \
tbl->term = (struct type##_error)typ2##_ERROR_INIT; \
*term = (struct type##_error)typ2##_ERROR_INIT; \
tbl->repl.valid_hooks = hook_mask; \
tbl->repl.num_entries = nhooks + 1; \
tbl->repl.size = nhooks * sizeof(struct type##_standard) + \
sizeof(struct type##_error); \
sizeof(struct type##_error); \
for (; hook_mask != 0; hook_mask >>= 1, ++hooknum) { \
if (!(hook_mask & 1)) \
continue; \

View File

@@ -65,12 +65,22 @@ warning- := $(empty)
warning-1 := -Wextra -Wunused -Wno-unused-parameter
warning-1 += -Wmissing-declarations
warning-1 += -Wmissing-format-attribute
warning-1 += -Wmissing-prototypes
warning-1 += $(call cc-option, -Wmissing-prototypes)
warning-1 += -Wold-style-definition
warning-1 += $(call cc-option, -Wmissing-include-dirs)
warning-1 += $(call cc-option, -Wunused-but-set-variable)
warning-1 += $(call cc-disable-warning, missing-field-initializers)
# Clang
warning-1 += $(call cc-disable-warning, initializer-overrides)
warning-1 += $(call cc-disable-warning, unused-value)
warning-1 += $(call cc-disable-warning, format)
warning-1 += $(call cc-disable-warning, unknown-warning-option)
warning-1 += $(call cc-disable-warning, sign-compare)
warning-1 += $(call cc-disable-warning, format-zero-length)
warning-1 += $(call cc-disable-warning, uninitialized)
warning-1 += $(call cc-option, -fcatch-undefined-behavior)
warning-2 := -Waggregate-return
warning-2 += -Wcast-align
warning-2 += -Wdisabled-optimization

View File

@@ -76,7 +76,7 @@ UTS_TRUNCATE="cut -b -$UTS_LEN"
echo \#define LINUX_COMPILE_BY \"`echo $LINUX_COMPILE_BY | $UTS_TRUNCATE`\"
echo \#define LINUX_COMPILE_HOST \"`echo $LINUX_COMPILE_HOST | $UTS_TRUNCATE`\"
echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | tail -n 1`\"
echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | grep ' version '`\"
) > .tmpcompile
# Only replace the real compile.h if the new one is different,