diff --git a/Documentation/filesystems/overlayfs.txt b/Documentation/filesystems/overlayfs.txt index bcbf9710e4af..3ef85226bcce 100755 --- a/Documentation/filesystems/overlayfs.txt +++ b/Documentation/filesystems/overlayfs.txt @@ -82,6 +82,29 @@ Only the lists of names from directories are merged. Other content such as metadata and extended attributes are reported for the upper directory only. These attributes of the lower directory are hidden. +credentials +----------- + +By default, all access to the upper, lower and work directories is the +recorded mounter's MAC and DAC credentials. The incoming accesses are +checked against the caller's credentials. + +In the case where caller MAC or DAC credentials do not overlap, a +use case available in older versions of the driver, the +override_creds mount flag can be turned off and help when the use +pattern has caller with legitimate credentials where the mounter +does not. Several unintended side effects will occur though. The +caller without certain key capabilities or lower privilege will not +always be able to delete files or directories, create nodes, or +search some restricted directories. The ability to search and read +a directory entry is spotty as a result of the cache mechanism not +retesting the credentials because of the assumption, a privileged +caller can fill cache, then a lower privilege can read the directory +cache. The uneven security model where cache, upperdir and workdir +are opened at privilege, but accessed without creating a form of +privilege escalation, should only be used with strict understanding +of the side effects and of the security policies. + whiteouts and opaque directories -------------------------------- diff --git a/Makefile b/Makefile index 2a7329235a61..133b2814839e 100755 --- a/Makefile +++ b/Makefile @@ -256,11 +256,8 @@ SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ # "make" in the configured kernel build directory always uses that. # Default value for CROSS_COMPILE is not to prefix executables # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile -#ARCH ?= $(SUBARCH) -#CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%) +CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%) ARCH ?= arm64 -#CROSS_COMPILE ?= ../PLATFORM/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android- -CROSS_COMPILE ?= $(srctree)/toolchain/gcc-cfp/gcc-ibv-jopp/aarch64-linux-android-4.9/bin/aarch64-linux-android- # Architecture as present in compile.h UTS_MACHINE := $(ARCH) @@ -306,14 +303,13 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ else if [ -x /bin/bash ]; then echo /bin/bash; \ else echo sh; fi ; fi) -HOSTCC = $(CCACHE) gcc -HOSTCXX = $(CCACHE) g++ +HOSTCC = gcc +HOSTCXX = g++ 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) -HOSTCFLAGS += -Wno-unused-value -Wno-unused-parameter \ - -Wno-missing-field-initializers -fno-delete-null-pointer-checks +ifeq ($(CONFIG_EXYNOS_FMP_FIPS),) +READELF = $(CROSS_COMPILE)readelf +export READELF endif # Decide whether to build built-in, modular, or both. @@ -351,16 +347,16 @@ scripts/Kbuild.include: ; include scripts/Kbuild.include # Make variables (CC, etc...) -AS = $(CCACHE) $(CROSS_COMPILE)as -LD = $(CCACHE) $(CROSS_COMPILE)ld -LDGOLD = $(CCACHE) $(CROSS_COMPILE)ld.gold -CC = $(CCACHE) $(CROSS_COMPILE)gcc -CPP = $(CCACHE) $(CC) -E -AR = $(CCACHE) $(CROSS_COMPILE)ar -NM = $(CCACHE) $(CROSS_COMPILE)nm -STRIP = $(CCACHE) $(CROSS_COMPILE)strip -OBJCOPY = $(CCACHE) $(CROSS_COMPILE)objcopy -OBJDUMP = $(CCACHE) $(CROSS_COMPILE)objdump +AS = $(CROSS_COMPILE)as +LD = $(CROSS_COMPILE)ld +LDGOLD = $(CROSS_COMPILE)ld.gold +CC = $(CROSS_COMPILE)gcc +CPP = $(CC) -E +AR = $(CROSS_COMPILE)ar +NM = $(CROSS_COMPILE)nm +STRIP = $(CROSS_COMPILE)strip +OBJCOPY = $(CROSS_COMPILE)objcopy +OBJDUMP = $(CROSS_COMPILE)objdump AWK = awk GENKSYMS = scripts/genksyms/genksyms INSTALLKERNEL := installkernel @@ -403,7 +399,7 @@ LINUXINCLUDE += $(filter-out $(LINUXINCLUDE),$(USERINCLUDE)) KBUILD_AFLAGS := -D__ASSEMBLY__ KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ - -fno-strict-aliasing -fno-common \ + -fno-strict-aliasing -fno-common -fshort-wchar \ -Werror-implicit-function-declaration \ -Wno-format-security \ -std=gnu89 @@ -414,6 +410,7 @@ KBUILD_AFLAGS_MODULE := -DMODULE KBUILD_CFLAGS_MODULE := -DMODULE KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds GCC_PLUGINS_CFLAGS := +CLANG_FLAGS := # Read KERNELRELEASE from include/config/kernel.release (if it exists) KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) @@ -426,7 +423,8 @@ export MAKE AWK GENKSYMS INSTALLKERNEL PERL PYTHON UTS_MACHINE export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS -export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE CFLAGS_KASAN CFLAGS_UBSAN +export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE +export CFLAGS_KASAN CFLAGS_KASAN_NOSANITIZE CFLAGS_UBSAN export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL @@ -532,6 +530,25 @@ ifneq ($(filter install,$(MAKECMDGOALS)),) endif endif +ifeq ($(cc-name),clang) +ifneq ($(CROSS_COMPILE),) +CLANG_TRIPLE ?= $(CROSS_COMPILE) +CLANG_FLAGS += --target=$(notdir $(CLANG_TRIPLE:%-=%)) +GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) +CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE)) +GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..) +endif +ifneq ($(GCC_TOOLCHAIN),) +CLANG_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN) +endif +KBUILD_CFLAGS += -Wno-sizeof-pointer-div +CLANG_FLAGS += -no-integrated-as +CLANG_FLAGS += -Werror=unknown-warning-option +KBUILD_CFLAGS += $(CLANG_FLAGS) +KBUILD_AFLAGS += $(CLANG_FLAGS) +endif + + ifeq ($(mixed-targets),1) # =========================================================================== # We're called with mixed targets (*config and build targets). @@ -673,6 +690,7 @@ KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,) KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation) KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow) KBUILD_CFLAGS += $(call cc-disable-warning, int-in-bool-context) +KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) KBUILD_CFLAGS += $(call cc-disable-warning, attribute-alias) ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION @@ -780,21 +798,9 @@ 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_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) @@ -803,14 +809,11 @@ 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. -# Use make W=1 to enable them (see scripts/Makefile.build) +# Use make W=1 to enable them (see scripts/Makefile.extrawarn) KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) -KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable) KBUILD_CFLAGS += $(call cc-disable-warning, attribute-alias) KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned) KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation) @@ -823,6 +826,7 @@ KBUILD_CFLAGS += $(call cc-disable-warning, unused-function) KBUILD_CFLAGS += $(call cc-disable-warning, implicit-function-declaration) endif +KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable) ifdef CONFIG_FRAME_POINTER KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls else @@ -851,10 +855,10 @@ KBUILD_CFLAGS += $(call cc-option, -gdwarf-4,) endif ifdef CONFIG_RKP_CFP_JOPP -# Don't use jump tables for switch statements, since this generates indirect jump (br) +# Don't use jump tables for switch statements, since this generates indirect jump (br) # instructions, which are very dangerous for kernel control flow integrity. KBUILD_CFLAGS += -fno-jump-tables -endif +endif ifdef CONFIG_DEBUG_INFO_REDUCED KBUILD_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \ @@ -927,6 +931,18 @@ KBUILD_CFLAGS += $(call cc-option,-Werror=date-time) # enforce correct pointer usage KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types) +# Require designated initializers for all marked structures +KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init) + +# change __FILE__ to the relative path from the srctree +KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=) + +# ensure -fcf-protection is disabled when using retpoline as it is +# incompatible with -mindirect-branch=thunk-extern +ifdef CONFIG_RETPOLINE +KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none) +endif + # use the deterministic mode of AR if available KBUILD_ARFLAGS := $(call ar-option,D) diff --git a/apollo.sh b/apollo.sh index d6d2cdf90b78..caed48fdd872 100755 --- a/apollo.sh +++ b/apollo.sh @@ -76,7 +76,10 @@ CR_GCC4=~/Android/Toolchains/aarch64-linux-android-4.9/bin/aarch64-linux-android CR_GCC9=~/Android/Toolchains/aarch64-linux-gnu-9.x/bin/aarch64-linux-gnu- CR_GCC12=~/Android/Toolchains/aarch64-linux-gnu-12.x/bin/aarch64-linux-gnu- CR_GCC13=~/Android/Toolchains/aarch64-linux-gnu-13.x/bin/aarch64-linux-gnu- -CR_CLANG=~/Android/Toolchains/clang-r353983c/bin +CR_CLANG_11=~/Android/Toolchains/clang-r383902-jopp +CR_CLANG_12=~/Android/Toolchains/clang-r416183b +CR_CLANG_14=~/Android/Toolchains/clang-r450784d +CR_CLANG_EXP=~/Android/Toolchains/clang-r522817 ##################################################### # Compiler Selection @@ -102,12 +105,42 @@ export CROSS_COMPILE=$CR_GCC13 compile="make" CR_COMPILER="$CR_GCC13" fi -if [ $CR_COMPILER = "5" ]; then -export CLANG_PATH=$CR_CLANG -export CROSS_COMPILE=$CR_GCC4 -export CLANG_TRIPLE=aarch64-linux-gnu- -compile="make CC=clang ARCH=arm64" -export PATH=${CLANG_PATH}:${PATH} +if [ $CR_COMPILER = "5" ] || [ $CR_COMPILER = "6" ] || [ $CR_COMPILER = "7" ] || [ $CR_COMPILER = "8" ]; then + if [ $CR_COMPILER = "5" ]; then + CR_CLANG=$CR_CLANG_11 + elif [ $CR_COMPILER = "6" ]; then + CR_CLANG=$CR_CLANG_12 + elif [ $CR_COMPILER = "7" ]; then + CR_CLANG=$CR_CLANG_14 + elif [ $CR_COMPILER = "8" ]; then + CR_CLANG=$CR_CLANG_EXP + fi + +# Check packages +for pkg in gcc-arm-linux-gnueabi gcc-aarch64-linux-gnu; do +if ! dpkg-query -W -f='${Status}' $pkg | grep "ok installed"; then + echo " $pkg is missing, please install with sudo apt-get install $pkg" + exit 0; +fi +done + +export PATH=$CR_CLANG/bin:$CR_CLANG/lib:${PATH} +export CLANG_TRIPLE=$CR_GCC9 +export CROSS_COMPILE=$CR_GCC9 +export CROSS_COMPILE_ARM32=arm-linux-gnueabi- +export CC=$CR_CLANG/bin/clang +export REAL_CC=$CR_CLANG/bin/clang +export LD=$CR_CLANG/bin/ld.lld +export AR=$CR_CLANG/bin/llvm-ar +export NM=$CR_CLANG/bin/llvm-nm +export OBJCOPY=$CR_CLANG/bin/llvm-objcopy +export OBJDUMP=$CR_CLANG/bin/llvm-objdump +export READELF=$CR_CLANG/bin/llvm-readelf +export STRIP=$CR_CLANG/bin/llvm-strip +export LLVM=1 +export LLVM_IAS=1 +export ARCH=arm64 && export SUBARCH=arm64 +compile="make ARCH=arm64 CC=clang" CR_COMPILER="$CR_CLANG" fi } @@ -279,7 +312,7 @@ PACK_BOOT_IMG() echo " Abort " fi # Remove red warning at boot - echo -n "SEANDROIDENFORCE" » $CR_AIK/image-new.img + echo -n "SEANDROIDENFORCE" >> $CR_AIK/image-new.img # Copy boot.img to Production folder if [ ! -e $CR_PRODUCT ]; then mkdir $CR_PRODUCT @@ -391,14 +424,14 @@ BUILD_DEBUG(){ echo "----------------------------------------------" echo " DEBUG : Debug build initiated " CR_TARGET=5 -CR_COMPILER=2 -CR_SELINUX=1 +CR_COMPILER=8 +CR_SELINUX=0 CR_KSU="y" CR_CLEAN="n" echo " DEBUG : Set Build options " echo " DEBUG : Variant : $CR_VARIANT_G965N" -echo " DEBUG : Compiler : $CR_GCC9" -echo " DEBUG : Selinux : $CR_SELINUX Permissive" +echo " DEBUG : Compiler : $CR_CLANG_EXP" +echo " DEBUG : Selinux : $CR_SELINUX Enforcing" echo " DEBUG : Clean : $CR_CLEAN" echo "----------------------------------------------" BUILD @@ -508,9 +541,12 @@ echo "1) $CR_GCC4 (GCC 4.9)" echo "2) $CR_GCC9 (GCC 9.x)" echo "3) $CR_GCC12 (GCC 12.x)" echo "4) $CR_GCC13 (GCC 13.x)" -echo "5) $CR_CLANG (CLANG)" +echo "5) $CR_CLANG_11 (Clang 11 - Samsung)" +echo "6) $CR_CLANG_12 (Clang 12)" +echo "7) $CR_CLANG_14 (Clang 14)" +echo "8) $CR_CLANG_EXP (Clang 18)" echo " " -read -p "Please select your compiler (1-5) > " CR_COMPILER +read -p "Please select your compiler (1-8) > " CR_COMPILER echo " " echo "1) Selinux Permissive " "2) Selinux Enforcing" echo " " diff --git a/arch/arm/include/asm/vdso_datapage.h b/arch/arm/include/asm/vdso_datapage.h index 9be259442fca..0120852b6b12 100755 --- a/arch/arm/include/asm/vdso_datapage.h +++ b/arch/arm/include/asm/vdso_datapage.h @@ -24,21 +24,38 @@ #include +#ifndef _VDSO_WTM_CLOCK_SEC_T +#define _VDSO_WTM_CLOCK_SEC_T +typedef u32 vdso_wtm_clock_nsec_t; +#endif + +#ifndef _VDSO_XTIME_CLOCK_SEC_T +#define _VDSO_XTIME_CLOCK_SEC_T +typedef u32 vdso_xtime_clock_sec_t; +#endif + +#ifndef _VDSO_RAW_TIME_SEC_T +#define _VDSO_RAW_TIME_SEC_T +typedef u32 vdso_raw_time_sec_t; +#endif + /* Try to be cache-friendly on systems that don't implement the * generic timer: fit the unconditionally updated fields in the first * 32 bytes. */ struct vdso_data { - u32 seq_count; /* sequence count - odd during updates */ - u16 tk_is_cntvct; /* fall back to syscall if false */ + u32 tb_seq_count; /* sequence count - odd during updates */ + u16 use_syscall; /* fall back to syscall if true */ u16 cs_shift; /* clocksource shift */ u32 xtime_coarse_sec; /* coarse time */ u32 xtime_coarse_nsec; - u32 wtm_clock_sec; /* wall to monotonic offset */ - u32 wtm_clock_nsec; - u32 xtime_clock_sec; /* CLOCK_REALTIME - seconds */ - u32 cs_mult; /* clocksource multiplier */ + /* wall to monotonic offset */ + u32 wtm_clock_sec; + vdso_wtm_clock_nsec_t wtm_clock_nsec; + /* CLOCK_REALTIME - seconds */ + vdso_xtime_clock_sec_t xtime_clock_sec; + u32 cs_mono_mult; /* clocksource multiplier */ u64 cs_cycle_last; /* last cycle value */ u64 cs_mask; /* clocksource mask */ @@ -46,6 +63,14 @@ struct vdso_data { u64 xtime_clock_snsec; /* CLOCK_REALTIME sub-ns base */ u32 tz_minuteswest; /* timezone info for gettimeofday(2) */ u32 tz_dsttime; + + u32 btm_sec; /* monotonic to boot time */ + u32 btm_nsec; + /* Raw clocksource multipler */ + u32 cs_raw_mult; + /* Raw time */ + vdso_raw_time_sec_t raw_time_sec; + u32 raw_time_nsec; }; union vdso_data_store { diff --git a/arch/arm/kernel/vdso.c b/arch/arm/kernel/vdso.c index 890439737374..2385f02be3df 100755 --- a/arch/arm/kernel/vdso.c +++ b/arch/arm/kernel/vdso.c @@ -173,6 +173,8 @@ static void __init patch_vdso(void *ehdr) if (!cntvct_ok) { vdso_nullpatch_one(&einfo, "__vdso_gettimeofday"); vdso_nullpatch_one(&einfo, "__vdso_clock_gettime"); + vdso_nullpatch_one(&einfo, "__vdso_clock_getres"); + /* do not zero out __vdso_time, no cntvct_ok dependency */ } } @@ -258,14 +260,14 @@ void arm_install_vdso(struct mm_struct *mm, unsigned long addr) static void vdso_write_begin(struct vdso_data *vdata) { - ++vdso_data->seq_count; + ++vdso_data->tb_seq_count; smp_wmb(); /* Pairs with smp_rmb in vdso_read_retry */ } static void vdso_write_end(struct vdso_data *vdata) { smp_wmb(); /* Pairs with smp_rmb in vdso_read_begin */ - ++vdso_data->seq_count; + ++vdso_data->tb_seq_count; } static bool tk_is_cntvct(const struct timekeeper *tk) @@ -289,10 +291,10 @@ static bool tk_is_cntvct(const struct timekeeper *tk) * counter again, making it even, indicating to userspace that the * update is finished. * - * Userspace is expected to sample seq_count before reading any other - * fields from the data page. If seq_count is odd, userspace is + * Userspace is expected to sample tb_seq_count before reading any other + * fields from the data page. If tb_seq_count is odd, userspace is * expected to wait until it becomes even. After copying data from - * the page, userspace must sample seq_count again; if it has changed + * the page, userspace must sample tb_seq_count again; if it has changed * from its previous value, userspace must retry the whole sequence. * * Calls to update_vsyscall are serialized by the timekeeping core. @@ -310,20 +312,28 @@ void update_vsyscall(struct timekeeper *tk) vdso_write_begin(vdso_data); - vdso_data->tk_is_cntvct = tk_is_cntvct(tk); + vdso_data->use_syscall = !tk_is_cntvct(tk); vdso_data->xtime_coarse_sec = tk->xtime_sec; vdso_data->xtime_coarse_nsec = (u32)(tk->tkr_mono.xtime_nsec >> tk->tkr_mono.shift); vdso_data->wtm_clock_sec = wtm->tv_sec; vdso_data->wtm_clock_nsec = wtm->tv_nsec; - if (vdso_data->tk_is_cntvct) { + if (!vdso_data->use_syscall) { + struct timespec btm = ktime_to_timespec(tk->offs_boot); + vdso_data->cs_cycle_last = tk->tkr_mono.cycle_last; + vdso_data->raw_time_sec = tk->raw_sec; + vdso_data->raw_time_nsec = tk->tkr_raw.xtime_nsec; vdso_data->xtime_clock_sec = tk->xtime_sec; vdso_data->xtime_clock_snsec = tk->tkr_mono.xtime_nsec; - vdso_data->cs_mult = tk->tkr_mono.mult; + vdso_data->cs_mono_mult = tk->tkr_mono.mult; + vdso_data->cs_raw_mult = tk->tkr_raw.mult; + /* tkr_mono.shift == tkr_raw.shift */ vdso_data->cs_shift = tk->tkr_mono.shift; vdso_data->cs_mask = tk->tkr_mono.mask; + vdso_data->btm_sec = btm.tv_sec; + vdso_data->btm_nsec = btm.tv_nsec; } vdso_write_end(vdso_data); diff --git a/arch/arm/vdso/Makefile b/arch/arm/vdso/Makefile index 59a8fa7b8a3b..1ce912ab47cc 100755 --- a/arch/arm/vdso/Makefile +++ b/arch/arm/vdso/Makefile @@ -26,8 +26,11 @@ CFLAGS_REMOVE_vdso.o = -pg CFLAGS_REMOVE_vgettimeofday.o = -pg -Os CFLAGS_vgettimeofday.o = -O2 -# Disable gcov profiling for VDSO code +# Disable gcov, kasan, ubsan and kcov profiling for VDSO code GCOV_PROFILE := n +KASAN_SANITIZE := n +UBSAN_SANITIZE := n +KCOV_INSTRUMENT := n # Force dependency $(obj)/vdso.o : $(obj)/vdso.so diff --git a/arch/arm/vdso/compiler.h b/arch/arm/vdso/compiler.h new file mode 100644 index 000000000000..6fd88be2ff0e --- /dev/null +++ b/arch/arm/vdso/compiler.h @@ -0,0 +1,75 @@ +/* + * Userspace implementations of fallback calls + * + * Copyright (C) 2017 Cavium, Inc. + * Copyright (C) 2012 ARM Limited + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Author: Will Deacon + * Rewriten into C by: Andrew Pinski + */ + +#ifndef __VDSO_COMPILER_H +#define __VDSO_COMPILER_H + +#include /* for arch_counter_get_cntvct() */ +#include /* for cpu_relax() */ +#include +#include +#include /* for LOW_RES_NSEC and MONOTONIC_RES_NSEC */ +#include /* for NSEC_PER_SEC */ + +#ifndef CONFIG_AEABI +#error This code depends on AEABI system call conventions +#endif + +#ifdef CONFIG_ARM_ARCH_TIMER +#define ARCH_PROVIDES_TIMER +#endif + +#define DEFINE_FALLBACK(name, type_arg1, name_arg1, type_arg2, name_arg2) \ +static notrace long name##_fallback(type_arg1 _##name_arg1, \ + type_arg2 _##name_arg2) \ +{ \ + register type_arg1 name_arg1 asm("r0") = _##name_arg1; \ + register type_arg2 name_arg2 asm("r1") = _##name_arg2; \ + register long ret asm ("r0"); \ + register long nr asm("r7") = __NR_##name; \ + \ + asm volatile( \ + " swi #0\n" \ + : "=r" (ret) \ + : "r" (name_arg1), "r" (name_arg2), "r" (nr) \ + : "memory"); \ + \ + return ret; \ +} + +#define arch_vdso_read_counter() arch_counter_get_cntvct() + +/* Avoid unresolved references emitted by GCC */ + +void __aeabi_unwind_cpp_pr0(void) +{ +} + +void __aeabi_unwind_cpp_pr1(void) +{ +} + +void __aeabi_unwind_cpp_pr2(void) +{ +} + +#endif /* __VDSO_COMPILER_H */ diff --git a/arch/arm/vdso/datapage.h b/arch/arm/vdso/datapage.h new file mode 100644 index 000000000000..e3088bdfb946 --- /dev/null +++ b/arch/arm/vdso/datapage.h @@ -0,0 +1,25 @@ +/* + * Userspace implementations of __get_datapage + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef __VDSO_DATAPAGE_H +#define __VDSO_DATAPAGE_H + +#include +#include + +extern const struct vdso_data *__get_datapage(void); + +#endif /* __VDSO_DATAPAGE_H */ diff --git a/arch/arm/vdso/vdso.lds.S b/arch/arm/vdso/vdso.lds.S index 89ca89f12d23..1eb577091d1f 100755 --- a/arch/arm/vdso/vdso.lds.S +++ b/arch/arm/vdso/vdso.lds.S @@ -82,6 +82,8 @@ VERSION global: __vdso_clock_gettime; __vdso_gettimeofday; + __vdso_clock_getres; + __vdso_time; local: *; }; } diff --git a/arch/arm/vdso/vgettimeofday.c b/arch/arm/vdso/vgettimeofday.c index 79214d5ff097..4b241fe60d17 100755 --- a/arch/arm/vdso/vgettimeofday.c +++ b/arch/arm/vdso/vgettimeofday.c @@ -1,282 +1,3 @@ -/* - * Copyright 2015 Mentor Graphics Corporation. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; version 2 of the - * License. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef CONFIG_AEABI -#error This code depends on AEABI system call conventions -#endif - -extern struct vdso_data *__get_datapage(void); - -static notrace u32 __vdso_read_begin(const struct vdso_data *vdata) -{ - u32 seq; -repeat: - seq = ACCESS_ONCE(vdata->seq_count); - if (seq & 1) { - cpu_relax(); - goto repeat; - } - return seq; -} - -static notrace u32 vdso_read_begin(const struct vdso_data *vdata) -{ - u32 seq; - - seq = __vdso_read_begin(vdata); - - smp_rmb(); /* Pairs with smp_wmb in vdso_write_end */ - return seq; -} - -static notrace int vdso_read_retry(const struct vdso_data *vdata, u32 start) -{ - smp_rmb(); /* Pairs with smp_wmb in vdso_write_begin */ - return vdata->seq_count != start; -} - -static notrace long clock_gettime_fallback(clockid_t _clkid, - struct timespec *_ts) -{ - register struct timespec *ts asm("r1") = _ts; - register clockid_t clkid asm("r0") = _clkid; - register long ret asm ("r0"); - register long nr asm("r7") = __NR_clock_gettime; - - asm volatile( - " swi #0\n" - : "=r" (ret) - : "r" (clkid), "r" (ts), "r" (nr) - : "memory"); - - return ret; -} - -static notrace int do_realtime_coarse(struct timespec *ts, - struct vdso_data *vdata) -{ - u32 seq; - - do { - seq = vdso_read_begin(vdata); - - ts->tv_sec = vdata->xtime_coarse_sec; - ts->tv_nsec = vdata->xtime_coarse_nsec; - - } while (vdso_read_retry(vdata, seq)); - - return 0; -} - -static notrace int do_monotonic_coarse(struct timespec *ts, - struct vdso_data *vdata) -{ - struct timespec tomono; - u32 seq; - - do { - seq = vdso_read_begin(vdata); - - ts->tv_sec = vdata->xtime_coarse_sec; - ts->tv_nsec = vdata->xtime_coarse_nsec; - - tomono.tv_sec = vdata->wtm_clock_sec; - tomono.tv_nsec = vdata->wtm_clock_nsec; - - } while (vdso_read_retry(vdata, seq)); - - ts->tv_sec += tomono.tv_sec; - timespec_add_ns(ts, tomono.tv_nsec); - - return 0; -} - -#ifdef CONFIG_ARM_ARCH_TIMER - -static notrace u64 get_ns(struct vdso_data *vdata) -{ - u64 cycle_delta; - u64 cycle_now; - u64 nsec; - - cycle_now = arch_counter_get_cntvct(); - - cycle_delta = (cycle_now - vdata->cs_cycle_last) & vdata->cs_mask; - - nsec = (cycle_delta * vdata->cs_mult) + vdata->xtime_clock_snsec; - nsec >>= vdata->cs_shift; - - return nsec; -} - -static notrace int do_realtime(struct timespec *ts, struct vdso_data *vdata) -{ - u64 nsecs; - u32 seq; - - do { - seq = vdso_read_begin(vdata); - - if (!vdata->tk_is_cntvct) - return -1; - - ts->tv_sec = vdata->xtime_clock_sec; - nsecs = get_ns(vdata); - - } while (vdso_read_retry(vdata, seq)); - - ts->tv_nsec = 0; - timespec_add_ns(ts, nsecs); - - return 0; -} - -static notrace int do_monotonic(struct timespec *ts, struct vdso_data *vdata) -{ - struct timespec tomono; - u64 nsecs; - u32 seq; - - do { - seq = vdso_read_begin(vdata); - - if (!vdata->tk_is_cntvct) - return -1; - - ts->tv_sec = vdata->xtime_clock_sec; - nsecs = get_ns(vdata); - - tomono.tv_sec = vdata->wtm_clock_sec; - tomono.tv_nsec = vdata->wtm_clock_nsec; - - } while (vdso_read_retry(vdata, seq)); - - ts->tv_sec += tomono.tv_sec; - ts->tv_nsec = 0; - timespec_add_ns(ts, nsecs + tomono.tv_nsec); - - return 0; -} - -#else /* CONFIG_ARM_ARCH_TIMER */ - -static notrace int do_realtime(struct timespec *ts, struct vdso_data *vdata) -{ - return -1; -} - -static notrace int do_monotonic(struct timespec *ts, struct vdso_data *vdata) -{ - return -1; -} - -#endif /* CONFIG_ARM_ARCH_TIMER */ - -notrace int __vdso_clock_gettime(clockid_t clkid, struct timespec *ts) -{ - struct vdso_data *vdata; - int ret = -1; - - vdata = __get_datapage(); - - switch (clkid) { - case CLOCK_REALTIME_COARSE: - ret = do_realtime_coarse(ts, vdata); - break; - case CLOCK_MONOTONIC_COARSE: - ret = do_monotonic_coarse(ts, vdata); - break; - case CLOCK_REALTIME: - ret = do_realtime(ts, vdata); - break; - case CLOCK_MONOTONIC: - ret = do_monotonic(ts, vdata); - break; - default: - break; - } - - if (ret) - ret = clock_gettime_fallback(clkid, ts); - - return ret; -} - -static notrace long gettimeofday_fallback(struct timeval *_tv, - struct timezone *_tz) -{ - register struct timezone *tz asm("r1") = _tz; - register struct timeval *tv asm("r0") = _tv; - register long ret asm ("r0"); - register long nr asm("r7") = __NR_gettimeofday; - - asm volatile( - " swi #0\n" - : "=r" (ret) - : "r" (tv), "r" (tz), "r" (nr) - : "memory"); - - return ret; -} - -notrace int __vdso_gettimeofday(struct timeval *tv, struct timezone *tz) -{ - struct timespec ts; - struct vdso_data *vdata; - int ret; - - vdata = __get_datapage(); - - ret = do_realtime(&ts, vdata); - if (ret) - return gettimeofday_fallback(tv, tz); - - if (tv) { - tv->tv_sec = ts.tv_sec; - tv->tv_usec = ts.tv_nsec / 1000; - } - if (tz) { - tz->tz_minuteswest = vdata->tz_minuteswest; - tz->tz_dsttime = vdata->tz_dsttime; - } - - return ret; -} - -/* Avoid unresolved references emitted by GCC */ - -void __aeabi_unwind_cpp_pr0(void) -{ -} - -void __aeabi_unwind_cpp_pr1(void) -{ -} - -void __aeabi_unwind_cpp_pr2(void) -{ -} +#include "compiler.h" +#include "datapage.h" +#include "../../../lib/vdso/vgettimeofday.c" diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 46a411faa156..6294105829df 100755 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -1436,10 +1436,65 @@ config COMPAT If you want to execute 32-bit userspace applications, say Y. +config KUSER_HELPERS + bool "Enable the kuser helpers page in 32-bit processes" + depends on COMPAT + default y + help + Warning: disabling this option may break 32-bit applications. + + Provide kuser helpers in a special purpose fixed-address page. The + kernel provides helper code to userspace in read-only form at a fixed + location to allow userspace to be independent of the CPU type fitted + to the system. This permits 32-bit binaries to be run on ARMv6 through + to ARMv8 without modification. + + See Documentation/arm/kernel_user_helpers.txt for details. + + However, the fixed-address nature of these helpers can be used by ROP + (return-orientated programming) authors when creating exploits. + + If all of the 32-bit binaries and libraries that run on your platform + are built specifically for your platform, and make no use of these + helpers, then you can turn this option off to hinder such exploits. + However, in that case, if a binary or library relying on those helpers + is run, it will receive a SIGSEGV signal, which will terminate the + program. Typically, binaries compiled for ARMv7 or later do not use + the kuser helpers. + + Say N here only if you are absolutely certain that you do not need + these helpers; otherwise, the safe option is to say Y (the default + for now) + config SYSVIPC_COMPAT def_bool y depends on COMPAT && SYSVIPC +config COMPAT_VDSO + bool "32-bit vDSO" + depends on COMPAT + select ARM_ARCH_TIMER_VCT_ACCESS + default n + help + Warning: a 32-bit toolchain is necessary to build the vDSO. You + must explicitly define which toolchain should be used by setting + CROSS_COMPILE_ARM32 to the prefix of the 32-bit toolchain (same format + as CROSS_COMPILE). If CROSS_COMPILE_ARM32 is empty, a warning will be + printed and the kernel will be built as if COMPAT_VDSO had not been + set. If CROSS_COMPILE_ARM32 is set to an invalid prefix, compilation + will be aborted. + + Provide a vDSO to 32-bit processes. It includes the symbols provided + by the vDSO from the 32-bit kernel, so that a 32-bit libc can use + the compat vDSO without modification. It also provides sigreturn + trampolines, replacing the sigreturn page. + +config CROSS_COMPILE_ARM32 + string "32-bit toolchain prefix" + help + Same as setting CROSS_COMPILE_ARM32 in the environment, but saved for + future builds. The environment variable overrides this config option. + endmenu menu "Power management options" diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile index 01615d6ebcce..dc03d659bf5c 100755 --- a/arch/arm64/Makefile +++ b/arch/arm64/Makefile @@ -10,7 +10,7 @@ # # Copyright (C) 1995-2001 by Russell King -LDFLAGS_vmlinux :=-p --no-undefined -X +LDFLAGS_vmlinux :=--no-undefined -X CPPFLAGS_vmlinux.lds = -DTEXT_OFFSET=$(TEXT_OFFSET) GZFLAGS :=-9 @@ -54,18 +54,50 @@ $(warning LSE atomics not supported by binutils) endif endif +ifeq ($(CONFIG_COMPAT_VDSO), y) + CROSS_COMPILE_ARM32 ?= $(CONFIG_CROSS_COMPILE_ARM32:"%"=%) + # Check that the user has provided a valid prefix for the 32-bit toolchain. + # To prevent selecting the system $(cc-name) by default, the prefix is not + # allowed to be empty, unlike CROSS_COMPILE. In the unlikely event that the + # system $(cc-name) is actually the 32-bit ARM compiler to be used, the + # variable can be set to the dirname (e.g. CROSS_COMPILE_ARM32=/usr/bin/). + # Note: this Makefile is read both before and after regenerating the config + # (if needed). Any warning appearing before the config has been regenerated + # should be ignored. If the error is triggered and you set + # CONFIG_CROSS_COMPILE_ARM32, set CROSS_COMPILE_ARM32 to an appropriate value + # when invoking make and fix CONFIG_CROSS_COMPILE_ARM32. + ifeq ($(CROSS_COMPILE_ARM32),) + $(error CROSS_COMPILE_ARM32 not defined or empty, the compat vDSO will not be built) + else ifeq ($(cc-name),clang) + export CLANG_TRIPLE_ARM32 ?= $(CROSS_COMPILE_ARM32) + export CLANG_TARGET_ARM32 := --target=$(notdir $(CLANG_TRIPLE_ARM32:%-=%)) + export GCC_TOOLCHAIN32_DIR := $(dir $(shell which $(CROSS_COMPILE_ARM32)ld)) + export GCC_TOOLCHAIN32 := $(realpath $(GCC_TOOLCHAIN32_DIR)/..) + export CLANG_PREFIX32 := --prefix=$(GCC_TOOLCHAIN32_DIR) + export CLANG_GCC32_TC := --gcc-toolchain=$(GCC_TOOLCHAIN32) + export CONFIG_VDSO32 := y + vdso32 := -DCONFIG_VDSO32=1 + else ifeq ($(shell which $(CROSS_COMPILE_ARM32)$(cc-name) 2> /dev/null),) + $(error $(CROSS_COMPILE_ARM32)$(cc-name) not found, check CROSS_COMPILE_ARM32) + else + export CROSS_COMPILE_ARM32 + export CONFIG_VDSO32 := y + vdso32 := -DCONFIG_VDSO32=1 + endif +endif + 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 +KBUILD_CFLAGS += -mno-implicit-float else -KBUILD_CFLAGS += -mgeneral-regs-only +KBUILD_CFLAGS += -mgeneral-regs-only endif -KBUILD_CFLAGS += $(lseinstr) +KBUILD_CFLAGS += $(lseinstr) $(vdso32) KBUILD_CFLAGS += -fno-asynchronous-unwind-tables KBUILD_CFLAGS += $(call cc-option, -mpc-relative-literal-loads) KBUILD_CFLAGS += -fno-pic -KBUILD_AFLAGS += $(lseinstr) +KBUILD_AFLAGS += $(lseinstr) $(vdso32) ifeq ($(CONFIG_CPU_BIG_ENDIAN), y) KBUILD_CPPFLAGS += -mbig-endian @@ -181,6 +213,7 @@ archclean: $(Q)$(MAKE) $(clean)=$(boot) $(Q)$(MAKE) $(clean)=$(boot)/dts +ifeq ($(KBUILD_EXTMOD),) # We need to generate vdso-offsets.h before compiling certain files in kernel/. # In order to do that, we should use the archprepare target, but we can't since # asm-offsets.h is included in some files used to generate vdso-offsets.h, and @@ -190,6 +223,9 @@ archclean: prepare: vdso_prepare vdso_prepare: prepare0 $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso include/generated/vdso-offsets.h + $(if $(CONFIG_VDSO32),$(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso32 \ + include/generated/vdso32-offsets.h) +endif define archhelp echo '* Image.gz - Compressed kernel image (arch/$(ARCH)/boot/Image.gz)' diff --git a/arch/arm64/configs/exynos9810_defconfig b/arch/arm64/configs/exynos9810_defconfig index b46db6c52d39..cf60b89d329d 100755 --- a/arch/arm64/configs/exynos9810_defconfig +++ b/arch/arm64/configs/exynos9810_defconfig @@ -525,7 +525,7 @@ CONFIG_CMA_AREAS=7 # CONFIG_Z3FOLD is not set CONFIG_ZSMALLOC=y CONFIG_MM_EVENT_STAT=y -CONFIG_PGTABLE_MAPPING=y +# CONFIG_PGTABLE_MAPPING is not set # CONFIG_ZSMALLOC_STAT is not set CONFIG_GENERIC_EARLY_IOREMAP=y CONFIG_HPA=y @@ -615,6 +615,9 @@ CONFIG_BINFMT_SCRIPT=y CONFIG_COREDUMP=y CONFIG_COMPAT=y CONFIG_KEYS_COMPAT=y +CONFIG_KUSER_HELPERS=y +# CONFIG_COMPAT_VDSO is not set +CONFIG_CROSS_COMPILE_ARM32="" # # Power management options @@ -4565,7 +4568,7 @@ CONFIG_CLKSRC_OF=y CONFIG_CLKSRC_PROBE=y CONFIG_ARM_ARCH_TIMER=y CONFIG_ARM_ARCH_TIMER_EVTSTREAM=y -# CONFIG_ARM_ARCH_TIMER_VCT_ACCESS is not set +CONFIG_ARM_ARCH_TIMER_VCT_ACCESS=y CONFIG_ARM_ARCH_TIMER_OOL_WORKAROUND=y CONFIG_FSL_ERRATUM_A008585=y # CONFIG_ARM_TIMER_SP804 is not set @@ -5289,7 +5292,7 @@ CONFIG_MANDATORY_FILE_LOCKING=y CONFIG_FS_ENCRYPTION=y CONFIG_FS_PRIVATE_ENCRYPTION=y # CONFIG_FS_CRYPTO_SEC_EXTENSION is not set -CONFIG_CRYPTO_FIPS=y +# CONFIG_CRYPTO_FIPS is not set # CONFIG_FSCRYPT_SDP is not set CONFIG_FSNOTIFY=y CONFIG_DNOTIFY=y @@ -5586,7 +5589,7 @@ CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE=0 # CONFIG_PANIC_ON_OOPS is not set CONFIG_PANIC_ON_OOPS_VALUE=0 CONFIG_PANIC_TIMEOUT=5 -CONFIG_SCHED_DEBUG=y +# CONFIG_SCHED_DEBUG is not set CONFIG_SCHED_INFO=y # CONFIG_PANIC_ON_RT_THROTTLING is not set CONFIG_SCHEDSTATS=y @@ -5908,9 +5911,7 @@ CONFIG_CRYPTO_HW=y # CONFIG_CRYPTO_DEV_CCP is not set CONFIG_EXYNOS_SMU=y CONFIG_EXYNOS_FMP=y -CONFIG_EXYNOS_FMP_FIPS=y -CONFIG_NODE_FOR_SELFTEST_FAIL=y -# CONFIG_PANIC_FOR_SELFTEST_FAIL is not set +# CONFIG_EXYNOS_FMP_FIPS is not set CONFIG_ASYMMETRIC_KEY_TYPE=y CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE=y CONFIG_X509_CERTIFICATE_PARSER=y diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h index 40a8a94db23b..d46c1941cfae 100755 --- a/arch/arm64/include/asm/elf.h +++ b/arch/arm64/include/asm/elf.h @@ -140,11 +140,12 @@ typedef struct user_fpsimd_state elf_fpregset_t; #define SET_PERSONALITY(ex) clear_thread_flag(TIF_32BIT); /* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes */ -#define ARCH_DLINFO \ +#define _SET_AUX_ENT_VDSO \ do { \ NEW_AUX_ENT(AT_SYSINFO_EHDR, \ - (elf_addr_t)current->mm->context.vdso); \ + (Elf64_Off)current->mm->context.vdso); \ } while (0) +#define ARCH_DLINFO _SET_AUX_ENT_VDSO #define ARCH_HAS_SETUP_ADDITIONAL_PAGES struct linux_binprm; @@ -184,7 +185,11 @@ typedef compat_elf_greg_t compat_elf_gregset_t[COMPAT_ELF_NGREG]; #define compat_start_thread compat_start_thread #define COMPAT_SET_PERSONALITY(ex) set_thread_flag(TIF_32BIT); +#ifdef CONFIG_VDSO32 +#define COMPAT_ARCH_DLINFO _SET_AUX_ENT_VDSO +#else #define COMPAT_ARCH_DLINFO +#endif extern int aarch32_setup_vectors_page(struct linux_binprm *bprm, int uses_interp); #define compat_arch_setup_additional_pages \ diff --git a/arch/arm64/include/asm/percpu.h b/arch/arm64/include/asm/percpu.h index a2f6bd2c8252..1abad2315fa9 100755 --- a/arch/arm64/include/asm/percpu.h +++ b/arch/arm64/include/asm/percpu.h @@ -93,6 +93,7 @@ static inline unsigned long __percpu_##op(void *ptr, \ : [val] "Ir" (val)); \ break; \ default: \ + ret = 0; \ BUILD_BUG(); \ } \ \ @@ -122,6 +123,7 @@ static inline unsigned long __percpu_read(void *ptr, int size) ret = ACCESS_ONCE(*(u64 *)ptr); break; default: + ret = 0; BUILD_BUG(); } @@ -191,6 +193,7 @@ static inline unsigned long __percpu_xchg(void *ptr, unsigned long val, : [val] "r" (val)); break; default: + ret = 0; BUILD_BUG(); } diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h index dc81cec1418e..09feb6b44b8f 100755 --- a/arch/arm64/include/asm/processor.h +++ b/arch/arm64/include/asm/processor.h @@ -63,9 +63,9 @@ #define STACK_TOP_MAX TASK_SIZE_64 #ifdef CONFIG_COMPAT -#define AARCH32_VECTORS_BASE 0xffff0000 +#define AARCH32_KUSER_HELPERS_BASE 0xffff0000 #define STACK_TOP (test_thread_flag(TIF_32BIT) ? \ - AARCH32_VECTORS_BASE : STACK_TOP_MAX) + AARCH32_KUSER_HELPERS_BASE : STACK_TOP_MAX) #else #define STACK_TOP STACK_TOP_MAX #endif /* CONFIG_COMPAT */ diff --git a/arch/arm64/include/asm/signal32.h b/arch/arm64/include/asm/signal32.h index 81abea0b7650..bcd0e139ee4a 100755 --- a/arch/arm64/include/asm/signal32.h +++ b/arch/arm64/include/asm/signal32.h @@ -20,7 +20,51 @@ #ifdef CONFIG_COMPAT #include -#define AARCH32_KERN_SIGRET_CODE_OFFSET 0x500 +struct compat_sigcontext { + /* We always set these two fields to 0 */ + compat_ulong_t trap_no; + compat_ulong_t error_code; + + compat_ulong_t oldmask; + compat_ulong_t arm_r0; + compat_ulong_t arm_r1; + compat_ulong_t arm_r2; + compat_ulong_t arm_r3; + compat_ulong_t arm_r4; + compat_ulong_t arm_r5; + compat_ulong_t arm_r6; + compat_ulong_t arm_r7; + compat_ulong_t arm_r8; + compat_ulong_t arm_r9; + compat_ulong_t arm_r10; + compat_ulong_t arm_fp; + compat_ulong_t arm_ip; + compat_ulong_t arm_sp; + compat_ulong_t arm_lr; + compat_ulong_t arm_pc; + compat_ulong_t arm_cpsr; + compat_ulong_t fault_address; +}; + +struct compat_ucontext { + compat_ulong_t uc_flags; + compat_uptr_t uc_link; + compat_stack_t uc_stack; + struct compat_sigcontext uc_mcontext; + compat_sigset_t uc_sigmask; + int __unused[32 - (sizeof(compat_sigset_t) / sizeof(int))]; + compat_ulong_t uc_regspace[128] __aligned(8); +}; + +struct compat_sigframe { + struct compat_ucontext uc; + compat_ulong_t retcode[2]; +}; + +struct compat_rt_sigframe { + struct compat_siginfo info; + struct compat_sigframe sig; +}; int compat_setup_frame(int usig, struct ksignal *ksig, sigset_t *set, struct pt_regs *regs); diff --git a/arch/arm64/include/asm/vdso.h b/arch/arm64/include/asm/vdso.h index 839ce0031bd5..f2a952338f1e 100755 --- a/arch/arm64/include/asm/vdso.h +++ b/arch/arm64/include/asm/vdso.h @@ -28,6 +28,9 @@ #ifndef __ASSEMBLY__ #include +#ifdef CONFIG_VDSO32 +#include +#endif #define VDSO_SYMBOL(base, name) \ ({ \ diff --git a/arch/arm64/include/asm/vdso_datapage.h b/arch/arm64/include/asm/vdso_datapage.h index 2b9a63771eda..348b9be9efe7 100755 --- a/arch/arm64/include/asm/vdso_datapage.h +++ b/arch/arm64/include/asm/vdso_datapage.h @@ -20,16 +20,33 @@ #ifndef __ASSEMBLY__ +#ifndef _VDSO_WTM_CLOCK_SEC_T +#define _VDSO_WTM_CLOCK_SEC_T +typedef __u64 vdso_wtm_clock_nsec_t; +#endif + +#ifndef _VDSO_XTIME_CLOCK_SEC_T +#define _VDSO_XTIME_CLOCK_SEC_T +typedef __u64 vdso_xtime_clock_sec_t; +#endif + +#ifndef _VDSO_RAW_TIME_SEC_T +#define _VDSO_RAW_TIME_SEC_T +typedef __u64 vdso_raw_time_sec_t; +#endif + struct vdso_data { __u64 cs_cycle_last; /* Timebase at clocksource init */ - __u64 raw_time_sec; /* Raw time */ + vdso_raw_time_sec_t raw_time_sec; /* Raw time */ __u64 raw_time_nsec; - __u64 xtime_clock_sec; /* Kernel time */ - __u64 xtime_clock_nsec; + vdso_xtime_clock_sec_t xtime_clock_sec; /* Kernel time */ + __u64 xtime_clock_snsec; __u64 xtime_coarse_sec; /* Coarse time */ __u64 xtime_coarse_nsec; __u64 wtm_clock_sec; /* Wall to monotonic time */ - __u64 wtm_clock_nsec; + vdso_wtm_clock_nsec_t wtm_clock_nsec; + __u32 btm_sec; /* monotonic to boot time */ + __u32 btm_nsec; __u32 tb_seq_count; /* Timebase sequence counter */ /* cs_* members must be adjacent and in this order (ldp accesses) */ __u32 cs_mono_mult; /* NTP-adjusted clocksource multiplier */ diff --git a/arch/arm64/include/uapi/asm/sigcontext.h b/arch/arm64/include/uapi/asm/sigcontext.h index ee469be1ae1d..a2634b91211f 100755 --- a/arch/arm64/include/uapi/asm/sigcontext.h +++ b/arch/arm64/include/uapi/asm/sigcontext.h @@ -16,6 +16,7 @@ #ifndef _UAPI__ASM_SIGCONTEXT_H #define _UAPI__ASM_SIGCONTEXT_H +#ifdef CONFIG_64BIT #include /* @@ -61,4 +62,36 @@ struct esr_context { __u64 esr; }; +#else /* CONFIG_64BIT */ + +/* + * Signal context structure - contains all info to do with the state + * before the signal handler was invoked. Note: only add new entries + * to the end of the structure. + */ +struct sigcontext { + unsigned long trap_no; + unsigned long error_code; + unsigned long oldmask; + unsigned long arm_r0; + unsigned long arm_r1; + unsigned long arm_r2; + unsigned long arm_r3; + unsigned long arm_r4; + unsigned long arm_r5; + unsigned long arm_r6; + unsigned long arm_r7; + unsigned long arm_r8; + unsigned long arm_r9; + unsigned long arm_r10; + unsigned long arm_fp; + unsigned long arm_ip; + unsigned long arm_sp; + unsigned long arm_lr; + unsigned long arm_pc; + unsigned long arm_cpsr; + unsigned long fault_address; +}; +#endif /* CONFIG_64BIT */ + #endif /* _UAPI__ASM_SIGCONTEXT_H */ diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index 40ec8da7a82e..36b3186dd783 100755 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -35,8 +35,12 @@ OBJCOPYFLAGS := --prefix-symbols=__efistub_ $(obj)/%.stub.o: $(obj)/%.o FORCE $(call if_changed,objcopy) -arm64-obj-$(CONFIG_COMPAT) += sys32.o kuser32.o signal32.o \ +arm64-obj-$(CONFIG_COMPAT) += sys32.o signal32.o \ sys_compat.o entry32.o +ifneq ($(CONFIG_VDSO32),y) +arm64-obj-$(CONFIG_COMPAT) += sigreturn32.o +endif +arm64-obj-$(CONFIG_KUSER_HELPERS) += kuser32.o arm64-obj-$(CONFIG_FUNCTION_TRACER) += ftrace.o entry-ftrace.o arm64-obj-$(CONFIG_MODULES) += arm64ksyms.o module.o arm64-obj-$(CONFIG_ARM64_MODULE_PLTS) += module-plts.o @@ -70,6 +74,7 @@ arm64-obj-$(CONFIG_UH_DEBUG) += uh_debug.o arm64-obj-$(CONFIG_UH_INFORM) += uh_inform.o obj-y += $(arm64-obj-y) vdso/ probes/ +obj-$(CONFIG_VDSO32) += vdso32/ obj-m += $(arm64-obj-m) head-y := head.o extra-y += $(head-y) vmlinux.lds diff --git a/arch/arm64/kernel/asm-offsets.c b/arch/arm64/kernel/asm-offsets.c index 327b17ada989..816ecb446aa7 100755 --- a/arch/arm64/kernel/asm-offsets.c +++ b/arch/arm64/kernel/asm-offsets.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -79,6 +80,18 @@ int main(void) DEFINE(S_ORIG_ADDR_LIMIT, offsetof(struct pt_regs, orig_addr_limit)); DEFINE(S_FRAME_SIZE, sizeof(struct pt_regs)); BLANK(); +#ifdef CONFIG_COMPAT + DEFINE(COMPAT_SIGFRAME_REGS_OFFSET, + offsetof(struct compat_sigframe, uc) + + offsetof(struct compat_ucontext, uc_mcontext) + + offsetof(struct compat_sigcontext, arm_r0)); + DEFINE(COMPAT_RT_SIGFRAME_REGS_OFFSET, + offsetof(struct compat_rt_sigframe, sig) + + offsetof(struct compat_sigframe, uc) + + offsetof(struct compat_ucontext, uc_mcontext) + + offsetof(struct compat_sigcontext, arm_r0)); + BLANK(); +#endif DEFINE(MM_CONTEXT_ID, offsetof(struct mm_struct, context.id.counter)); BLANK(); DEFINE(VMA_VM_MM, offsetof(struct vm_area_struct, vm_mm)); @@ -93,40 +106,6 @@ int main(void) DEFINE(DMA_TO_DEVICE, DMA_TO_DEVICE); DEFINE(DMA_FROM_DEVICE, DMA_FROM_DEVICE); BLANK(); - DEFINE(CLOCK_REALTIME, CLOCK_REALTIME); - DEFINE(CLOCK_MONOTONIC, CLOCK_MONOTONIC); - DEFINE(CLOCK_MONOTONIC_RAW, CLOCK_MONOTONIC_RAW); - DEFINE(CLOCK_REALTIME_RES, MONOTONIC_RES_NSEC); - DEFINE(CLOCK_REALTIME_COARSE, CLOCK_REALTIME_COARSE); - DEFINE(CLOCK_MONOTONIC_COARSE,CLOCK_MONOTONIC_COARSE); - DEFINE(CLOCK_COARSE_RES, LOW_RES_NSEC); - DEFINE(NSEC_PER_SEC, NSEC_PER_SEC); - BLANK(); - DEFINE(VDSO_CS_CYCLE_LAST, offsetof(struct vdso_data, cs_cycle_last)); - DEFINE(VDSO_RAW_TIME_SEC, offsetof(struct vdso_data, raw_time_sec)); - DEFINE(VDSO_RAW_TIME_NSEC, offsetof(struct vdso_data, raw_time_nsec)); - DEFINE(VDSO_XTIME_CLK_SEC, offsetof(struct vdso_data, xtime_clock_sec)); - DEFINE(VDSO_XTIME_CLK_NSEC, offsetof(struct vdso_data, xtime_clock_nsec)); - DEFINE(VDSO_XTIME_CRS_SEC, offsetof(struct vdso_data, xtime_coarse_sec)); - DEFINE(VDSO_XTIME_CRS_NSEC, offsetof(struct vdso_data, xtime_coarse_nsec)); - DEFINE(VDSO_WTM_CLK_SEC, offsetof(struct vdso_data, wtm_clock_sec)); - DEFINE(VDSO_WTM_CLK_NSEC, offsetof(struct vdso_data, wtm_clock_nsec)); - DEFINE(VDSO_TB_SEQ_COUNT, offsetof(struct vdso_data, tb_seq_count)); - DEFINE(VDSO_CS_MONO_MULT, offsetof(struct vdso_data, cs_mono_mult)); - DEFINE(VDSO_CS_RAW_MULT, offsetof(struct vdso_data, cs_raw_mult)); - DEFINE(VDSO_CS_SHIFT, offsetof(struct vdso_data, cs_shift)); - DEFINE(VDSO_TZ_MINWEST, offsetof(struct vdso_data, tz_minuteswest)); - DEFINE(VDSO_TZ_DSTTIME, offsetof(struct vdso_data, tz_dsttime)); - DEFINE(VDSO_USE_SYSCALL, offsetof(struct vdso_data, use_syscall)); - BLANK(); - DEFINE(TVAL_TV_SEC, offsetof(struct timeval, tv_sec)); - DEFINE(TVAL_TV_USEC, offsetof(struct timeval, tv_usec)); - DEFINE(TSPEC_TV_SEC, offsetof(struct timespec, tv_sec)); - DEFINE(TSPEC_TV_NSEC, offsetof(struct timespec, tv_nsec)); - BLANK(); - DEFINE(TZ_MINWEST, offsetof(struct timezone, tz_minuteswest)); - DEFINE(TZ_DSTTIME, offsetof(struct timezone, tz_dsttime)); - BLANK(); DEFINE(CPU_BOOT_STACK, offsetof(struct secondary_data, stack)); DEFINE(CPU_BOOT_TASK, offsetof(struct secondary_data, task)); BLANK(); diff --git a/arch/arm64/kernel/kuser32.S b/arch/arm64/kernel/kuser32.S index 997e6b27ff6a..d15b5c2935b3 100755 --- a/arch/arm64/kernel/kuser32.S +++ b/arch/arm64/kernel/kuser32.S @@ -20,16 +20,13 @@ * * AArch32 user helpers. * - * Each segment is 32-byte aligned and will be moved to the top of the high - * vector page. New segments (if ever needed) must be added in front of - * existing ones. This mechanism should be used only for things that are - * really small and justified, and not be abused freely. + * These helpers are provided for compatibility with AArch32 binaries that + * still need them. They are installed at a fixed address by + * aarch32_setup_additional_pages(). * * See Documentation/arm/kernel_user_helpers.txt for formal definitions. */ -#include - .align 5 .globl __kuser_helper_start __kuser_helper_start: @@ -77,42 +74,3 @@ __kuser_helper_version: // 0xffff0ffc .word ((__kuser_helper_end - __kuser_helper_start) >> 5) .globl __kuser_helper_end __kuser_helper_end: - -/* - * AArch32 sigreturn code - * - * For ARM syscalls, the syscall number has to be loaded into r7. - * We do not support an OABI userspace. - * - * For Thumb syscalls, we also pass the syscall number via r7. We therefore - * need two 16-bit instructions. - */ - .globl __aarch32_sigret_code_start -__aarch32_sigret_code_start: - - /* - * ARM Code - */ - .byte __NR_compat_sigreturn, 0x70, 0xa0, 0xe3 // mov r7, #__NR_compat_sigreturn - .byte __NR_compat_sigreturn, 0x00, 0x00, 0xef // svc #__NR_compat_sigreturn - - /* - * Thumb code - */ - .byte __NR_compat_sigreturn, 0x27 // svc #__NR_compat_sigreturn - .byte __NR_compat_sigreturn, 0xdf // mov r7, #__NR_compat_sigreturn - - /* - * ARM code - */ - .byte __NR_compat_rt_sigreturn, 0x70, 0xa0, 0xe3 // mov r7, #__NR_compat_rt_sigreturn - .byte __NR_compat_rt_sigreturn, 0x00, 0x00, 0xef // svc #__NR_compat_rt_sigreturn - - /* - * Thumb code - */ - .byte __NR_compat_rt_sigreturn, 0x27 // svc #__NR_compat_rt_sigreturn - .byte __NR_compat_rt_sigreturn, 0xdf // mov r7, #__NR_compat_rt_sigreturn - - .globl __aarch32_sigret_code_end -__aarch32_sigret_code_end: diff --git a/arch/arm64/kernel/signal32.c b/arch/arm64/kernel/signal32.c index b7063de792f7..b6e8ff7949a4 100755 --- a/arch/arm64/kernel/signal32.c +++ b/arch/arm64/kernel/signal32.c @@ -28,42 +28,7 @@ #include #include #include - -struct compat_sigcontext { - /* We always set these two fields to 0 */ - compat_ulong_t trap_no; - compat_ulong_t error_code; - - compat_ulong_t oldmask; - compat_ulong_t arm_r0; - compat_ulong_t arm_r1; - compat_ulong_t arm_r2; - compat_ulong_t arm_r3; - compat_ulong_t arm_r4; - compat_ulong_t arm_r5; - compat_ulong_t arm_r6; - compat_ulong_t arm_r7; - compat_ulong_t arm_r8; - compat_ulong_t arm_r9; - compat_ulong_t arm_r10; - compat_ulong_t arm_fp; - compat_ulong_t arm_ip; - compat_ulong_t arm_sp; - compat_ulong_t arm_lr; - compat_ulong_t arm_pc; - compat_ulong_t arm_cpsr; - compat_ulong_t fault_address; -}; - -struct compat_ucontext { - compat_ulong_t uc_flags; - compat_uptr_t uc_link; - compat_stack_t uc_stack; - struct compat_sigcontext uc_mcontext; - compat_sigset_t uc_sigmask; - int __unused[32 - (sizeof (compat_sigset_t) / sizeof (int))]; - compat_ulong_t uc_regspace[128] __attribute__((__aligned__(8))); -}; +#include struct compat_vfp_sigframe { compat_ulong_t magic; @@ -91,16 +56,6 @@ struct compat_aux_sigframe { unsigned long end_magic; } __attribute__((__aligned__(8))); -struct compat_sigframe { - struct compat_ucontext uc; - compat_ulong_t retcode[2]; -}; - -struct compat_rt_sigframe { - struct compat_siginfo info; - struct compat_sigframe sig; -}; - #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) static inline int put_sigset_t(compat_sigset_t __user *uset, sigset_t *set) @@ -484,14 +439,27 @@ static void compat_setup_return(struct pt_regs *regs, struct k_sigaction *ka, retcode = ptr_to_compat(ka->sa.sa_restorer); } else { /* Set up sigreturn pointer */ +#ifdef CONFIG_VDSO32 + void *vdso_base = current->mm->context.vdso; + void *trampoline = + (ka->sa.sa_flags & SA_SIGINFO + ? (thumb + ? VDSO_SYMBOL(vdso_base, compat_rt_sigreturn_thumb) + : VDSO_SYMBOL(vdso_base, compat_rt_sigreturn_arm)) + : (thumb + ? VDSO_SYMBOL(vdso_base, compat_sigreturn_thumb) + : VDSO_SYMBOL(vdso_base, compat_sigreturn_arm))); + + retcode = ptr_to_compat(trampoline) + thumb; +#else + void *sigreturn_base = current->mm->context.vdso; unsigned int idx = thumb << 1; if (ka->sa.sa_flags & SA_SIGINFO) idx += 3; - retcode = AARCH32_VECTORS_BASE + - AARCH32_KERN_SIGRET_CODE_OFFSET + - (idx << 2) + thumb; + retcode = ptr_to_compat(sigreturn_base) + (idx << 2) + thumb; +#endif } regs->regs[0] = usig; diff --git a/arch/arm64/kernel/sigreturn32.S b/arch/arm64/kernel/sigreturn32.S new file mode 100644 index 000000000000..6ecda4d84cd5 --- /dev/null +++ b/arch/arm64/kernel/sigreturn32.S @@ -0,0 +1,67 @@ +/* + * sigreturn trampolines for AArch32. + * + * Copyright (C) 2005-2011 Nicolas Pitre + * Copyright (C) 2012 ARM Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * + * AArch32 sigreturn code + * + * For ARM syscalls, the syscall number has to be loaded into r7. + * We do not support an OABI userspace. + * + * For Thumb syscalls, we also pass the syscall number via r7. We therefore + * need two 16-bit instructions. + */ + +#include + + .globl __aarch32_sigret_code_start +__aarch32_sigret_code_start: + + /* + * ARM Code + */ + // mov r7, #__NR_compat_sigreturn + .byte __NR_compat_sigreturn, 0x70, 0xa0, 0xe3 + // svc #__NR_compat_sigreturn + .byte __NR_compat_sigreturn, 0x00, 0x00, 0xef + + /* + * Thumb code + */ + // svc #__NR_compat_sigreturn + .byte __NR_compat_sigreturn, 0x27 + // mov r7, #__NR_compat_sigreturn + .byte __NR_compat_sigreturn, 0xdf + + /* + * ARM code + */ + // mov r7, #__NR_compat_rt_sigreturn + .byte __NR_compat_rt_sigreturn, 0x70, 0xa0, 0xe3 + // svc #__NR_compat_rt_sigreturn + .byte __NR_compat_rt_sigreturn, 0x00, 0x00, 0xef + + /* + * Thumb code + */ + // svc #__NR_compat_rt_sigreturn + .byte __NR_compat_rt_sigreturn, 0x27 + // mov r7, #__NR_compat_rt_sigreturn + .byte __NR_compat_rt_sigreturn, 0xdf + + .globl __aarch32_sigret_code_end +__aarch32_sigret_code_end: diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c index 7492d9009610..70695e6dae65 100755 --- a/arch/arm64/kernel/vdso.c +++ b/arch/arm64/kernel/vdso.c @@ -1,5 +1,7 @@ /* - * VDSO implementation for AArch64 and vector page setup for AArch32. + * Additional userspace pages setup for AArch64 and AArch32. + * - AArch64: vDSO pages setup, vDSO data page update. + * - AArch32: sigreturn and kuser helpers pages setup. * * Copyright (C) 2012 ARM Limited * @@ -37,8 +39,11 @@ #include #include -extern char vdso_start, vdso_end; -static unsigned long vdso_pages __ro_after_init; +struct vdso_mappings { + unsigned long num_code_pages; + struct vm_special_mapping data_mapping; + struct vm_special_mapping code_mapping; +}; /* * The vDSO data page. @@ -53,151 +58,265 @@ struct vdso_data *vdso_data = &vdso_data_store.data; /* * Create and map the vectors page for AArch32 tasks. */ -static struct page *vectors_page[1] __ro_after_init; +#if !defined(CONFIG_VDSO32) || defined(CONFIG_KUSER_HELPERS) +static struct page *vectors_page[] __ro_after_init; +static const struct vm_special_mapping compat_vdso_spec[] = { + { + /* Must be named [sigpage] for compatibility with arm. */ + .name = "[sigpage]", + .pages = &vectors_page[0], + }, +#ifdef CONFIG_KUSER_HELPERS + { + .name = "[kuserhelpers]", + .pages = &vectors_page[1], + }, +#endif +}; +static struct page *vectors_page[ARRAY_SIZE(compat_vdso_spec)] __ro_after_init; +#endif static int __init alloc_vectors_page(void) { +#ifdef CONFIG_KUSER_HELPERS extern char __kuser_helper_start[], __kuser_helper_end[]; - extern char __aarch32_sigret_code_start[], __aarch32_sigret_code_end[]; - - int kuser_sz = __kuser_helper_end - __kuser_helper_start; - int sigret_sz = __aarch32_sigret_code_end - __aarch32_sigret_code_start; - unsigned long vpage; + size_t kuser_sz = __kuser_helper_end - __kuser_helper_start; + unsigned long kuser_vpage; +#endif - vpage = get_zeroed_page(GFP_ATOMIC); +#ifndef CONFIG_VDSO32 + extern char __aarch32_sigret_code_start[], __aarch32_sigret_code_end[]; + size_t sigret_sz = + __aarch32_sigret_code_end - __aarch32_sigret_code_start; + unsigned long sigret_vpage; - if (!vpage) + sigret_vpage = get_zeroed_page(GFP_ATOMIC); + if (!sigret_vpage) return -ENOMEM; +#endif + +#ifdef CONFIG_KUSER_HELPERS + kuser_vpage = get_zeroed_page(GFP_ATOMIC); + if (!kuser_vpage) { +#ifndef CONFIG_VDSO32 + free_page(sigret_vpage); +#endif + return -ENOMEM; + } +#endif - /* kuser helpers */ - memcpy((void *)vpage + 0x1000 - kuser_sz, __kuser_helper_start, - kuser_sz); - +#ifndef CONFIG_VDSO32 /* sigreturn code */ - memcpy((void *)vpage + AARCH32_KERN_SIGRET_CODE_OFFSET, - __aarch32_sigret_code_start, sigret_sz); + memcpy((void *)sigret_vpage, __aarch32_sigret_code_start, sigret_sz); + flush_icache_range(sigret_vpage, sigret_vpage + PAGE_SIZE); + vectors_page[0] = virt_to_page(sigret_vpage); +#endif - flush_icache_range(vpage, vpage + PAGE_SIZE); - vectors_page[0] = virt_to_page(vpage); +#ifdef CONFIG_KUSER_HELPERS + /* kuser helpers */ + memcpy((void *)kuser_vpage + 0x1000 - kuser_sz, __kuser_helper_start, + kuser_sz); + flush_icache_range(kuser_vpage, kuser_vpage + PAGE_SIZE); + vectors_page[1] = virt_to_page(kuser_vpage); +#endif return 0; } arch_initcall(alloc_vectors_page); +#ifndef CONFIG_VDSO32 int aarch32_setup_vectors_page(struct linux_binprm *bprm, int uses_interp) { struct mm_struct *mm = current->mm; - unsigned long addr = AARCH32_VECTORS_BASE; - static const struct vm_special_mapping spec = { - .name = "[vectors]", - .pages = vectors_page, - - }; + unsigned long addr; void *ret; if (down_write_killable(&mm->mmap_sem)) return -EINTR; - current->mm->context.vdso = (void *)addr; + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0); + if (IS_ERR_VALUE(addr)) { + ret = ERR_PTR(addr); + goto out; + } - /* Map vectors page at the high address. */ ret = _install_special_mapping(mm, addr, PAGE_SIZE, - VM_READ|VM_EXEC|VM_MAYREAD|VM_MAYEXEC, - &spec); + VM_READ|VM_EXEC| + VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC, + &compat_vdso_spec[0]); + if (IS_ERR(ret)) + goto out; + + current->mm->context.vdso = (void *)addr; +#ifdef CONFIG_KUSER_HELPERS + /* Map the kuser helpers at the ABI-defined high address. */ + ret = _install_special_mapping(mm, AARCH32_KUSER_HELPERS_BASE, + PAGE_SIZE, + VM_READ|VM_EXEC|VM_MAYREAD|VM_MAYEXEC, + &compat_vdso_spec[1]); +#endif +out: up_write(&mm->mmap_sem); return PTR_ERR_OR_ZERO(ret); } +#endif /* !CONFIG_VDSO32 */ #endif /* CONFIG_COMPAT */ -static struct vm_special_mapping vdso_spec[2] __ro_after_init = { - { - .name = "[vvar]", - }, - { - .name = "[vdso]", - }, -}; - -static int __init vdso_init(void) +static int __init vdso_mappings_init(const char *name, + const char *code_start, + const char *code_end, + struct vdso_mappings *mappings) { - int i; + unsigned long i, vdso_pages; struct page **vdso_pagelist; unsigned long pfn; - if (memcmp(&vdso_start, "\177ELF", 4)) { - pr_err("vDSO is not a valid ELF object!\n"); + if (memcmp(code_start, "\177ELF", 4)) { + pr_err("%sis not a valid ELF object!\n", name); return -EINVAL; } - vdso_pages = (&vdso_end - &vdso_start) >> PAGE_SHIFT; - pr_info("vdso: %ld pages (%ld code @ %p, %ld data @ %p)\n", - vdso_pages + 1, vdso_pages, &vdso_start, 1L, vdso_data); + vdso_pages = (code_end - code_start) >> PAGE_SHIFT; + pr_info("%s: %ld pages (%ld code @ %p, %ld data @ %p)\n", + name, vdso_pages + 1, vdso_pages, code_start, 1L, vdso_data); /* Allocate the vDSO pagelist, plus a page for the data. */ - vdso_pagelist = kcalloc(vdso_pages + 1, sizeof(struct page *), - GFP_KERNEL); + /* + * Allocate space for storing pointers to the vDSO code pages + the + * data page. The pointers must have the same lifetime as the mappings, + * which are static, so there is no need to keep track of the pointer + * array to free it. + */ + vdso_pagelist = kmalloc_array(vdso_pages + 1, sizeof(struct page *), + GFP_KERNEL); if (vdso_pagelist == NULL) return -ENOMEM; /* Grab the vDSO data page. */ vdso_pagelist[0] = phys_to_page(__pa_symbol(vdso_data)); - /* Grab the vDSO code pages. */ - pfn = sym_to_pfn(&vdso_start); + pfn = sym_to_pfn(code_start); for (i = 0; i < vdso_pages; i++) vdso_pagelist[i + 1] = pfn_to_page(pfn + i); - vdso_spec[0].pages = &vdso_pagelist[0]; - vdso_spec[1].pages = &vdso_pagelist[1]; + /* Populate the special mapping structures */ + mappings->data_mapping = (struct vm_special_mapping) { + .name = "[vvar]", + .pages = &vdso_pagelist[0], + }; + + mappings->code_mapping = (struct vm_special_mapping) { + .name = "[vdso]", + .pages = &vdso_pagelist[1], + }; + + mappings->num_code_pages = vdso_pages; return 0; } + +#ifdef CONFIG_COMPAT +#ifdef CONFIG_VDSO32 + +static struct vdso_mappings vdso32_mappings __ro_after_init; + +static int __init vdso32_init(void) +{ + extern char vdso32_start[], vdso32_end[]; + + return vdso_mappings_init("vdso32", vdso32_start, vdso32_end, + &vdso32_mappings); +} +arch_initcall(vdso32_init); + +#endif /* CONFIG_VDSO32 */ +#endif /* CONFIG_COMPAT */ + +static struct vdso_mappings vdso_mappings __ro_after_init; + +static int __init vdso_init(void) +{ + extern char vdso_start[], vdso_end[]; + + return vdso_mappings_init("vdso", vdso_start, vdso_end, + &vdso_mappings); +} arch_initcall(vdso_init); -int arch_setup_additional_pages(struct linux_binprm *bprm, - int uses_interp) +static int vdso_setup(struct mm_struct *mm, + const struct vdso_mappings *mappings) { - struct mm_struct *mm = current->mm; unsigned long vdso_base, vdso_text_len, vdso_mapping_len; void *ret; - vdso_text_len = vdso_pages << PAGE_SHIFT; + vdso_text_len = mappings->num_code_pages << PAGE_SHIFT; /* Be sure to map the data page */ vdso_mapping_len = vdso_text_len + PAGE_SIZE; - if (down_write_killable(&mm->mmap_sem)) - return -EINTR; vdso_base = get_unmapped_area(NULL, 0, vdso_mapping_len, 0, 0); - if (IS_ERR_VALUE(vdso_base)) { - ret = ERR_PTR(vdso_base); - goto up_fail; - } + if (IS_ERR_VALUE(vdso_base)) + return PTR_ERR_OR_ZERO(ERR_PTR(vdso_base)); + ret = _install_special_mapping(mm, vdso_base, PAGE_SIZE, VM_READ|VM_MAYREAD, - &vdso_spec[0]); + &mappings->data_mapping); if (IS_ERR(ret)) - goto up_fail; + return PTR_ERR_OR_ZERO(ret); vdso_base += PAGE_SIZE; - mm->context.vdso = (void *)vdso_base; ret = _install_special_mapping(mm, vdso_base, vdso_text_len, VM_READ|VM_EXEC| VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC, - &vdso_spec[1]); - if (IS_ERR(ret)) - goto up_fail; + &mappings->code_mapping); + if (!IS_ERR(ret)) + mm->context.vdso = (void *)vdso_base; + + return PTR_ERR_OR_ZERO(ret); +} + +#ifdef CONFIG_COMPAT +#ifdef CONFIG_VDSO32 +int aarch32_setup_vectors_page(struct linux_binprm *bprm, int uses_interp) +{ + struct mm_struct *mm = current->mm; + void *ret; + if (down_write_killable(&mm->mmap_sem)) + return -EINTR; + + ret = ERR_PTR(vdso_setup(mm, &vdso32_mappings)); +#ifdef CONFIG_KUSER_HELPERS + if (!IS_ERR(ret)) + /* Map the kuser helpers at the ABI-defined high address. */ + ret = _install_special_mapping(mm, AARCH32_KUSER_HELPERS_BASE, + PAGE_SIZE, + VM_READ|VM_EXEC| + VM_MAYREAD|VM_MAYEXEC, + &compat_vdso_spec[1]); +#endif up_write(&mm->mmap_sem); - return 0; -up_fail: - mm->context.vdso = NULL; + return PTR_ERR_OR_ZERO(ret); +} +#endif /* CONFIG_VDSO32 */ +#endif /* CONFIG_COMPAT */ + +int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) +{ + struct mm_struct *mm = current->mm; + int ret; + + if (down_write_killable(&mm->mmap_sem)) + return -EINTR; + + ret = vdso_setup(mm, &vdso_mappings); + up_write(&mm->mmap_sem); - return PTR_ERR(ret); + return ret; } /* @@ -218,16 +337,20 @@ void update_vsyscall(struct timekeeper *tk) vdso_data->wtm_clock_nsec = tk->wall_to_monotonic.tv_nsec; if (!use_syscall) { + struct timespec btm = ktime_to_timespec(tk->offs_boot); + /* tkr_mono.cycle_last == tkr_raw.cycle_last */ vdso_data->cs_cycle_last = tk->tkr_mono.cycle_last; vdso_data->raw_time_sec = tk->raw_sec; vdso_data->raw_time_nsec = tk->tkr_raw.xtime_nsec; vdso_data->xtime_clock_sec = tk->xtime_sec; - vdso_data->xtime_clock_nsec = tk->tkr_mono.xtime_nsec; + vdso_data->xtime_clock_snsec = tk->tkr_mono.xtime_nsec; vdso_data->cs_mono_mult = tk->tkr_mono.mult; vdso_data->cs_raw_mult = tk->tkr_raw.mult; /* tkr_mono.shift == tkr_raw.shift */ vdso_data->cs_shift = tk->tkr_mono.shift; + vdso_data->btm_sec = btm.tv_sec; + vdso_data->btm_nsec = btm.tv_nsec; } smp_wmb(); diff --git a/arch/arm64/kernel/vdso/Makefile b/arch/arm64/kernel/vdso/Makefile index 88fef3867886..1e47df823e8c 100755 --- a/arch/arm64/kernel/vdso/Makefile +++ b/arch/arm64/kernel/vdso/Makefile @@ -5,19 +5,33 @@ # Heavily based on the vDSO Makefiles for other archs. # -obj-vdso := gettimeofday.o note.o sigreturn.o +obj-vdso-s := note.o sigreturn.o +obj-vdso-c := vgettimeofday.o # Build rules -targets := $(obj-vdso) vdso.so vdso.so.dbg -obj-vdso := $(addprefix $(obj)/, $(obj-vdso)) +targets := $(obj-vdso-s) $(obj-vdso-c) vdso.so vdso.so.dbg +obj-vdso-s := $(addprefix $(obj)/, $(obj-vdso-s)) +obj-vdso-c := $(addprefix $(obj)/, $(obj-vdso-c)) +obj-vdso := $(obj-vdso-c) $(obj-vdso-s) -ccflags-y := -shared -fno-common -fno-builtin +ccflags-y := -shared -fno-common -fno-builtin -fno-stack-protector +ccflags-y += -DDISABLE_BRANCH_PROFILING -ffixed-x18 ccflags-y += -nostdlib -Wl,-soname=linux-vdso.so.1 \ $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) ccflags-y += $(DISABLE_LTO) +# Force -O2 to avoid libgcc dependencies +CFLAGS_REMOVE_vgettimeofday.o = -pg -Os +CFLAGS_vgettimeofday.o = -O2 -fPIC +ifneq ($(cc-name),clang) +CFLAGS_vgettimeofday.o += -mcmodel=tiny +endif + # Disable gcov profiling for VDSO code GCOV_PROFILE := n +KASAN_SANITIZE := n +UBSAN_SANITIZE := n +KCOV_INSTRUMENT := n # Workaround for bare-metal (ELF) toolchains that neglect to pass -shared # down to collect2, resulting in silent corruption of the vDSO image. @@ -50,12 +64,17 @@ include/generated/vdso-offsets.h: $(obj)/vdso.so.dbg FORCE $(call if_changed,vdsosym) # Assembly rules for the .S files -$(obj-vdso): %.o: %.S FORCE +$(obj-vdso-s): %.o: %.S FORCE $(call if_changed_dep,vdsoas) +$(obj-vdso-c): %.o: %.c FORCE + $(call if_changed_dep,vdsocc) + # Actual build commands quiet_cmd_vdsold = VDSOL $@ cmd_vdsold = $(CC) $(c_flags) -Wl,-n -Wl,-T $^ -o $@ +quiet_cmd_vdsocc = VDSOC $@ + cmd_vdsocc = ${CC} $(c_flags) -c -o $@ $< quiet_cmd_vdsoas = VDSOA $@ cmd_vdsoas = $(CC) $(a_flags) -c -o $@ $< diff --git a/arch/arm64/kernel/vdso/compiler.h b/arch/arm64/kernel/vdso/compiler.h new file mode 100644 index 000000000000..fb27545640f2 --- /dev/null +++ b/arch/arm64/kernel/vdso/compiler.h @@ -0,0 +1,70 @@ +/* + * Userspace implementations of fallback calls + * + * Copyright (C) 2017 Cavium, Inc. + * Copyright (C) 2012 ARM Limited + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Author: Will Deacon + * Rewriten into C by: Andrew Pinski + */ + +#ifndef __VDSO_COMPILER_H +#define __VDSO_COMPILER_H + +#include /* for cpu_relax() */ +#include /* for read_sysreg() */ +#include +#include +#include /* for LOW_RES_NSEC and MONOTONIC_RES_NSEC */ + +#ifdef CONFIG_ARM_ARCH_TIMER +#define ARCH_PROVIDES_TIMER +#endif + +#define DEFINE_FALLBACK(name, type_arg1, name_arg1, type_arg2, name_arg2) \ +static notrace long name##_fallback(type_arg1 _##name_arg1, \ + type_arg2 _##name_arg2) \ +{ \ + register type_arg1 name_arg1 asm("x0") = _##name_arg1; \ + register type_arg2 name_arg2 asm("x1") = _##name_arg2; \ + register long ret asm ("x0"); \ + register long nr asm("x8") = __NR_##name; \ + \ + asm volatile( \ + " svc #0\n" \ + : "=r" (ret) \ + : "r" (name_arg1), "r" (name_arg2), "r" (nr) \ + : "memory"); \ + \ + return ret; \ +} + +/* + * AArch64 implementation of arch_counter_get_cntvct() suitable for vdso + */ +static __always_inline notrace u64 arch_vdso_read_counter(void) +{ + /* Read the virtual counter. */ + isb(); + return read_sysreg(cntvct_el0); +} + +/* Rename exported vdso functions */ +#define __vdso_clock_gettime __kernel_clock_gettime +#define __vdso_gettimeofday __kernel_gettimeofday +#define __vdso_clock_getres __kernel_clock_getres +#define __vdso_time __kernel_time + +#endif /* __VDSO_COMPILER_H */ diff --git a/arch/arm64/kernel/vdso/datapage.h b/arch/arm64/kernel/vdso/datapage.h new file mode 100644 index 000000000000..be86a6074cf8 --- /dev/null +++ b/arch/arm64/kernel/vdso/datapage.h @@ -0,0 +1,59 @@ +/* + * Userspace implementations of __get_datapage + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef __VDSO_DATAPAGE_H +#define __VDSO_DATAPAGE_H + +#include +#include +#include + +/* + * We use the hidden visibility to prevent the compiler from generating a GOT + * relocation. Not only is going through a GOT useless (the entry couldn't and + * mustn't be overridden by another library), it does not even work: the linker + * cannot generate an absolute address to the data page. + * + * With the hidden visibility, the compiler simply generates a PC-relative + * relocation (R_ARM_REL32), and this is what we need. + */ +extern const struct vdso_data _vdso_data __attribute__((visibility("hidden"))); + +static inline const struct vdso_data *__get_datapage(void) +{ + const struct vdso_data *ret; + /* + * This simply puts &_vdso_data into ret. The reason why we don't use + * `ret = &_vdso_data` is that the compiler tends to optimise this in a + * very suboptimal way: instead of keeping &_vdso_data in a register, + * it goes through a relocation almost every time _vdso_data must be + * accessed (even in subfunctions). This is both time and space + * consuming: each relocation uses a word in the code section, and it + * has to be loaded at runtime. + * + * This trick hides the assignment from the compiler. Since it cannot + * track where the pointer comes from, it will only use one relocation + * where __get_datapage() is called, and then keep the result in a + * register. + */ + asm("" : "=r"(ret) : "0"(&_vdso_data)); + return ret; +} + +/* We can only guarantee 56 bits of precision. */ +#define ARCH_CLOCK_FIXED_MASK GENMASK_ULL(55, 0) + +#endif /* __VDSO_DATAPAGE_H */ diff --git a/arch/arm64/kernel/vdso/gettimeofday.S b/arch/arm64/kernel/vdso/gettimeofday.S deleted file mode 100755 index c39872a7b03c..000000000000 --- a/arch/arm64/kernel/vdso/gettimeofday.S +++ /dev/null @@ -1,328 +0,0 @@ -/* - * Userspace implementations of gettimeofday() and friends. - * - * Copyright (C) 2012 ARM Limited - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Author: Will Deacon - */ - -#include -#include -#include - -#define NSEC_PER_SEC_LO16 0xca00 -#define NSEC_PER_SEC_HI16 0x3b9a - -vdso_data .req x6 -seqcnt .req w7 -w_tmp .req w8 -x_tmp .req x8 - -/* - * Conventions for macro arguments: - * - An argument is write-only if its name starts with "res". - * - All other arguments are read-only, unless otherwise specified. - */ - - .macro seqcnt_acquire -9999: ldr seqcnt, [vdso_data, #VDSO_TB_SEQ_COUNT] - tbnz seqcnt, #0, 9999b - dmb ishld - .endm - - .macro seqcnt_check fail - dmb ishld - ldr w_tmp, [vdso_data, #VDSO_TB_SEQ_COUNT] - cmp w_tmp, seqcnt - b.ne \fail - .endm - - .macro syscall_check fail - ldr w_tmp, [vdso_data, #VDSO_USE_SYSCALL] - cbnz w_tmp, \fail - .endm - - .macro get_nsec_per_sec res - mov \res, #NSEC_PER_SEC_LO16 - movk \res, #NSEC_PER_SEC_HI16, lsl #16 - .endm - - /* - * Returns the clock delta, in nanoseconds left-shifted by the clock - * shift. - */ - .macro get_clock_shifted_nsec res, cycle_last, mult - /* Read the virtual counter. */ - isb - mrs x_tmp, cntvct_el0 - /* Calculate cycle delta and convert to ns. */ - sub \res, x_tmp, \cycle_last - /* We can only guarantee 56 bits of precision. */ - movn x_tmp, #0xff00, lsl #48 - and \res, x_tmp, \res - mul \res, \res, \mult - .endm - - /* - * Returns in res_{sec,nsec} the REALTIME timespec, based on the - * "wall time" (xtime) and the clock_mono delta. - */ - .macro get_ts_realtime res_sec, res_nsec, \ - clock_nsec, xtime_sec, xtime_nsec, nsec_to_sec - add \res_nsec, \clock_nsec, \xtime_nsec - udiv x_tmp, \res_nsec, \nsec_to_sec - add \res_sec, \xtime_sec, x_tmp - msub \res_nsec, x_tmp, \nsec_to_sec, \res_nsec - .endm - - /* - * Returns in res_{sec,nsec} the timespec based on the clock_raw delta, - * used for CLOCK_MONOTONIC_RAW. - */ - .macro get_ts_clock_raw res_sec, res_nsec, clock_nsec, nsec_to_sec - udiv \res_sec, \clock_nsec, \nsec_to_sec - msub \res_nsec, \res_sec, \nsec_to_sec, \clock_nsec - .endm - - /* sec and nsec are modified in place. */ - .macro add_ts sec, nsec, ts_sec, ts_nsec, nsec_to_sec - /* Add timespec. */ - add \sec, \sec, \ts_sec - add \nsec, \nsec, \ts_nsec - - /* Normalise the new timespec. */ - cmp \nsec, \nsec_to_sec - b.lt 9999f - sub \nsec, \nsec, \nsec_to_sec - add \sec, \sec, #1 -9999: - cmp \nsec, #0 - b.ge 9998f - add \nsec, \nsec, \nsec_to_sec - sub \sec, \sec, #1 -9998: - .endm - - .macro clock_gettime_return, shift=0 - .if \shift == 1 - lsr x11, x11, x12 - .endif - stp x10, x11, [x1, #TSPEC_TV_SEC] - mov x0, xzr - ret - .endm - - .macro jump_slot jumptable, index, label - .if (. - \jumptable) != 4 * (\index) - .error "Jump slot index mismatch" - .endif - b \label - .endm - - .text - -/* int __kernel_gettimeofday(struct timeval *tv, struct timezone *tz); */ -ENTRY(__kernel_gettimeofday) - .cfi_startproc - adr vdso_data, _vdso_data - /* If tv is NULL, skip to the timezone code. */ - cbz x0, 2f - - /* Compute the time of day. */ -1: seqcnt_acquire - syscall_check fail=4f - ldr x10, [vdso_data, #VDSO_CS_CYCLE_LAST] - /* w11 = cs_mono_mult, w12 = cs_shift */ - ldp w11, w12, [vdso_data, #VDSO_CS_MONO_MULT] - ldp x13, x14, [vdso_data, #VDSO_XTIME_CLK_SEC] - seqcnt_check fail=1b - - get_nsec_per_sec res=x9 - lsl x9, x9, x12 - - get_clock_shifted_nsec res=x15, cycle_last=x10, mult=x11 - get_ts_realtime res_sec=x10, res_nsec=x11, \ - clock_nsec=x15, xtime_sec=x13, xtime_nsec=x14, nsec_to_sec=x9 - - /* Convert ns to us. */ - mov x13, #1000 - lsl x13, x13, x12 - udiv x11, x11, x13 - stp x10, x11, [x0, #TVAL_TV_SEC] -2: - /* If tz is NULL, return 0. */ - cbz x1, 3f - ldp w4, w5, [vdso_data, #VDSO_TZ_MINWEST] - stp w4, w5, [x1, #TZ_MINWEST] -3: - mov x0, xzr - ret -4: - /* Syscall fallback. */ - mov x8, #__NR_gettimeofday - svc #0 - ret - .cfi_endproc -ENDPROC(__kernel_gettimeofday) - -#define JUMPSLOT_MAX CLOCK_MONOTONIC_COARSE - -/* int __kernel_clock_gettime(clockid_t clock_id, struct timespec *tp); */ -ENTRY(__kernel_clock_gettime) - .cfi_startproc - cmp w0, #JUMPSLOT_MAX - b.hi syscall - adr vdso_data, _vdso_data - adr x_tmp, jumptable - add x_tmp, x_tmp, w0, uxtw #2 - br x_tmp - - ALIGN -jumptable: - jump_slot jumptable, CLOCK_REALTIME, realtime - jump_slot jumptable, CLOCK_MONOTONIC, monotonic - b syscall - b syscall - jump_slot jumptable, CLOCK_MONOTONIC_RAW, monotonic_raw - jump_slot jumptable, CLOCK_REALTIME_COARSE, realtime_coarse - jump_slot jumptable, CLOCK_MONOTONIC_COARSE, monotonic_coarse - - .if (. - jumptable) != 4 * (JUMPSLOT_MAX + 1) - .error "Wrong jumptable size" - .endif - - ALIGN -realtime: - seqcnt_acquire - syscall_check fail=syscall - ldr x10, [vdso_data, #VDSO_CS_CYCLE_LAST] - /* w11 = cs_mono_mult, w12 = cs_shift */ - ldp w11, w12, [vdso_data, #VDSO_CS_MONO_MULT] - ldp x13, x14, [vdso_data, #VDSO_XTIME_CLK_SEC] - seqcnt_check fail=realtime - - /* All computations are done with left-shifted nsecs. */ - get_nsec_per_sec res=x9 - lsl x9, x9, x12 - - get_clock_shifted_nsec res=x15, cycle_last=x10, mult=x11 - get_ts_realtime res_sec=x10, res_nsec=x11, \ - clock_nsec=x15, xtime_sec=x13, xtime_nsec=x14, nsec_to_sec=x9 - clock_gettime_return, shift=1 - - ALIGN -monotonic: - seqcnt_acquire - syscall_check fail=syscall - ldr x10, [vdso_data, #VDSO_CS_CYCLE_LAST] - /* w11 = cs_mono_mult, w12 = cs_shift */ - ldp w11, w12, [vdso_data, #VDSO_CS_MONO_MULT] - ldp x13, x14, [vdso_data, #VDSO_XTIME_CLK_SEC] - ldp x3, x4, [vdso_data, #VDSO_WTM_CLK_SEC] - seqcnt_check fail=monotonic - - /* All computations are done with left-shifted nsecs. */ - lsl x4, x4, x12 - get_nsec_per_sec res=x9 - lsl x9, x9, x12 - - get_clock_shifted_nsec res=x15, cycle_last=x10, mult=x11 - get_ts_realtime res_sec=x10, res_nsec=x11, \ - clock_nsec=x15, xtime_sec=x13, xtime_nsec=x14, nsec_to_sec=x9 - - add_ts sec=x10, nsec=x11, ts_sec=x3, ts_nsec=x4, nsec_to_sec=x9 - clock_gettime_return, shift=1 - - ALIGN -monotonic_raw: - seqcnt_acquire - syscall_check fail=syscall - ldr x10, [vdso_data, #VDSO_CS_CYCLE_LAST] - /* w11 = cs_raw_mult, w12 = cs_shift */ - ldp w12, w11, [vdso_data, #VDSO_CS_SHIFT] - ldp x13, x14, [vdso_data, #VDSO_RAW_TIME_SEC] - seqcnt_check fail=monotonic_raw - - /* All computations are done with left-shifted nsecs. */ - get_nsec_per_sec res=x9 - lsl x9, x9, x12 - - get_clock_shifted_nsec res=x15, cycle_last=x10, mult=x11 - get_ts_clock_raw res_sec=x10, res_nsec=x11, \ - clock_nsec=x15, nsec_to_sec=x9 - - add_ts sec=x10, nsec=x11, ts_sec=x13, ts_nsec=x14, nsec_to_sec=x9 - clock_gettime_return, shift=1 - - ALIGN -realtime_coarse: - seqcnt_acquire - ldp x10, x11, [vdso_data, #VDSO_XTIME_CRS_SEC] - seqcnt_check fail=realtime_coarse - clock_gettime_return - - ALIGN -monotonic_coarse: - seqcnt_acquire - ldp x10, x11, [vdso_data, #VDSO_XTIME_CRS_SEC] - ldp x13, x14, [vdso_data, #VDSO_WTM_CLK_SEC] - seqcnt_check fail=monotonic_coarse - - /* Computations are done in (non-shifted) nsecs. */ - get_nsec_per_sec res=x9 - add_ts sec=x10, nsec=x11, ts_sec=x13, ts_nsec=x14, nsec_to_sec=x9 - clock_gettime_return - - ALIGN -syscall: /* Syscall fallback. */ - mov x8, #__NR_clock_gettime - svc #0 - ret - .cfi_endproc -ENDPROC(__kernel_clock_gettime) - -/* int __kernel_clock_getres(clockid_t clock_id, struct timespec *res); */ -ENTRY(__kernel_clock_getres) - .cfi_startproc - cmp w0, #CLOCK_REALTIME - ccmp w0, #CLOCK_MONOTONIC, #0x4, ne - ccmp w0, #CLOCK_MONOTONIC_RAW, #0x4, ne - b.ne 1f - - ldr x2, 5f - b 2f -1: - cmp w0, #CLOCK_REALTIME_COARSE - ccmp w0, #CLOCK_MONOTONIC_COARSE, #0x4, ne - b.ne 4f - ldr x2, 6f -2: - cbz x1, 3f - stp xzr, x2, [x1] - -3: /* res == NULL. */ - mov w0, wzr - ret - -4: /* Syscall fallback. */ - mov x8, #__NR_clock_getres - svc #0 - ret -5: - .quad CLOCK_REALTIME_RES -6: - .quad CLOCK_COARSE_RES - .cfi_endproc -ENDPROC(__kernel_clock_getres) diff --git a/arch/arm64/kernel/vdso/vdso.lds.S b/arch/arm64/kernel/vdso/vdso.lds.S index beca249bc2f3..3dc1198b5ec9 100755 --- a/arch/arm64/kernel/vdso/vdso.lds.S +++ b/arch/arm64/kernel/vdso/vdso.lds.S @@ -39,6 +39,13 @@ SECTIONS .gnu.version_d : { *(.gnu.version_d) } .gnu.version_r : { *(.gnu.version_r) } + /* + * Discard .note.gnu.property sections which are unused and have + * different alignment requirement from vDSO note sections. + */ + /DISCARD/ : { + *(.note.GNU-stack .note.gnu.property) + } .note : { *(.note.*) } :text :note . = ALIGN(16); @@ -59,7 +66,6 @@ SECTIONS PROVIDE(end = .); /DISCARD/ : { - *(.note.GNU-stack) *(.data .data.* .gnu.linkonce.d.* .sdata*) *(.bss .sbss .dynbss .dynsbss) } @@ -88,6 +94,7 @@ VERSION __kernel_gettimeofday; __kernel_clock_gettime; __kernel_clock_getres; + __kernel_time; local: *; }; } diff --git a/arch/arm64/kernel/vdso/vgettimeofday.c b/arch/arm64/kernel/vdso/vgettimeofday.c new file mode 100644 index 000000000000..b73d4011993d --- /dev/null +++ b/arch/arm64/kernel/vdso/vgettimeofday.c @@ -0,0 +1,3 @@ +#include "compiler.h" +#include "datapage.h" +#include "../../../../lib/vdso/vgettimeofday.c" diff --git a/arch/arm64/kernel/vdso32/.gitignore b/arch/arm64/kernel/vdso32/.gitignore new file mode 100644 index 000000000000..4fea950fa5ed --- /dev/null +++ b/arch/arm64/kernel/vdso32/.gitignore @@ -0,0 +1,2 @@ +vdso.lds +vdso.so.raw diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile new file mode 100644 index 000000000000..835e53cca611 --- /dev/null +++ b/arch/arm64/kernel/vdso32/Makefile @@ -0,0 +1,172 @@ +# +# Building a vDSO image for AArch32. +# +# Author: Kevin Brodsky +# A mix between the arm64 and arm vDSO Makefiles. + +ifeq ($(cc-name),clang) + CC_ARM32 := $(CC) $(CLANG_TARGET_ARM32) $(CLANG_GCC32_TC) $(CLANG_PREFIX32) +else + CC_ARM32 := $(CROSS_COMPILE_ARM32)$(cc-name) +endif + +# Same as cc-*option, but using CC_ARM32 instead of CC +cc32-option = $(call try-run,\ + $(CC_ARM32) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2)) +cc32-disable-warning = $(call try-run,\ + $(CC_ARM32) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1))) +cc32-ldoption = $(call try-run,\ + $(CC_ARM32) $(1) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2)) + +# We cannot use the global flags to compile the vDSO files, the main reason +# being that the 32-bit compiler may be older than the main (64-bit) compiler +# and therefore may not understand flags set using $(cc-option ...). Besides, +# arch-specific options should be taken from the arm Makefile instead of the +# arm64 one. +# As a result we set our own flags here. + +# From top-level Makefile +# NOSTDINC_FLAGS +VDSO_CPPFLAGS := -nostdinc -isystem $(shell $(CC_ARM32) -print-file-name=include) +VDSO_CPPFLAGS += $(LINUXINCLUDE) +VDSO_CPPFLAGS += $(KBUILD_CPPFLAGS) + +# Common C and assembly flags +# From top-level Makefile +VDSO_CAFLAGS := $(VDSO_CPPFLAGS) +VDSO_CAFLAGS += $(call cc32-option,-fno-PIE) +ifdef CONFIG_DEBUG_INFO +VDSO_CAFLAGS += -g +endif +ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC_ARM32)), y) +VDSO_CAFLAGS += -DCC_HAVE_ASM_GOTO +endif + +# From arm Makefile +VDSO_CAFLAGS += $(call cc32-option,-fno-dwarf2-cfi-asm) +VDSO_CAFLAGS += -mabi=aapcs-linux -mfloat-abi=soft +ifeq ($(CONFIG_CPU_BIG_ENDIAN), y) +VDSO_CAFLAGS += -mbig-endian +else +VDSO_CAFLAGS += -mlittle-endian +endif + +# From arm vDSO Makefile +VDSO_CAFLAGS += -fPIC -fno-builtin -fno-stack-protector +VDSO_CAFLAGS += -DDISABLE_BRANCH_PROFILING + +# Try to compile for ARMv8. If the compiler is too old and doesn't support it, +# fall back to v7. There is no easy way to check for what architecture the code +# is being compiled, so define a macro specifying that (see arch/arm/Makefile). +VDSO_CAFLAGS += $(call cc32-option,-march=armv8-a -D__LINUX_ARM_ARCH__=8,\ + -march=armv7-a -D__LINUX_ARM_ARCH__=7) + +VDSO_CFLAGS := $(VDSO_CAFLAGS) +# KBUILD_CFLAGS from top-level Makefile +VDSO_CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ + -fno-strict-aliasing -fno-common \ + -Werror-implicit-function-declaration \ + -Wno-format-security \ + -std=gnu89 +VDSO_CFLAGS += -O2 +# Some useful compiler-dependent flags from top-level Makefile +VDSO_CFLAGS += $(call cc32-option,-Wdeclaration-after-statement,) +VDSO_CFLAGS += $(call cc32-option,-Wno-pointer-sign) +VDSO_CFLAGS += $(call cc32-option,-fno-strict-overflow) +VDSO_CFLAGS += $(call cc32-option,-Werror=strict-prototypes) +VDSO_CFLAGS += $(call cc32-option,-Werror=date-time) +VDSO_CFLAGS += $(call cc32-option,-Werror=incompatible-pointer-types) + +# The 32-bit compiler does not provide 128-bit integers, which are used in +# some headers that are indirectly included from the vDSO code. +# This hack makes the compiler happy and should trigger a warning/error if +# variables of such type are referenced. +VDSO_CFLAGS += -D__uint128_t='void*' +# Silence some warnings coming from headers that operate on long's +# (on GCC 4.8 or older, there is unfortunately no way to silence this warning) +VDSO_CFLAGS += $(call cc32-disable-warning,shift-count-overflow) +VDSO_CFLAGS += -Wno-int-to-pointer-cast + +VDSO_AFLAGS := $(VDSO_CAFLAGS) +VDSO_AFLAGS += -D__ASSEMBLY__ + +VDSO_LDFLAGS := $(VDSO_CPPFLAGS) +# From arm vDSO Makefile +VDSO_LDFLAGS += -Wl,-Bsymbolic -Wl,--no-undefined -Wl,-soname=linux-vdso.so.1 +VDSO_LDFLAGS += -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096 +VDSO_LDFLAGS += -nostdlib -shared -mfloat-abi=soft +VDSO_LDFLAGS += $(call cc32-ldoption,-Wl$(comma)--hash-style=sysv) +VDSO_LDFLAGS += $(call cc32-ldoption,-Wl$(comma)--build-id) +VDSO_LDFLAGS += $(call cc32-ldoption,-fuse-ld=bfd) + + +# Borrow vdsomunge.c from the arm vDSO +# We have to use a relative path because scripts/Makefile.host prefixes +# $(hostprogs-y) with $(obj) +munge := ../../../arm/vdso/vdsomunge +hostprogs-y := $(munge) + +c-obj-vdso := vgettimeofday.o +asm-obj-vdso := sigreturn.o + +# Build rules +targets := $(c-obj-vdso) $(asm-obj-vdso) vdso.so vdso.so.dbg vdso.so.raw +c-obj-vdso := $(addprefix $(obj)/, $(c-obj-vdso)) +asm-obj-vdso := $(addprefix $(obj)/, $(asm-obj-vdso)) +obj-vdso := $(c-obj-vdso) $(asm-obj-vdso) + +obj-y += vdso.o +extra-y += vdso.lds +CPPFLAGS_vdso.lds += -P -C -U$(ARCH) + +# Force dependency (vdso.s includes vdso.so through incbin) +$(obj)/vdso.o: $(obj)/vdso.so + +include/generated/vdso32-offsets.h: $(obj)/vdso.so.dbg FORCE + $(call if_changed,vdsosym) + +# Strip rule for vdso.so +$(obj)/vdso.so: OBJCOPYFLAGS := -S +$(obj)/vdso.so: $(obj)/vdso.so.dbg FORCE + $(call if_changed,objcopy) + +$(obj)/vdso.so.dbg: $(obj)/vdso.so.raw $(obj)/$(munge) FORCE + $(call if_changed,vdsomunge) + +# Link rule for the .so file, .lds has to be first +$(obj)/vdso.so.raw: $(src)/vdso.lds $(obj-vdso) FORCE + $(call if_changed,vdsold) + +# Compilation rules for the vDSO sources +$(filter-out vgettimeofday.o, $(c-obj-vdso)): %.o: %.c FORCE + $(call if_changed_dep,vdsocc) +$(asm-obj-vdso): %.o: %.S FORCE + $(call if_changed_dep,vdsoas) + +# Actual build commands +quiet_cmd_vdsold = VDSOL32 $@ + cmd_vdsold = $(CC_ARM32) -Wp,-MD,$(depfile) $(VDSO_LDFLAGS) \ + -Wl,-T $(filter %.lds,$^) $(filter %.o,$^) -o $@ +quiet_cmd_vdsocc = VDSOC32 $@ + cmd_vdsocc = $(CC_ARM32) -Wp,-MD,$(depfile) $(VDSO_CFLAGS) -c -o $@ $< +quiet_cmd_vdsoas = VDSOA32 $@ + cmd_vdsoas = $(CC_ARM32) -Wp,-MD,$(depfile) $(VDSO_AFLAGS) -c -o $@ $< + +quiet_cmd_vdsomunge = MUNGE $@ + cmd_vdsomunge = $(obj)/$(munge) $< $@ + +# Generate vDSO offsets using helper script (borrowed from the 64-bit vDSO) +gen-vdsosym := $(srctree)/$(src)/../vdso/gen_vdso_offsets.sh +quiet_cmd_vdsosym = VDSOSYM $@ +# The AArch64 nm should be able to read an AArch32 binary + cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@ + +# Install commands for the unstripped file +quiet_cmd_vdso_install = INSTALL $@ + cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/vdso32.so + +vdso.so: $(obj)/vdso.so.dbg + @mkdir -p $(MODLIB)/vdso + $(call cmd,vdso_install) + +vdso_install: vdso.so diff --git a/arch/arm64/kernel/vdso32/compiler.h b/arch/arm64/kernel/vdso32/compiler.h new file mode 100644 index 000000000000..19a43fc37bb9 --- /dev/null +++ b/arch/arm64/kernel/vdso32/compiler.h @@ -0,0 +1,122 @@ +/* + * Userspace implementations of fallback calls + * + * Copyright (C) 2017 Cavium, Inc. + * Copyright (C) 2012 ARM Limited + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Author: Will Deacon + * Rewriten into C by: Andrew Pinski + */ + +#ifndef __VDSO_COMPILER_H +#define __VDSO_COMPILER_H + +#include +#undef CONFIG_64BIT +#include /* for isb() & dmb() */ +#include /* for HZ */ +#include +#include + +#ifdef CONFIG_ARM_ARCH_TIMER +#define ARCH_PROVIDES_TIMER +#endif + +/* can not include linux/time.h because of too much architectural cruft */ +#ifndef NSEC_PER_SEC +#define NSEC_PER_SEC 1000000000L +#endif + +/* can not include linux/jiffies.h because of too much architectural cruft */ +#ifndef TICK_NSEC +#define TICK_NSEC ((NSEC_PER_SEC+HZ/2)/HZ) +#endif + +/* can not include linux/hrtimer.h because of too much architectural cruft */ +#ifndef LOW_RES_NSEC +#define LOW_RES_NSEC TICK_NSEC +#ifdef ARCH_PROVIDES_TIMER +#ifdef CONFIG_HIGH_RES_TIMERS +# define HIGH_RES_NSEC 1 +# define MONOTONIC_RES_NSEC HIGH_RES_NSEC +#else +# define MONOTONIC_RES_NSEC LOW_RES_NSEC +#endif +#endif +#endif + +#define DEFINE_FALLBACK(name, type_arg1, name_arg1, type_arg2, name_arg2) \ +static notrace long name##_fallback(type_arg1 _##name_arg1, \ + type_arg2 _##name_arg2) \ +{ \ + register type_arg1 name_arg1 asm("r0") = _##name_arg1; \ + register type_arg2 name_arg2 asm("r1") = _##name_arg2; \ + register long ret asm ("r0"); \ + register long nr asm("r7") = __NR_##name; \ + \ + asm volatile( \ + " swi #0\n" \ + : "=r" (ret) \ + : "r" (name_arg1), "r" (name_arg2), "r" (nr) \ + : "memory"); \ + \ + return ret; \ +} + +/* + * AArch32 implementation of arch_counter_get_cntvct() suitable for vdso + */ +static __always_inline notrace u64 arch_vdso_read_counter(void) +{ + u64 res; + + /* Read the virtual counter. */ + isb(); + asm volatile("mrrc p15, 1, %Q0, %R0, c14" : "=r" (res)); + + return res; +} + +/* + * Can not include asm/processor.h to pick this up because of all the + * architectural components also included, so we open code a copy. + */ +static inline void cpu_relax(void) +{ + asm volatile("yield" ::: "memory"); +} + +#undef smp_rmb +#if __LINUX_ARM_ARCH__ >= 8 +#define smp_rmb() dmb(ishld) /* ok on ARMv8 */ +#else +#define smp_rmb() dmb(ish) /* ishld does not exist on ARMv7 */ +#endif + +/* Avoid unresolved references emitted by GCC */ + +void __aeabi_unwind_cpp_pr0(void) +{ +} + +void __aeabi_unwind_cpp_pr1(void) +{ +} + +void __aeabi_unwind_cpp_pr2(void) +{ +} + +#endif /* __VDSO_COMPILER_H */ diff --git a/arch/arm64/kernel/vdso32/datapage.h b/arch/arm64/kernel/vdso32/datapage.h new file mode 100644 index 000000000000..fe3e216d94d1 --- /dev/null +++ b/arch/arm64/kernel/vdso32/datapage.h @@ -0,0 +1 @@ +#include "../vdso/datapage.h" diff --git a/arch/arm64/kernel/vdso32/sigreturn.S b/arch/arm64/kernel/vdso32/sigreturn.S new file mode 100644 index 000000000000..14e5f9ca34f9 --- /dev/null +++ b/arch/arm64/kernel/vdso32/sigreturn.S @@ -0,0 +1,76 @@ +/* + * Sigreturn trampolines for returning from a signal when the SA_RESTORER + * flag is not set. + * + * Copyright (C) 2016 ARM Limited + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Based on glibc's arm sa_restorer. While this is not strictly necessary, we + * provide both A32 and T32 versions, in accordance with the arm sigreturn + * code. + */ + +#include +#include +#include + +.macro sigreturn_trampoline name, syscall, regs_offset + /* + * We provide directives for enabling stack unwinding through the + * trampoline. On arm, CFI directives are only used for debugging (and + * the vDSO is stripped of debug information), so only the arm-specific + * unwinding directives are useful here. + */ + .fnstart + .save {r0-r15} + .pad #\regs_offset + /* + * It is necessary to start the unwind tables at least one instruction + * before the trampoline, as the unwinder will assume that the signal + * handler has been called from the trampoline, that is just before + * where the signal handler returns (mov r7, ...). + */ + nop +ENTRY(\name) + mov r7, #\syscall + svc #0 + .fnend + /* + * We would like to use ENDPROC, but the macro uses @ which is a + * comment symbol for arm assemblers, so directly use .type with % + * instead. + */ + .type \name, %function +END(\name) +.endm + + .text + + .arm + sigreturn_trampoline __kernel_sigreturn_arm, \ + __NR_sigreturn, \ + COMPAT_SIGFRAME_REGS_OFFSET + + sigreturn_trampoline __kernel_rt_sigreturn_arm, \ + __NR_rt_sigreturn, \ + COMPAT_RT_SIGFRAME_REGS_OFFSET + + .thumb + sigreturn_trampoline __kernel_sigreturn_thumb, \ + __NR_sigreturn, \ + COMPAT_SIGFRAME_REGS_OFFSET + + sigreturn_trampoline __kernel_rt_sigreturn_thumb, \ + __NR_rt_sigreturn, \ + COMPAT_RT_SIGFRAME_REGS_OFFSET diff --git a/arch/arm64/kernel/vdso32/vdso.S b/arch/arm64/kernel/vdso32/vdso.S new file mode 100644 index 000000000000..fe19ff70eb76 --- /dev/null +++ b/arch/arm64/kernel/vdso32/vdso.S @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2012 ARM Limited + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Author: Will Deacon + */ + +#include +#include +#include +#include + + .globl vdso32_start, vdso32_end + .section .rodata + .balign PAGE_SIZE +vdso32_start: + .incbin "arch/arm64/kernel/vdso32/vdso.so" + .balign PAGE_SIZE +vdso32_end: + + .previous diff --git a/arch/arm64/kernel/vdso32/vdso.lds.S b/arch/arm64/kernel/vdso32/vdso.lds.S new file mode 100644 index 000000000000..f95cb1c431fb --- /dev/null +++ b/arch/arm64/kernel/vdso32/vdso.lds.S @@ -0,0 +1,95 @@ +/* + * Adapted from arm64 version. + * + * GNU linker script for the VDSO library. + * + * Copyright (C) 2012 ARM Limited + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Author: Will Deacon + * Heavily based on the vDSO linker scripts for other archs. + */ + +#include +#include +#include + +OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") +OUTPUT_ARCH(arm) + +SECTIONS +{ + PROVIDE_HIDDEN(_vdso_data = . - PAGE_SIZE); + . = VDSO_LBASE + SIZEOF_HEADERS; + + .hash : { *(.hash) } :text + .gnu.hash : { *(.gnu.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .gnu.version : { *(.gnu.version) } + .gnu.version_d : { *(.gnu.version_d) } + .gnu.version_r : { *(.gnu.version_r) } + + .note : { *(.note.*) } :text :note + + .dynamic : { *(.dynamic) } :text :dynamic + + .rodata : { *(.rodata*) } :text + + .text : { *(.text*) } :text =0xe7f001f2 + + .got : { *(.got) } + .rel.plt : { *(.rel.plt) } + + /DISCARD/ : { + *(.note.GNU-stack) + *(.data .data.* .gnu.linkonce.d.* .sdata*) + *(.bss .sbss .dynbss .dynsbss) + } +} + +/* + * We must supply the ELF program headers explicitly to get just one + * PT_LOAD segment, and set the flags explicitly to make segments read-only. + */ +PHDRS +{ + text PT_LOAD FLAGS(5) FILEHDR PHDRS; /* PF_R|PF_X */ + dynamic PT_DYNAMIC FLAGS(4); /* PF_R */ + note PT_NOTE FLAGS(4); /* PF_R */ +} + +VERSION +{ + LINUX_2.6 { + global: + __vdso_clock_gettime; + __vdso_gettimeofday; + __vdso_clock_getres; + __vdso_time; + __kernel_sigreturn_arm; + __kernel_sigreturn_thumb; + __kernel_rt_sigreturn_arm; + __kernel_rt_sigreturn_thumb; + local: *; + }; +} + +/* + * Make the sigreturn code visible to the kernel. + */ +VDSO_compat_sigreturn_arm = __kernel_sigreturn_arm; +VDSO_compat_sigreturn_thumb = __kernel_sigreturn_thumb; +VDSO_compat_rt_sigreturn_arm = __kernel_rt_sigreturn_arm; +VDSO_compat_rt_sigreturn_thumb = __kernel_rt_sigreturn_thumb; diff --git a/arch/arm64/kernel/vdso32/vgettimeofday.c b/arch/arm64/kernel/vdso32/vgettimeofday.c new file mode 100644 index 000000000000..b73d4011993d --- /dev/null +++ b/arch/arm64/kernel/vdso32/vgettimeofday.c @@ -0,0 +1,3 @@ +#include "compiler.h" +#include "datapage.h" +#include "../../../../lib/vdso/vgettimeofday.c" diff --git a/crypto/Makefile b/crypto/Makefile index 896356eb4680..96b63d461f54 100755 --- a/crypto/Makefile +++ b/crypto/Makefile @@ -31,7 +31,6 @@ crypto_hash-y += ahash.o crypto_hash-y += shash.o obj-$(CONFIG_CRYPTO_HASH2) += crypto_hash.o -CFLAGS_testmgr.o = -fno-merge-constants cryptomgr-y := algboss.o testmgr.o obj-$(CONFIG_CRYPTO_MANAGER2) += cryptomgr.o diff --git a/drivers/battery_v2/include/sec_charging_common.h b/drivers/battery_v2/include/sec_charging_common.h index c55113f02a1c..055702edb442 100755 --- a/drivers/battery_v2/include/sec_charging_common.h +++ b/drivers/battery_v2/include/sec_charging_common.h @@ -1075,7 +1075,8 @@ static inline struct power_supply *get_power_supply_by_name(char *name) ret = -ENOENT; \ } else { \ if (psy->desc->function##_property != NULL) { \ - ret = psy->desc->function##_property(psy, (property), &(value)); \ + ret = psy->desc->function##_property(psy, \ + (enum power_supply_property) (property), &(value)); \ if (ret < 0) { \ pr_err("%s: Fail to %s "#function" (%d=>%d)\n", \ __func__, name, (property), ret); \ @@ -1156,7 +1157,7 @@ static inline struct power_supply *get_power_supply_by_name(char *name) cable_type == SEC_BATTERY_CABLE_NONE || \ cable_type == SEC_BATTERY_CABLE_OTG || \ cable_type == SEC_BATTERY_CABLE_POWER_SHARING) - + #define is_slate_mode(battery) ((battery->current_event & SEC_BAT_CURRENT_EVENT_SLATE) \ == SEC_BAT_CURRENT_EVENT_SLATE) #endif /* __SEC_CHARGING_COMMON_H */ diff --git a/drivers/battery_v2/max77705_charger.c b/drivers/battery_v2/max77705_charger.c index ec555157c2f7..e01e6fa04129 100755 --- a/drivers/battery_v2/max77705_charger.c +++ b/drivers/battery_v2/max77705_charger.c @@ -810,7 +810,7 @@ static int max77705_set_otg(struct max77705_charger_data *charger, int enable) enable > 0 ? "on" : "off"); if (charger->otg_on == enable ||lpcharge) return 0; - + ret = max77705_check_wcin_before_otg_on(charger); pr_info("%s: wc_state = %d\n", __func__, ret); if (ret < 0) @@ -1161,7 +1161,7 @@ static int max77705_chg_get_property(struct power_supply *psy, { struct max77705_charger_data *charger = power_supply_get_drvdata(psy); u8 reg_data; - enum power_supply_ext_property ext_psp = psp; + enum power_supply_ext_property ext_psp = (enum power_supply_ext_property) psp; switch (psp) { case POWER_SUPPLY_PROP_ONLINE: @@ -1304,7 +1304,7 @@ static int max77705_chg_set_property(struct power_supply *psy, u8 reg = 0; static u8 chg_int_state; int buck_state = ENABLE; - enum power_supply_ext_property ext_psp = psp; + enum power_supply_ext_property ext_psp = (enum power_supply_ext_property) psp; union power_supply_propval value = {0, }; /* check unlock status before does set the register */ @@ -2710,4 +2710,3 @@ module_exit(max77705_charger_exit); MODULE_DESCRIPTION("Samsung MAX77705 Charger Driver"); MODULE_AUTHOR("Samsung Electronics"); MODULE_LICENSE("GPL"); - diff --git a/drivers/battery_v2/max77705_fuelgauge.c b/drivers/battery_v2/max77705_fuelgauge.c index 347672a3a72e..6d2e0865a2fe 100755 --- a/drivers/battery_v2/max77705_fuelgauge.c +++ b/drivers/battery_v2/max77705_fuelgauge.c @@ -1804,7 +1804,7 @@ static int max77705_fg_get_property(struct power_supply *psy, static int abnormal_current_cnt; union power_supply_propval value; u8 data[2] = { 0, 0 }; - enum power_supply_ext_property ext_psp = psp; + enum power_supply_ext_property ext_psp = (enum power_supply_ext_property) psp; switch (psp) { /* Cell voltage (VCELL, mV) */ @@ -2112,7 +2112,7 @@ static int max77705_fg_set_property(struct power_supply *psy, power_supply_get_drvdata(psy); u8 data[2] = { 0, 0 }; static bool low_temp_wa; - enum power_supply_ext_property ext_psp = psp; + enum power_supply_ext_property ext_psp = (enum power_supply_ext_property) psp; switch (psp) { case POWER_SUPPLY_PROP_STATUS: @@ -2799,4 +2799,3 @@ module_exit(max77705_fuelgauge_exit); MODULE_DESCRIPTION("Samsung max77705 Fuel Gauge Driver"); MODULE_AUTHOR("Samsung Electronics"); MODULE_LICENSE("GPL"); - diff --git a/drivers/battery_v2/max77865_charger.c b/drivers/battery_v2/max77865_charger.c index 080e10347db4..82f985938895 100755 --- a/drivers/battery_v2/max77865_charger.c +++ b/drivers/battery_v2/max77865_charger.c @@ -854,7 +854,7 @@ static int max77865_chg_get_property(struct power_supply *psy, { struct max77865_charger_data *charger = power_supply_get_drvdata(psy); u8 reg_data; - enum power_supply_ext_property ext_psp = psp; + enum power_supply_ext_property ext_psp = (enum power_supply_ext_property)psp; switch (psp) { case POWER_SUPPLY_PROP_ONLINE: @@ -990,7 +990,7 @@ static int max77865_chg_set_property(struct power_supply *psy, u8 reg = 0; static u8 chg_int_state; int buck_state = ENABLE; - enum power_supply_ext_property ext_psp = psp; + enum power_supply_ext_property ext_psp = (enum power_supply_ext_property)psp; switch (psp) { /* val->intval : type */ diff --git a/drivers/battery_v2/max77865_fuelgauge.c b/drivers/battery_v2/max77865_fuelgauge.c index 717b6cf3afef..058bfd34acf0 100755 --- a/drivers/battery_v2/max77865_fuelgauge.c +++ b/drivers/battery_v2/max77865_fuelgauge.c @@ -1465,7 +1465,7 @@ static int max77865_fg_get_property(struct power_supply *psy, static int abnormal_current_cnt = 0; union power_supply_propval value; u8 data[2] = {0, 0}; - enum power_supply_ext_property ext_psp = psp; + enum power_supply_property ext_psp = psp; switch (psp) { /* Cell voltage (VCELL, mV) */ @@ -1719,7 +1719,7 @@ static int max77865_fg_set_property(struct power_supply *psy, struct max77865_fuelgauge_data *fuelgauge = power_supply_get_drvdata(psy); u8 data[2] = {0, 0}; static bool low_temp_wa = false; - enum power_supply_ext_property ext_psp = psp; + enum power_supply_property ext_psp = psp; switch (psp) { case POWER_SUPPLY_PROP_STATUS: diff --git a/drivers/battery_v2/mfc_charger.c b/drivers/battery_v2/mfc_charger.c index d22bea823794..b9d70d509388 100755 --- a/drivers/battery_v2/mfc_charger.c +++ b/drivers/battery_v2/mfc_charger.c @@ -56,7 +56,7 @@ static irqreturn_t mfc_wpc_irq_thread(int irq, void *irq_data); #define MAX_I2C_ERROR_COUNT 30 static void mfc_check_i2c_error(struct mfc_charger_data *charger, bool is_error) { - charger->i2c_error_count = + charger->i2c_error_count = (charger->wc_w_state && gpio_get_value(charger->pdata->wpc_det) && is_error) ? (charger->i2c_error_count + 1) : 0; @@ -1832,7 +1832,7 @@ static int mfc_chg_get_property(struct power_supply *psy, union power_supply_propval *val) { struct mfc_charger_data *charger = power_supply_get_drvdata(psy); - enum power_supply_ext_property ext_psp = psp; + enum power_supply_ext_property ext_psp = (enum power_supply_ext_property) psp; // union power_supply_propval value; u8 mst_mode; u8 reg_data; @@ -2089,7 +2089,7 @@ static int mfc_chg_set_property(struct power_supply *psy, const union power_supply_propval *val) { struct mfc_charger_data *charger = power_supply_get_drvdata(psy); - enum power_supply_ext_property ext_psp = psp; + enum power_supply_ext_property ext_psp = (enum power_supply_ext_property) psp; int vout, vrect, iout, freq, i = 0; u8 tmp = 0; /* int ret; */ @@ -3819,4 +3819,3 @@ module_exit(mfc_charger_exit); MODULE_DESCRIPTION("Samsung MFC Charger Driver"); MODULE_AUTHOR("Samsung Electronics"); MODULE_LICENSE("GPL"); - diff --git a/drivers/battery_v2/sec_battery.c b/drivers/battery_v2/sec_battery.c index 29a7d39b4ae0..696ae207a206 100755 --- a/drivers/battery_v2/sec_battery.c +++ b/drivers/battery_v2/sec_battery.c @@ -3281,7 +3281,7 @@ static void sec_bat_ext_event_work(struct work_struct *work) battery->cable_type == SEC_BATTERY_CABLE_WIRELESS_TX) { pr_info("%s : Call is off during Wireless Pack or TX\n",__func__); } - + /* process phm */ if(battery->wc_rx_phm_mode) { char wpc_en_status[2]; @@ -3987,7 +3987,7 @@ static void sec_bat_cable_work(struct work_struct *work) #endif if (current_cable_type == SEC_BATTERY_CABLE_HV_TA_CHG_LIMIT) - current_cable_type = SEC_BATTERY_CABLE_9V_TA; + current_cable_type = SEC_BATTERY_CABLE_9V_TA; battery->cable_type = current_cable_type; battery->wpc_vout_level = WIRELESS_VOUT_10V; @@ -4253,7 +4253,7 @@ static int sec_bat_set_property(struct power_supply *psy, int current_cable_type = SEC_BATTERY_CABLE_NONE; int full_check_type = SEC_BATTERY_FULLCHARGED_NONE; union power_supply_propval value = {0, }; - enum power_supply_ext_property ext_psp = psp; + enum power_supply_ext_property ext_psp = (enum power_supply_ext_property) psp; dev_dbg(battery->dev, "%s: (%d,%d)\n", __func__, psp, val->intval); @@ -4523,7 +4523,7 @@ static int sec_bat_get_property(struct power_supply *psy, { struct sec_battery_info *battery = power_supply_get_drvdata(psy); union power_supply_propval value = {0, }; - enum power_supply_ext_property ext_psp = psp; + enum power_supply_ext_property ext_psp = (enum power_supply_ext_property) psp; switch (psp) { case POWER_SUPPLY_PROP_STATUS: @@ -4772,7 +4772,7 @@ static int sec_ac_get_property(struct power_supply *psy, union power_supply_propval *val) { struct sec_battery_info *battery = power_supply_get_drvdata(psy); - enum power_supply_ext_property ext_psp = psp; + enum power_supply_ext_property ext_psp = (enum power_supply_ext_property) psp; switch (psp) { case POWER_SUPPLY_PROP_ONLINE: @@ -4867,7 +4867,7 @@ static int sec_wireless_set_property(struct power_supply *psy, const union power_supply_propval *val) { struct sec_battery_info *battery = power_supply_get_drvdata(psy); - enum power_supply_ext_property ext_psp = psp; + enum power_supply_ext_property ext_psp = (enum power_supply_ext_property) psp; switch (psp) { case POWER_SUPPLY_PROP_ONLINE: @@ -4962,7 +4962,7 @@ static int sec_wireless_set_property(struct power_supply *psy, case POWER_SUPPLY_EXT_PROP_CALL_EVENT: if(val->intval == 1) { pr_info("%s : PHM enabled\n",__func__); - battery->wc_rx_phm_mode = true; + battery->wc_rx_phm_mode = true; } break; default: diff --git a/drivers/bts/cal_bts9810.c b/drivers/bts/cal_bts9810.c index aed6fb80bf5a..7f4beeee914e 100755 --- a/drivers/bts/cal_bts9810.c +++ b/drivers/bts/cal_bts9810.c @@ -10,7 +10,7 @@ * */ -#include "cal_bts8895.h" +#include "cal_bts9810.h" #include #define LOG(x, ...) \ diff --git a/drivers/ccic/max77705_alternate.c b/drivers/ccic/max77705_alternate.c index 00dde0117178..291016e23b2f 100755 --- a/drivers/ccic/max77705_alternate.c +++ b/drivers/ccic/max77705_alternate.c @@ -972,8 +972,10 @@ void max77705_send_dex_fan_unstructured_vdm_message(void *data, int cmd) SS_DEX_UNSTRUCTURED_VDM.byte_data.BITS.Num_Of_VDO = 2; SS_DEX_UNSTRUCTURED_VDM.byte_data.BITS.Cmd_Type = ACK; SS_DEX_UNSTRUCTURED_VDM.byte_data.BITS.Reserved = 0; - SS_DEX_UNSTRUCTURED_VDM.VDO_MSG.VDO[0] = SWAP_UINT32(0x0000E804); - SS_DEX_UNSTRUCTURED_VDM.VDO_MSG.VDO[1] = SWAP_UINT32(0x100120A0); + //SS_DEX_UNSTRUCTURED_VDM.VDO_MSG.VDO[0] = SWAP_UINT32(0x0000E804); + //SS_DEX_UNSTRUCTURED_VDM.VDO_MSG.VDO[1] = SWAP_UINT32(0x100120A0); + SS_DEX_UNSTRUCTURED_VDM.VDO_MSG.VDO[0] = 0x04E80000; + SS_DEX_UNSTRUCTURED_VDM.VDO_MSG.VDO[1] = 0xA0200110; pr_info("%s: cmd : 0x%x\n", __func__, cmd); memcpy(SendMSG, &SS_DEX_UNSTRUCTURED_VDM, len); diff --git a/drivers/ccic/max77705_cc.c b/drivers/ccic/max77705_cc.c index 991b80d7519e..568d963a2a3f 100755 --- a/drivers/ccic/max77705_cc.c +++ b/drivers/ccic/max77705_cc.c @@ -639,8 +639,7 @@ static void max77705_ccstat_irq_handler(void *data, int irq) psy_charger = power_supply_get_by_name("max77705-charger"); if (psy_charger) { val.intval = 1; - psy_charger->desc->set_property(psy_charger, - POWER_SUPPLY_EXT_PROP_CHGINSEL, &val); + psy_do_property("max77705-charger", set, POWER_SUPPLY_EXT_PROP_CHGINSEL, val); } else { pr_err("%s: Fail to get psy charger\n", __func__); } diff --git a/drivers/ccic/max77705_pd.c b/drivers/ccic/max77705_pd.c index d494748d2110..285ea6b86833 100755 --- a/drivers/ccic/max77705_pd.c +++ b/drivers/ccic/max77705_pd.c @@ -543,8 +543,7 @@ static void max77705_pd_check_pdmsg(struct max77705_usbc_platform_data *usbc_dat psy_charger = power_supply_get_by_name("max77705-charger"); if (psy_charger) { val.intval = 0; - psy_charger->desc->set_property(psy_charger, - POWER_SUPPLY_EXT_PROP_CHGINSEL, &val); + psy_do_property("max77705-charger", set, POWER_SUPPLY_EXT_PROP_CHGINSEL, val); } else { pr_err("%s: Fail to get psy charger\n", __func__); } @@ -740,7 +739,7 @@ static void max77705_datarole_irq_handler(void *data, int irq) if (pd_data->previous_dr != 0xFF) msg_maxim("%s detach previous usb connection\n", __func__); max77705_notify_dr_status(usbc_data, 1); -#if defined(CONFIG_TYPEC) +#if defined(CONFIG_TYPEC) if (usbc_data->typec_try_state_change == TRY_ROLE_SWAP_DR || usbc_data->typec_try_state_change == TRY_ROLE_SWAP_TYPE) { /* Role change try and new mode detected */ @@ -748,7 +747,7 @@ static void max77705_datarole_irq_handler(void *data, int irq) usbc_data->typec_try_state_change = TRY_ROLE_SWAP_NONE; complete(&usbc_data->typec_reverse_completion); } -#endif +#endif } msg_maxim(" UFP"); break; @@ -761,7 +760,7 @@ static void max77705_datarole_irq_handler(void *data, int irq) msg_maxim("%s detach previous usb connection\n", __func__); max77705_notify_dr_status(usbc_data, 1); -#if defined(CONFIG_TYPEC) +#if defined(CONFIG_TYPEC) if (usbc_data->typec_try_state_change == TRY_ROLE_SWAP_DR || usbc_data->typec_try_state_change == TRY_ROLE_SWAP_TYPE) { /* Role change try and new mode detected */ @@ -769,7 +768,7 @@ static void max77705_datarole_irq_handler(void *data, int irq) usbc_data->typec_try_state_change = TRY_ROLE_SWAP_NONE; complete(&usbc_data->typec_reverse_completion); } -#endif +#endif if (usbc_data->cc_data->current_pr == SNK && !(usbc_data->is_first_booting)) { max77705_vdm_process_set_identity_req(usbc_data); msg_maxim("SEND THE IDENTITY REQUEST FROM DFP HANDLER"); diff --git a/drivers/crypto/fmp/Makefile b/drivers/crypto/fmp/Makefile index 242064d9e25e..5e961784815d 100755 --- a/drivers/crypto/fmp/Makefile +++ b/drivers/crypto/fmp/Makefile @@ -1,9 +1,16 @@ # Exynos FMP/SMU makefile #ccflags-y := -DCONFIG_EXYNOS_FMP_FIPS_FUNC_TEST obj-$(CONFIG_EXYNOS_SMU) += smu_dev.o +CC_NO_CLANG := $(shell $(CC) -dM -E -x c /dev/null | grep -Fq "__clang__"; echo $$?) +ifeq ($(CC_NO_CLANG), 0) +ccflags-y += -DCC_USE_CLANG +CFLAGS_fmp_fips_selftest.o = -fno-merge-all-constants +endif +ifeq ($(CC_NO_CLANG), 1) +CFLAGS_fmp_fips_selftest.o = -fno-merge-constants +endif obj-$(CONFIG_EXYNOS_FMP_FIPS) += first_file.o obj-$(CONFIG_EXYNOS_FMP) += fmp_dev.o fmp_lib.o -CFLAGS_fmp_fips_selftest.o = -fno-merge-constants obj-$(CONFIG_EXYNOS_FMP_FIPS) += fmp_fips_main.o fmp_fips_fops.o fmp_fips_selftest.o \ fmp_fips_integrity.o hmac-sha256.o \ fmp_fips_cipher.o diff --git a/drivers/crypto/fmp/first_file.c b/drivers/crypto/fmp/first_file.c index acb91db114d3..8e1a44370c23 100755 --- a/drivers/crypto/fmp/first_file.c +++ b/drivers/crypto/fmp/first_file.c @@ -15,5 +15,5 @@ const unsigned char first_fmp_rodata = 0x10; __attribute__ ((section(".text"), unused)) void first_fmp_text(void){} -__attribute__ ((section(".init.text"), optimize("-O0"), unused)) -static void first_fmp_init(void){}; +__attribute__ ((section(".init.text"), unused)) +void first_fmp_init(void){}; diff --git a/drivers/crypto/fmp/last_file.c b/drivers/crypto/fmp/last_file.c index c0d405d5d829..9b9b7a6eded8 100755 --- a/drivers/crypto/fmp/last_file.c +++ b/drivers/crypto/fmp/last_file.c @@ -17,5 +17,5 @@ const unsigned char last_fmp_rodata = 0x20; __attribute__ ((section(".text"), unused)) void last_fmp_text(void){} -__attribute__ ((section(".init.text"), optimize("-O0"), unused)) -static void last_fmp_init(void){}; +__attribute__ ((section(".init.text"), unused)) +void last_fmp_init(void){}; diff --git a/drivers/fingerprint/vfs8xxx.c b/drivers/fingerprint/vfs8xxx.c index f8de188749d2..5003807d0408 100755 --- a/drivers/fingerprint/vfs8xxx.c +++ b/drivers/fingerprint/vfs8xxx.c @@ -1328,7 +1328,7 @@ static int vfsspi_parse_dt(struct device *dev, struct vfsspi_device_data *data) if (of_property_read_string_index(np, "vfsspi-chipid", 0, (const char **)&data->chipid)) - data->chipid = '\0'; + data->chipid = NULL; pr_info("%s: chipid: %s\n", __func__, data->chipid); if (of_property_read_u32(np, "vfsspi-wog", &data->detect_mode)) diff --git a/drivers/gator_5.27/gator.h b/drivers/gator_5.27/gator.h index 8ea2f83455b7..86b1208d18ed 100755 --- a/drivers/gator_5.27/gator.h +++ b/drivers/gator_5.27/gator.h @@ -14,9 +14,21 @@ #include #include -#define GATOR_PERF_PMU_SUPPORT (defined(CONFIG_PERF_EVENTS) && (!(defined(__arm__) || defined(__aarch64__)) || defined(CONFIG_HW_PERF_EVENTS))) -#define GATOR_CPU_FREQ_SUPPORT defined(CONFIG_CPU_FREQ) -#define GATOR_IKS_SUPPORT defined(CONFIG_BL_SWITCHER) +#if (defined(CONFIG_PERF_EVENTS) && (!(defined(__arm__) || defined(__aarch64__)) || defined(CONFIG_HW_PERF_EVENTS))) + #define GATOR_PERF_PMU_SUPPORT 1 +#else + #define GATOR_PERF_PMU_SUPPORT 0 +#endif +#if defined(CONFIG_CPU_FREQ) + #define GATOR_CPU_FREQ_SUPPORT 1 +#else + #define GATOR_CPU_FREQ_SUPPORT 0 +#endif +#if defined(CONFIG_BL_SWITCHER) + #define GATOR_IKS_SUPPORT 1 +#else + #define GATOR_IKS_SUPPORT 0 +#endif /* cpu ids */ #define CORTEX_A5 0x41c05 diff --git a/drivers/gator_5.27/gator_events_meminfo.c b/drivers/gator_5.27/gator_events_meminfo.c index 5c0911b2bc47..4a3d1ab4d174 100755 --- a/drivers/gator_5.27/gator_events_meminfo.c +++ b/drivers/gator_5.27/gator_events_meminfo.c @@ -17,7 +17,11 @@ #include #include -#define USE_THREAD defined(CONFIG_PREEMPT_RT_FULL) +#if defined(CONFIG_PREEMPT_RT_FULL) + #define USE_THREAD 1 +#else + #define USE_THREAD 0 +#endif enum { MEMINFO_MEMFREE, @@ -237,7 +241,7 @@ static void do_read(void) break; case MEMINFO_CACHED: // total_swapcache_pages is not exported so the result is slightly different, but hopefully not too much - value = (global_page_state(NR_FILE_PAGES) /*- total_swapcache_pages()*/ - info.bufferram) * PAGE_SIZE; + value = (global_node_page_state(NR_FILE_PAGES) /*- total_swapcache_pages()*/ - info.bufferram) * PAGE_SIZE; break; case MEMINFO_SLAB: value = (global_page_state(NR_SLAB_RECLAIMABLE) + global_page_state(NR_SLAB_UNRECLAIMABLE)) * PAGE_SIZE; diff --git a/drivers/gpu/arm/exynos/backend/dummy/gpexbe_secure_dummy.c b/drivers/gpu/arm/exynos/backend/dummy/gpexbe_secure_dummy.c index 8db5c301ee4b..df847b93cc37 100755 --- a/drivers/gpu/arm/exynos/backend/dummy/gpexbe_secure_dummy.c +++ b/drivers/gpu/arm/exynos/backend/dummy/gpexbe_secure_dummy.c @@ -25,7 +25,7 @@ #include #include -struct protected_mode_ops *gpexbe_secure_get_protected_mode_ops() +struct protected_mode_ops *gpexbe_secure_get_protected_mode_ops(void) { return NULL; } diff --git a/drivers/gpu/arm/exynos/backend/gpexbe_bts_v1.c b/drivers/gpu/arm/exynos/backend/gpexbe_bts_v1.c index 0c6e4ffb37f8..9941112dcc40 100755 --- a/drivers/gpu/arm/exynos/backend/gpexbe_bts_v1.c +++ b/drivers/gpu/arm/exynos/backend/gpexbe_bts_v1.c @@ -30,12 +30,12 @@ int gpexbe_bts_set_bts_mo(int val) return 0; } -int gpexbe_bts_init() +int gpexbe_bts_init(void) { return 0; } -void gpexbe_bts_term() +void gpexbe_bts_term(void) { return; } diff --git a/drivers/gpu/arm/exynos/backend/gpexbe_clock.c b/drivers/gpu/arm/exynos/backend/gpexbe_clock.c index c74d60408549..388c66d0484e 100755 --- a/drivers/gpu/arm/exynos/backend/gpexbe_clock.c +++ b/drivers/gpu/arm/exynos/backend/gpexbe_clock.c @@ -60,12 +60,12 @@ int gpexbe_clock_get_rate_asv_table(struct freq_volt *fv_array, int level_num) return ret; } -int gpexbe_clock_get_boot_freq() +int gpexbe_clock_get_boot_freq(void) { return pm_info.boot_clock; } -int gpexbe_clock_get_max_freq() +int gpexbe_clock_get_max_freq(void) { return pm_info.max_clock_limit; } @@ -89,12 +89,12 @@ int gpexbe_clock_set_rate(int clk) return ret; } -int gpexbe_clock_get_rate() +int gpexbe_clock_get_rate(void) { return cal_dfs_get_rate(cal_id); } -int gpexbe_clock_init() +int gpexbe_clock_init(void) { cal_id = gpexbe_devicetree_get_int(g3d_cmu_cal_id); @@ -111,7 +111,7 @@ int gpexbe_clock_init() return 0; } -void gpexbe_clock_term() +void gpexbe_clock_term(void) { cal_id = 0; pm_info.boot_clock = 0; diff --git a/drivers/gpu/arm/exynos/backend/gpexbe_debug_v1.c b/drivers/gpu/arm/exynos/backend/gpexbe_debug_v1.c index d50629cd9e22..4b27b79cc6e8 100755 --- a/drivers/gpu/arm/exynos/backend/gpexbe_debug_v1.c +++ b/drivers/gpu/arm/exynos/backend/gpexbe_debug_v1.c @@ -36,12 +36,12 @@ void gpexbe_debug_dbg_snapshot_freq_out(int freq_before, int freq_after) return; } -int gpexbe_debug_init() +int gpexbe_debug_init(void) { return 0; } -void gpexbe_debug_term() +void gpexbe_debug_term(void) { return; } diff --git a/drivers/gpu/arm/exynos/backend/gpexbe_notifier.c b/drivers/gpu/arm/exynos/backend/gpexbe_notifier.c index 35efc106faac..959cf4830192 100755 --- a/drivers/gpu/arm/exynos/backend/gpexbe_notifier.c +++ b/drivers/gpu/arm/exynos/backend/gpexbe_notifier.c @@ -106,7 +106,7 @@ static struct notifier_block gpu_tmu_nb = { .notifier_call = tmu_notifier, }; -int gpexbe_notifier_init() +int gpexbe_notifier_init(void) { int ret = 0; @@ -123,7 +123,7 @@ int gpexbe_notifier_init() return ret; } -void gpexbe_notifier_term() +void gpexbe_notifier_term(void) { gpexbe_notifier_internal_remove(GPU_NOTIFIER_MIN_LOCK, &gpu_min_qos_notifier); gpexbe_notifier_internal_remove(GPU_NOTIFIER_MAX_LOCK, &gpu_max_qos_notifier); diff --git a/drivers/gpu/arm/exynos/backend/gpexbe_pm.c b/drivers/gpu/arm/exynos/backend/gpexbe_pm.c index 965225e7bc1b..6e6ca3ddacd5 100755 --- a/drivers/gpu/arm/exynos/backend/gpexbe_pm.c +++ b/drivers/gpu/arm/exynos/backend/gpexbe_pm.c @@ -65,7 +65,7 @@ static struct exynos_pm_domain *gpu_get_pm_domain(const char *g3d_genpd_name) return pd; } -int gpexbe_pm_get_status() +int gpexbe_pm_get_status(void) { int ret = 0; unsigned int val = 0xf; @@ -76,18 +76,18 @@ int gpexbe_pm_get_status() return ret; } -struct exynos_pm_domain *gpexbe_pm_get_exynos_pm_domain() +struct exynos_pm_domain *gpexbe_pm_get_exynos_pm_domain(void) { return exynos_pm_domain; } -void gpexbe_pm_access_lock() +void gpexbe_pm_access_lock(void) { //DEBUG_ASSERT(exynos_pm_domain) mutex_lock(&exynos_pm_domain->access_lock); } -void gpexbe_pm_access_unlock() +void gpexbe_pm_access_unlock(void) { //DEBUG_ASSERT(exynos_pm_domain) mutex_unlock(&exynos_pm_domain->access_lock); @@ -130,17 +130,17 @@ static int gpexbe_pm_pd_control(int target_status) return 0; } -int gpexbe_pm_pd_control_up() +int gpexbe_pm_pd_control_up(void) { return gpexbe_pm_pd_control(1); } -int gpexbe_pm_pd_control_down() +int gpexbe_pm_pd_control_down(void) { return gpexbe_pm_pd_control(0); } -int gpexbe_pm_init() +int gpexbe_pm_init(void) { const char *g3d_genpd_name; @@ -156,7 +156,7 @@ int gpexbe_pm_init() return 0; } -void gpexbe_pm_term() +void gpexbe_pm_term(void) { exynos_pm_domain = NULL; } diff --git a/drivers/gpu/arm/exynos/backend/gpexbe_qos.c b/drivers/gpu/arm/exynos/backend/gpexbe_qos.c index b979a68c67c7..701e8c89407f 100755 --- a/drivers/gpu/arm/exynos/backend/gpexbe_qos.c +++ b/drivers/gpu/arm/exynos/backend/gpexbe_qos.c @@ -1,11 +1,11 @@ #include -int gpexbe_qos_init() +int gpexbe_qos_init(void) { return 0; } -void gpexbe_qos_term() +void gpexbe_qos_term(void) { /* TODO: unset and unregister */ return; diff --git a/drivers/gpu/arm/exynos/backend/gpexbe_qos_internal.h b/drivers/gpu/arm/exynos/backend/gpexbe_qos_internal.h index a85fedfcc595..89b5b40546f6 100755 --- a/drivers/gpu/arm/exynos/backend/gpexbe_qos_internal.h +++ b/drivers/gpu/arm/exynos/backend/gpexbe_qos_internal.h @@ -18,7 +18,7 @@ * http://www.gnu.org/licenses/gpl-2.0.html. */ -static inline pmqos_flag_check(mali_pmqos_flags type, mali_pmqos_flags in) +static inline int pmqos_flag_check(mali_pmqos_flags type, mali_pmqos_flags in) { return (type & in) == in; } diff --git a/drivers/gpu/arm/exynos/backend/gpexbe_smc.c b/drivers/gpu/arm/exynos/backend/gpexbe_smc.c index 5c88b8fb767a..d5bfd07f0427 100755 --- a/drivers/gpu/arm/exynos/backend/gpexbe_smc.c +++ b/drivers/gpu/arm/exynos/backend/gpexbe_smc.c @@ -41,7 +41,7 @@ struct _smc_info { static struct _smc_info smc_info; -int gpexbe_smc_protection_enable() +int gpexbe_smc_protection_enable(void) { int err; unsigned long flags; @@ -68,7 +68,7 @@ int gpexbe_smc_protection_enable() return err; } -int gpexbe_smc_protection_disable() +int gpexbe_smc_protection_disable(void) { int err; unsigned long flags; @@ -104,20 +104,20 @@ int gpexbe_smc_protection_disable() #define SMC_DRM_G3D_POWER_ON SMC_DRM_G3D_PPCFW_RESTORE #endif -void gpexbe_smc_notify_power_on() +void gpexbe_smc_notify_power_on(void) { exynos_smc(SMC_DRM_G3D_POWER_ON, 0, 0, 0); } -void gpexbe_smc_notify_power_off() +void gpexbe_smc_notify_power_off(void) { exynos_smc(SMC_DRM_G3D_POWER_OFF, 0, 0, 0); } #else -void gpexbe_smc_notify_power_on() +void gpexbe_smc_notify_power_on(void) { } -void gpexbe_smc_notify_power_off() +void gpexbe_smc_notify_power_off(void) { } #endif diff --git a/drivers/gpu/arm/exynos/frontend/gpex_clock.c b/drivers/gpu/arm/exynos/frontend/gpex_clock.c index 94b6a0fff1cc..a3caf261eb99 100755 --- a/drivers/gpu/arm/exynos/frontend/gpex_clock.c +++ b/drivers/gpu/arm/exynos/frontend/gpex_clock.c @@ -37,31 +37,31 @@ static struct _clock_info clk_info; -int gpex_clock_get_boot_clock() +int gpex_clock_get_boot_clock(void) { return clk_info.boot_clock; } -int gpex_clock_get_max_clock() +int gpex_clock_get_max_clock(void) { return clk_info.gpu_max_clock; } -int gpex_clock_get_max_clock_limit() +int gpex_clock_get_max_clock_limit(void) { return clk_info.gpu_max_clock_limit; } -int gpex_clock_get_min_clock() +int gpex_clock_get_min_clock(void) { return clk_info.gpu_min_clock; } -int gpex_clock_get_cur_clock() +int gpex_clock_get_cur_clock(void) { return clk_info.cur_clock; } -int gpex_clock_get_max_lock() +int gpex_clock_get_max_lock(void) { return clk_info.max_lock; } -int gpex_clock_get_min_lock() +int gpex_clock_get_min_lock(void) { return clk_info.min_lock; } @@ -331,7 +331,7 @@ int gpex_clock_init(struct device **dev) return 0; } -void gpex_clock_term() +void gpex_clock_term(void) { /* TODO: reset other clk_info variables too */ clk_info.kbdev = NULL; @@ -352,7 +352,7 @@ int gpex_clock_get_table_idx(int clock) return -1; } -int gpex_clock_get_clock_slow() +int gpex_clock_get_clock_slow(void) { return gpexbe_clock_get_rate(); } @@ -404,7 +404,7 @@ int gpex_clock_set(int clk) return ret; } -int gpex_clock_prepare_runtime_off() +int gpex_clock_prepare_runtime_off(void) { gpex_clock_update_time_in_state(clk_info.cur_clock); @@ -558,12 +558,12 @@ int gpex_clock_lock_clock(gpex_clock_lock_cmd_t lock_command, gpex_clock_lock_ty return 0; } -void gpex_clock_mutex_lock() +void gpex_clock_mutex_lock(void) { mutex_lock(&clk_info.clock_lock); } -void gpex_clock_mutex_unlock() +void gpex_clock_mutex_unlock(void) { mutex_unlock(&clk_info.clock_lock); } diff --git a/drivers/gpu/arm/exynos/frontend/gpex_dvfs.c b/drivers/gpu/arm/exynos/frontend/gpex_dvfs.c index 899087ea90f0..8523dab92bfe 100755 --- a/drivers/gpu/arm/exynos/frontend/gpex_dvfs.c +++ b/drivers/gpu/arm/exynos/frontend/gpex_dvfs.c @@ -172,12 +172,12 @@ static void gpu_dvfs_timer_control(bool timer_state) spin_unlock_irqrestore(&dvfs.spinlock, flags); } -void gpex_dvfs_start() +void gpex_dvfs_start(void) { gpu_dvfs_timer_control(true); } -void gpex_dvfs_stop() +void gpex_dvfs_stop(void) { gpu_dvfs_timer_control(false); } @@ -220,17 +220,17 @@ static int gpu_dvfs_on_off(bool enable) return 0; } -int gpex_dvfs_enable() +int gpex_dvfs_enable(void) { return gpu_dvfs_on_off(true); } -int gpex_dvfs_disable() +int gpex_dvfs_disable(void) { return gpu_dvfs_on_off(false); } -static int gpu_dvfs_handler_init() +static int gpu_dvfs_handler_init(void) { if (!dvfs.status) dvfs.status = true; @@ -243,7 +243,7 @@ static int gpu_dvfs_handler_init() return 0; } -static int gpu_dvfs_handler_deinit() +static int gpu_dvfs_handler_deinit(void) { if (dvfs.status) dvfs.status = false; @@ -295,7 +295,7 @@ int gpex_dvfs_init(struct device **dev) return 0; } -void gpex_dvfs_term() +void gpex_dvfs_term(void) { /* DVFS stuff */ gpu_pm_metrics_term(); @@ -303,7 +303,7 @@ void gpex_dvfs_term() dvfs.kbdev = NULL; } -int gpex_dvfs_get_status() +int gpex_dvfs_get_status(void) { return dvfs.status; } diff --git a/drivers/gpu/arm/exynos/frontend/gpex_platform.c b/drivers/gpu/arm/exynos/frontend/gpex_platform.c index 512340222382..ddafa4220c5a 100755 --- a/drivers/gpu/arm/exynos/frontend/gpex_platform.c +++ b/drivers/gpu/arm/exynos/frontend/gpex_platform.c @@ -96,7 +96,7 @@ int gpex_platform_init(struct device **dev) return 0; } -void gpex_platform_term() +void gpex_platform_term(void) { runtime_test_runner_term(); diff --git a/drivers/gpu/arm/exynos/frontend/gpex_pm.c b/drivers/gpu/arm/exynos/frontend/gpex_pm.c index 0a392e251201..335bc14a289b 100755 --- a/drivers/gpu/arm/exynos/frontend/gpex_pm.c +++ b/drivers/gpu/arm/exynos/frontend/gpex_pm.c @@ -101,17 +101,17 @@ int gpex_pm_get_status(bool clock_lock) } /* Read the power_status value set by gpex_pm module */ -int gpex_pm_get_power_status() +int gpex_pm_get_power_status(void) { return pm.power_status; } -void gpex_pm_lock() +void gpex_pm_lock(void) { gpexbe_pm_access_lock(); } -void gpex_pm_unlock() +void gpex_pm_unlock(void) { gpexbe_pm_access_unlock(); } diff --git a/drivers/gpu/arm/exynos/frontend/gpex_qos.c b/drivers/gpu/arm/exynos/frontend/gpex_qos.c index 51498d51591d..c6324651ce88 100755 --- a/drivers/gpu/arm/exynos/frontend/gpex_qos.c +++ b/drivers/gpu/arm/exynos/frontend/gpex_qos.c @@ -118,7 +118,7 @@ int gpex_qos_unset(gpex_qos_flag flags) return 0; } -int gpex_qos_init() +int gpex_qos_init(void) { int i = 0; gpu_dt *dt = gpexbe_devicetree_get_gpu_dt(); @@ -179,7 +179,7 @@ int gpex_qos_init() return 0; } -void gpex_qos_term() +void gpex_qos_term(void) { gpexbe_qos_request_remove(PMQOS_MIF | PMQOS_LITTLE | PMQOS_MIDDLE | PMQOS_BIG | PMQOS_MIN | PMQOS_MAX); diff --git a/drivers/gpu/arm/exynos/frontend/gpex_thermal.c b/drivers/gpu/arm/exynos/frontend/gpex_thermal.c index 298b6ecd83f1..fbc10a0df780 100755 --- a/drivers/gpu/arm/exynos/frontend/gpex_thermal.c +++ b/drivers/gpu/arm/exynos/frontend/gpex_thermal.c @@ -37,7 +37,7 @@ void gpex_thermal_set_status(bool status) thermal.tmu_enabled = status; } -int gpex_thermal_gpu_normal() +int gpex_thermal_gpu_normal(void) { int ret = 0; ret = gpex_clock_lock_clock(GPU_CLOCK_MAX_UNLOCK, TMU_LOCK, 0); @@ -158,7 +158,7 @@ static void gpex_thermal_create_sysfs_file(void) /*********************************************************************** * INIT, TERM FUNCTIONS ***********************************************************************/ -int gpex_thermal_init() +int gpex_thermal_init(void) { gpex_thermal_create_sysfs_file(); @@ -167,7 +167,7 @@ int gpex_thermal_init() return 0; } -void gpex_thermal_term() +void gpex_thermal_term(void) { thermal.tmu_enabled = false; diff --git a/drivers/gpu/arm/exynos/frontend/gpu_dvfs_governor.c b/drivers/gpu/arm/exynos/frontend/gpu_dvfs_governor.c index e1549918a992..47cda7c22267 100755 --- a/drivers/gpu/arm/exynos/frontend/gpu_dvfs_governor.c +++ b/drivers/gpu/arm/exynos/frontend/gpu_dvfs_governor.c @@ -31,7 +31,7 @@ static struct dvfs_info *dvfs; /* TODO: This should be moved to DVFS module */ -int gpex_dvfs_set_clock_callback() +int gpex_dvfs_set_clock_callback(void) { unsigned long flags; int level = 0; diff --git a/drivers/gpu/arm/exynos/mali_exynos_kbase_entrypoint.c b/drivers/gpu/arm/exynos/mali_exynos_kbase_entrypoint.c index 8dc15d962f2e..cb9245c71fee 100755 --- a/drivers/gpu/arm/exynos/mali_exynos_kbase_entrypoint.c +++ b/drivers/gpu/arm/exynos/mali_exynos_kbase_entrypoint.c @@ -257,27 +257,27 @@ void mali_exynos_set_thread_affinity(void) gpex_cmar_sched_set_affinity(); } -void mali_exynos_coherency_reg_map() +void mali_exynos_coherency_reg_map(void) { gpexbe_llc_coherency_reg_map(); } -void mali_exynos_coherency_reg_unmap() +void mali_exynos_coherency_reg_unmap(void) { gpexbe_llc_coherency_reg_unmap(); } -void mali_exynos_coherency_set_coherency_feature() +void mali_exynos_coherency_set_coherency_feature(void) { gpexbe_llc_coherency_set_coherency_feature(); } -void mali_exynos_llc_set_aruser() +void mali_exynos_llc_set_aruser(void) { gpexbe_llc_coherency_set_aruser(); } -void mali_exynos_llc_set_awuser() +void mali_exynos_llc_set_awuser(void) { gpexbe_llc_coherency_set_awuser(); } diff --git a/drivers/gpu/arm/exynos/tests/runtime_test_runner_dummy.c b/drivers/gpu/arm/exynos/tests/runtime_test_runner_dummy.c index 51015909c0b7..b1e3915ff3c8 100755 --- a/drivers/gpu/arm/exynos/tests/runtime_test_runner_dummy.c +++ b/drivers/gpu/arm/exynos/tests/runtime_test_runner_dummy.c @@ -20,11 +20,11 @@ #include -int runtime_test_runner_init() +int runtime_test_runner_init(void) { return 0; } -void runtime_test_runner_term() +void runtime_test_runner_term(void) { } diff --git a/drivers/gpu/arm/exynos/workarounds/gpexwa_ehmp.c b/drivers/gpu/arm/exynos/workarounds/gpexwa_ehmp.c index 31333e938c1e..d6b46b6b6297 100644 --- a/drivers/gpu/arm/exynos/workarounds/gpexwa_ehmp.c +++ b/drivers/gpu/arm/exynos/workarounds/gpexwa_ehmp.c @@ -51,7 +51,7 @@ void gpexwa_ehmp_set(void) { gpexbe_qos_request_update_timeout(PMQOS_MIDDLE | PMQOS_MIN, ehmp_info.lock_clock, QOS_TIMEOUT); } -void gpexwa_ehmp_unset() { +void gpexwa_ehmp_unset(void) { mutex_lock(&ehmp_info.gpu_sched_hmp_lock); if (ehmp_info.ctx_need_qos) { ehmp_info.ctx_need_qos = false; diff --git a/drivers/gpu/exynos/g2d/g2d_perf.h b/drivers/gpu/exynos/g2d/g2d_perf.h index 96c813292242..1c096db8220f 100755 --- a/drivers/gpu/exynos/g2d/g2d_perf.h +++ b/drivers/gpu/exynos/g2d/g2d_perf.h @@ -14,7 +14,7 @@ */ #ifndef _G2D_PERF_H_ -#define _G2D_PEEF_H_ +#define _G2D_PERF_H_ struct g2d_context; struct g2d_performance_data; diff --git a/drivers/input/touchscreen/sec_ts/sec_ts_fn.c b/drivers/input/touchscreen/sec_ts/sec_ts_fn.c index cbfa9ec6da8a..a7c63a12ef0c 100755 --- a/drivers/input/touchscreen/sec_ts/sec_ts_fn.c +++ b/drivers/input/touchscreen/sec_ts/sec_ts_fn.c @@ -4771,7 +4771,7 @@ static void clear_cover_mode(void *device_data) #endif } - if (!ts->power_status == SEC_TS_STATE_POWER_OFF && ts->reinit_done) { + if (!(ts->power_status == SEC_TS_STATE_POWER_OFF) && ts->reinit_done) { if (ts->flip_enable) sec_ts_set_cover_type(ts, true); else diff --git a/drivers/input/touchscreen/sec_ts/y771/sec_ts_fn.c b/drivers/input/touchscreen/sec_ts/y771/sec_ts_fn.c index 00ef6bd467f7..3b758facbcf8 100755 --- a/drivers/input/touchscreen/sec_ts/y771/sec_ts_fn.c +++ b/drivers/input/touchscreen/sec_ts/y771/sec_ts_fn.c @@ -5236,7 +5236,7 @@ static void clear_cover_mode(void *device_data) #endif } - if (!ts->power_status == SEC_TS_STATE_POWER_OFF && ts->reinit_done) { + if (!(ts->power_status == SEC_TS_STATE_POWER_OFF) && ts->reinit_done) { if (ts->flip_enable) sec_ts_set_cover_type(ts, true); else diff --git a/drivers/media/platform/exynos/fimc-is2/Makefile b/drivers/media/platform/exynos/fimc-is2/Makefile index ae0dbab42b2e..48b34ce75597 100755 --- a/drivers/media/platform/exynos/fimc-is2/Makefile +++ b/drivers/media/platform/exynos/fimc-is2/Makefile @@ -90,6 +90,3 @@ subdir-ccflags-$(CONFIG_FIMC_IS_V6_0_0) += -Idrivers/media/platform/exynos/fimc- subdir-ccflags-$(CONFIG_VENDER_DEFAULT) += -Idrivers/media/platform/exynos/fimc-is2/vendor/default subdir-ccflags-$(CONFIG_VENDER_MCD) += -Idrivers/media/platform/exynos/fimc-is2/vendor/mcd subdir-ccflags-$(CONFIG_VENDER_PSV) += -Idrivers/media/platform/exynos/fimc-is2/vendor/psv - -subdir-ccflags-y += -Wno-sizeof-pointer-memaccess -subdir-ccflags-y += -Wno-stringop-overflow diff --git a/drivers/media/platform/exynos/fimc-is2/fimc-is-framemgr.h b/drivers/media/platform/exynos/fimc-is2/fimc-is-framemgr.h index 90aa22f18a3b..7280e53a9bfa 100755 --- a/drivers/media/platform/exynos/fimc-is2/fimc-is-framemgr.h +++ b/drivers/media/platform/exynos/fimc-is2/fimc-is-framemgr.h @@ -136,13 +136,11 @@ enum fimc_is_frame_state { FS_INVALID }; -enum fimc_is_hw_frame_state { - FS_HW_FREE, - FS_HW_REQUEST, - FS_HW_CONFIGURE, - FS_HW_WAIT_DONE, - FS_HW_INVALID -}; +#define FS_HW_FREE FS_FREE +#define FS_HW_REQUEST FS_REQUEST +#define FS_HW_CONFIGURE FS_PROCESS +#define FS_HW_WAIT_DONE FS_COMPLETE +#define FS_HW_INVALID FS_INVALID #define NR_FRAME_STATE FS_INVALID diff --git a/drivers/media/platform/exynos/fimc-is2/hardware/fimc-is-hw-control.c b/drivers/media/platform/exynos/fimc-is2/hardware/fimc-is-hw-control.c index 6a5368c87cc7..381b8acd3360 100755 --- a/drivers/media/platform/exynos/fimc-is2/hardware/fimc-is-hw-control.c +++ b/drivers/media/platform/exynos/fimc-is2/hardware/fimc-is-hw-control.c @@ -344,7 +344,7 @@ void print_all_hw_frame_count(struct fimc_is_hardware *hardware) } void fimc_is_hardware_flush_frame(struct fimc_is_hw_ip *hw_ip, - enum fimc_is_hw_frame_state state, + enum fimc_is_frame_state state, enum ShotErrorType done_type) { int ret = 0; @@ -1749,7 +1749,7 @@ int fimc_is_hardware_process_start(struct fimc_is_hardware *hardware, u32 instan static int flush_frames_in_instance(struct fimc_is_hw_ip *hw_ip, struct fimc_is_framemgr *framemgr, u32 instance, - enum fimc_is_hw_frame_state state, enum ShotErrorType done_type) + enum fimc_is_frame_state state, enum ShotErrorType done_type) { int retry = 150; struct fimc_is_frame *frame; @@ -1813,7 +1813,7 @@ void fimc_is_hardware_force_stop(struct fimc_is_hardware *hardware, int ret = 0; struct fimc_is_framemgr *framemgr; struct fimc_is_framemgr *framemgr_late; - enum fimc_is_hw_frame_state state; + enum fimc_is_frame_state state; FIMC_BUG_VOID(!hw_ip); diff --git a/drivers/media/platform/exynos/fimc-is2/hardware/fimc-is-hw-control.h b/drivers/media/platform/exynos/fimc-is2/hardware/fimc-is-hw-control.h index 33a4f71a8d26..2fab25b300ff 100755 --- a/drivers/media/platform/exynos/fimc-is2/hardware/fimc-is-hw-control.h +++ b/drivers/media/platform/exynos/fimc-is2/hardware/fimc-is-hw-control.h @@ -383,7 +383,7 @@ struct fimc_is_hardware { u32 get_hw_id_from_group(u32 group_id); void fimc_is_hardware_flush_frame(struct fimc_is_hw_ip *hw_ip, - enum fimc_is_hw_frame_state state, + enum fimc_is_frame_state state, enum ShotErrorType done_type); int fimc_is_hardware_probe(struct fimc_is_hardware *hardware, struct fimc_is_interface *itf, struct fimc_is_interface_ischain *itfc); diff --git a/drivers/media/platform/exynos/fimc-is2/ischain/fimc-is-v6_0_0/fimc-is-param.h b/drivers/media/platform/exynos/fimc-is2/ischain/fimc-is-v6_0_0/fimc-is-param.h index d021cbf9ee7e..383cc7462b1f 100755 --- a/drivers/media/platform/exynos/fimc-is2/ischain/fimc-is-v6_0_0/fimc-is-param.h +++ b/drivers/media/platform/exynos/fimc-is2/ischain/fimc-is-v6_0_0/fimc-is-param.h @@ -1479,9 +1479,6 @@ static inline enum dma_input_order change_to_input_order(enum dma_output_order o enum dma_input_order input_order; switch (output_order) { - case DMA_OUTPUT_ORDER_NO: - input_order = DMA_INPUT_ORDER_NO; - break; case DMA_OUTPUT_ORDER_CrCb: input_order = DMA_INPUT_ORDER_CrCb; break; @@ -1506,8 +1503,9 @@ static inline enum dma_input_order change_to_input_order(enum dma_output_order o case DMA_OUTPUT_ORDER_YCbCr: input_order = DMA_INPUT_ORDER_YCbCr; break; + case DMA_OUTPUT_ORDER_NO: default: - input_order = output_order; + input_order = DMA_INPUT_ORDER_NO; break; } diff --git a/drivers/media/platform/exynos/fimc-is2/sensor/module/fimc-is-module-3h7_sunny.h b/drivers/media/platform/exynos/fimc-is2/sensor/module/fimc-is-module-3h7_sunny.h index 3e0d1c4106a1..26b73d10351e 100755 --- a/drivers/media/platform/exynos/fimc-is2/sensor/module/fimc-is-module-3h7_sunny.h +++ b/drivers/media/platform/exynos/fimc-is2/sensor/module/fimc-is-module-3h7_sunny.h @@ -10,7 +10,7 @@ */ #ifndef FIMC_IS_DEVICE_3H7_SUNNY_H -#define FIMC_IS_DEVICE_3H7_SYNNY_H +#define FIMC_IS_DEVICE_3H7_SUNNY_H #define SENSOR_S5K3H7_SUNNY_INSTANCE 0 #define SENSOR_S5K3H7_SUNNY_NAME SENSOR_NAME_S5K3H7_SUNNY diff --git a/drivers/media/platform/exynos/fimc-is2/vendor/mcd/fimc-is-sysfs.c b/drivers/media/platform/exynos/fimc-is2/vendor/mcd/fimc-is-sysfs.c index 6092f40877a3..0404ab70968b 100755 --- a/drivers/media/platform/exynos/fimc-is2/vendor/mcd/fimc-is-sysfs.c +++ b/drivers/media/platform/exynos/fimc-is2/vendor/mcd/fimc-is-sysfs.c @@ -244,7 +244,7 @@ static ssize_t camera_ssrm_camera_info_store(struct device *dev, ret_count = sscanf(buf, "%d%d%d%d%d%d%d", &temp.operation, &temp.cameraID, &temp.previewMinFPS, &temp.previewMaxFPS, &temp.previewSizeWidth, &temp.previewSizeHeight, &temp.sensorOn); - if (ret_count > sizeof(SsrmCameraInfo)/sizeof(int)) { + if (ret_count > sizeof(SsrmCameraInfo)/(sizeof(int))) { return -EINVAL; } diff --git a/drivers/media/tdmb/fc8080/dmbdrv_wrap_fc8080.c b/drivers/media/tdmb/fc8080/dmbdrv_wrap_fc8080.c index eb30cc3558b8..94c535ac4235 100755 --- a/drivers/media/tdmb/fc8080/dmbdrv_wrap_fc8080.c +++ b/drivers/media/tdmb/fc8080/dmbdrv_wrap_fc8080.c @@ -383,7 +383,7 @@ int dmb_drv_get_dat_sub_ch_cnt(void) } -char *dmb_drv_get_ensemble_label() +char *dmb_drv_get_ensemble_label(void) { struct esbinfo_t *esb; diff --git a/drivers/misc/modem_v1/link_device_memory.h b/drivers/misc/modem_v1/link_device_memory.h index d43e7a0b6948..16294fdb884e 100755 --- a/drivers/misc/modem_v1/link_device_memory.h +++ b/drivers/misc/modem_v1/link_device_memory.h @@ -155,7 +155,7 @@ struct __packed shmem_4mb_phys_map { #ifdef GROUP_MEM_IPC_DEVICE struct mem_ipc_device { - enum dev_format id; + enum legacy_ipc_map id; char name[16]; struct circ_queue txq; @@ -740,7 +740,7 @@ static inline enum dev_format dev_id(enum sipc_ch_id ch) return sipc5_fmt_ch(ch) ? IPC_FMT : IPC_RAW; } -static inline enum dev_format get_mmap_idx(enum sipc_ch_id ch, +static inline enum legacy_ipc_map get_mmap_idx(enum sipc_ch_id ch, struct sk_buff *skb) { if (sipc5_fmt_ch(ch)) diff --git a/drivers/misc/modem_v1/link_device_memory_debug.c b/drivers/misc/modem_v1/link_device_memory_debug.c index 6b87776b0b52..f0b965cc3dcd 100755 --- a/drivers/misc/modem_v1/link_device_memory_debug.c +++ b/drivers/misc/modem_v1/link_device_memory_debug.c @@ -62,7 +62,7 @@ void print_req_ack(struct mem_link_device *mld, struct mem_snapshot *mst, #ifdef DEBUG_MODEM_IF_FLOW_CTRL struct link_device *ld = &mld->link_dev; struct modem_ctl *mc = ld->mc; - enum dev_format id = dev->id; + enum legacy_ipc_map id = dev->id; unsigned int qsize = get_size(cq(dev, dir)); unsigned int in = mst->head[id][dir]; unsigned int out = mst->tail[id][dir]; @@ -81,7 +81,7 @@ void print_res_ack(struct mem_link_device *mld, struct mem_snapshot *mst, #ifdef DEBUG_MODEM_IF_FLOW_CTRL struct link_device *ld = &mld->link_dev; struct modem_ctl *mc = ld->mc; - enum dev_format id = dev->id; + enum legacy_ipc_map id = dev->id; enum direction opp_dir = opposite(dir); /* opposite direction */ unsigned int qsize = get_size(cq(dev, opp_dir)); unsigned int in = mst->head[id][opp_dir]; @@ -116,7 +116,7 @@ void print_dev_snapshot(struct mem_link_device *mld, struct mem_snapshot *mst, { #ifdef DEBUG_MODEM_IF struct link_device *ld = &mld->link_dev; - enum dev_format id = dev->id; + enum legacy_ipc_map id = dev->id; if (id > IPC_RAW) return; diff --git a/drivers/misc/modem_v1/link_device_shmem.c b/drivers/misc/modem_v1/link_device_shmem.c index 1e07a79e77fe..019b90350e0b 100755 --- a/drivers/misc/modem_v1/link_device_shmem.c +++ b/drivers/misc/modem_v1/link_device_shmem.c @@ -312,8 +312,22 @@ static void shmem_handle_cp_crash(struct mem_link_device *mld, stop_net_ifaces(ld); purge_txq(mld); - if (cp_online(mc)) - modem_notify_event(state); + if (cp_online(mc)) { + switch (state) { + case STATE_CRASH_RESET: + modem_notify_event(MODEM_EVENT_RESET); + break; + case STATE_CRASH_EXIT: + modem_notify_event(MODEM_EVENT_EXIT); + break; + case STATE_CRASH_WATCHDOG: + modem_notify_event(MODEM_EVENT_WATCHDOG); + break; + default: + mif_err("Invalid state to notify\n"); + break; + } + } if (cp_online(mc) || cp_booting(mc)) set_modem_state(mld, state); diff --git a/drivers/net/wireless/Makefile b/drivers/net/wireless/Makefile index 7e5dcebd5f4a..dcbfe6310956 100755 --- a/drivers/net/wireless/Makefile +++ b/drivers/net/wireless/Makefile @@ -36,5 +36,3 @@ obj-$(CONFIG_PCMCIA_WL3501) += wl3501_cs.o obj-$(CONFIG_USB_NET_RNDIS_WLAN) += rndis_wlan.o obj-$(CONFIG_MAC80211_HWSIM) += mac80211_hwsim.o -subdir-ccflags-y += -Wno-sizeof-pointer-memaccess -subdir-ccflags-y += -Wno-stringop-overflow diff --git a/drivers/net/wireless/bcmdhd_100_15/dhd_common.c b/drivers/net/wireless/bcmdhd_100_15/dhd_common.c index ba4a2fa77810..f0300e506ea0 100755 --- a/drivers/net/wireless/bcmdhd_100_15/dhd_common.c +++ b/drivers/net/wireless/bcmdhd_100_15/dhd_common.c @@ -4120,7 +4120,7 @@ dhd_pktfilter_offload_set(dhd_pub_t * dhd, char *arg) htod16(WL_PKT_FILTER_MFLAG_NEG); (argv[i])++; } - if (argv[i] == '\0') { + if (argv[i] == (char *)'\0') { printf("Pattern not provided\n"); goto fail; } diff --git a/drivers/net/wireless/bcmdhd_100_15/dhd_linux_pktdump.c b/drivers/net/wireless/bcmdhd_100_15/dhd_linux_pktdump.c index 7dcf35336f63..b92053976699 100755 --- a/drivers/net/wireless/bcmdhd_100_15/dhd_linux_pktdump.c +++ b/drivers/net/wireless/bcmdhd_100_15/dhd_linux_pktdump.c @@ -160,6 +160,7 @@ typedef struct pkt_cnt_log { #define PKT_CNT_RSN_VALID(rsn) \ (((rsn) > (PKT_CNT_RSN_INVALID)) && ((rsn) < (PKT_CNT_RSN_MAX))) +#ifdef DHD_PKTDUMP_ROAM static const char pkt_cnt_msg[][20] = { "INVALID", "ROAM_SUCCESS", @@ -167,6 +168,7 @@ static const char pkt_cnt_msg[][20] = { "CONNECT_SUCCESS", "INVALID" }; +#endif static const char tx_pktfate[][30] = { "TX_PKT_FATE_ACKED", /* 0: WLFC_CTL_PKTFLAG_DISCARD */ @@ -925,11 +927,13 @@ static char dhcp_types[][10] = { "NA", "DISCOVER", "OFFER", "REQUEST", "DECLINE", "ACK", "NAK", "RELEASE", "INFORM" }; +#ifdef DHD_STATUS_LOGGING static const int dhcp_types_stat[9] = { ST(INVALID), ST(DHCP_DISCOVER), ST(DHCP_OFFER), ST(DHCP_REQUEST), ST(DHCP_DECLINE), ST(DHCP_ACK), ST(DHCP_NAK), ST(DHCP_RELEASE), ST(DHCP_INFORM) }; +#endif void dhd_dhcp_dump(dhd_pub_t *dhdp, int ifidx, uint8 *pktdata, bool tx, diff --git a/drivers/net/wireless/bcmdhd_100_15/wl_android.c b/drivers/net/wireless/bcmdhd_100_15/wl_android.c index b31a85c011c5..45e3616b6515 100755 --- a/drivers/net/wireless/bcmdhd_100_15/wl_android.c +++ b/drivers/net/wireless/bcmdhd_100_15/wl_android.c @@ -8986,7 +8986,7 @@ wl_android_set_adps_mode(struct net_device *dev, const char* string_num) adps_mode = bcm_atoi(string_num); WL_ERR(("%s: SET_ADPS %d\n", __FUNCTION__, adps_mode)); - if ((adps_mode < 0) && (1 < adps_mode)) { + if ((adps_mode < 0) || (1 < adps_mode)) { WL_ERR(("wl_android_set_adps_mode: Invalid value %d.\n", adps_mode)); return -EINVAL; } diff --git a/drivers/net/wireless/bcmdhd_101_16/dhd_linux.c b/drivers/net/wireless/bcmdhd_101_16/dhd_linux.c index 346ff93554af..be40237819dd 100755 --- a/drivers/net/wireless/bcmdhd_101_16/dhd_linux.c +++ b/drivers/net/wireless/bcmdhd_101_16/dhd_linux.c @@ -19277,7 +19277,7 @@ dhd_nla_put_sssr_dump_len(void *ndev, uint32 *arr_len) #endif /* DHD_SSSR_DUMP */ uint32 -dhd_get_time_str_len() +dhd_get_time_str_len(void) { char *ts = NULL, time_str[128]; diff --git a/drivers/net/wireless/bcmdhd_101_16/dhd_linux_platdev.c b/drivers/net/wireless/bcmdhd_101_16/dhd_linux_platdev.c index 7108ec4fa347..3611516332d7 100755 --- a/drivers/net/wireless/bcmdhd_101_16/dhd_linux_platdev.c +++ b/drivers/net/wireless/bcmdhd_101_16/dhd_linux_platdev.c @@ -864,7 +864,7 @@ static int dhd_wifi_platform_load_usb(void) return 0; } -static int dhd_wifi_platform_load() +static int dhd_wifi_platform_load(void) { int err = 0; diff --git a/drivers/net/wireless/bcmdhd_101_16/wl_cfg_btcoex.c b/drivers/net/wireless/bcmdhd_101_16/wl_cfg_btcoex.c index 55a85bf4e8b7..45bb69bb9f2d 100755 --- a/drivers/net/wireless/bcmdhd_101_16/wl_cfg_btcoex.c +++ b/drivers/net/wireless/bcmdhd_101_16/wl_cfg_btcoex.c @@ -432,7 +432,7 @@ void* wl_cfg80211_btcoex_init(struct net_device *ndev) return btco_inf; } -void wl_cfg80211_btcoex_kill_handler() +void wl_cfg80211_btcoex_kill_handler(void) { if (!btcoex_info_loc) return; @@ -445,7 +445,7 @@ void wl_cfg80211_btcoex_kill_handler() wl_cfg80211_btcoex_init_handler_status(); } -void wl_cfg80211_btcoex_deinit() +void wl_cfg80211_btcoex_deinit(void) { if (!btcoex_info_loc) return; diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c index f4a9890e398e..5ccc2346537a 100755 --- a/drivers/scsi/scsi_devinfo.c +++ b/drivers/scsi/scsi_devinfo.c @@ -401,8 +401,8 @@ EXPORT_SYMBOL(scsi_dev_info_list_add_keyed); /** * scsi_dev_info_list_find - find a matching dev_info list entry. - * @vendor: vendor string - * @model: model (product) string + * @vendor: full vendor string + * @model: full model (product) string * @key: specify list to use * * Description: @@ -417,7 +417,7 @@ static struct scsi_dev_info_list *scsi_dev_info_list_find(const char *vendor, struct scsi_dev_info_list *devinfo; struct scsi_dev_info_list_table *devinfo_table = scsi_devinfo_lookup_by_key(key); - size_t vmax, mmax; + size_t vmax, mmax, mlen; const char *vskip, *mskip; if (IS_ERR(devinfo_table)) @@ -456,15 +456,19 @@ static struct scsi_dev_info_list *scsi_dev_info_list_find(const char *vendor, dev_info_list) { if (devinfo->compatible) { /* - * Behave like the older version of get_device_flags. + * vendor strings must be an exact match */ - if (memcmp(devinfo->vendor, vskip, vmax) || - (vmax < sizeof(devinfo->vendor) && - devinfo->vendor[vmax])) + if (vmax != strnlen(devinfo->vendor, + sizeof(devinfo->vendor)) || + memcmp(devinfo->vendor, vskip, vmax)) continue; - if (memcmp(devinfo->model, mskip, mmax) || - (mmax < sizeof(devinfo->model) && - devinfo->model[mmax])) + + /* + * @model specifies the full string, and + * must be larger or equal to devinfo->model + */ + mlen = strnlen(devinfo->model, sizeof(devinfo->model)); + if (mmax < mlen || memcmp(devinfo->model, mskip, mlen)) continue; return devinfo; } else { diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index ebd05e7373c0..fe7e80401d0c 100755 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -3429,7 +3429,7 @@ static int sd_remove(struct device *dev) /* restore bdi min/max ratio before device removal */ sdp = to_scsi_device(dev); - if (sdp && sdp->request_queue && &sdp->request_queue->backing_dev_info) { + if (sdp && sdp->request_queue) { bdi_set_min_ratio(&sdp->request_queue->backing_dev_info, 0); bdi_set_max_ratio(&sdp->request_queue->backing_dev_info, 100); } diff --git a/drivers/scsi/ufs/ufs-exynos.c b/drivers/scsi/ufs/ufs-exynos.c index a810e8b9980e..72934ad0ba07 100755 --- a/drivers/scsi/ufs/ufs-exynos.c +++ b/drivers/scsi/ufs/ufs-exynos.c @@ -838,7 +838,7 @@ static void exynos_ufs_set_nexus_t_task_mgmt(struct ufs_hba *hba, int tag, u8 tm } static void exynos_ufs_hibern8_notify(struct ufs_hba *hba, - u8 enter, bool notify) + u8 enter, int notify) { if (notify == PRE_CHANGE) { exynos_ufs_pre_hibern8(hba, enter); @@ -848,7 +848,7 @@ static void exynos_ufs_hibern8_notify(struct ufs_hba *hba, } static int exynos_ufs_hibern8_prepare(struct ufs_hba *hba, - u8 enter, bool notify) + u8 enter, int notify) { struct exynos_ufs *ufs = to_exynos_ufs(hba); int ret = 0; diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index a8179c9e703d..2b6e189f57bc 100755 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -1510,9 +1510,9 @@ ufshcd_wait_for_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd) if (uic_cmd->command == UIC_CMD_DME_LINK_STARTUP) index = 0; - else if ((uic_cmd->command == UIC_CMD_DME_HIBER_ENTER)) + else if (uic_cmd->command == UIC_CMD_DME_HIBER_ENTER) index = 1; - else if ((uic_cmd->command == UIC_CMD_DME_HIBER_EXIT)) + else if (uic_cmd->command == UIC_CMD_DME_HIBER_EXIT) index = 2; else index = -1; diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index 50fb8799cd1e..4fb25bb6ca0d 100755 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -320,8 +320,8 @@ struct ufs_hba_variant_ops { void (*set_nexus_t_xfer_req)(struct ufs_hba *, int, struct scsi_cmnd *); void (*set_nexus_t_task_mgmt)(struct ufs_hba *, int, u8); - void (*hibern8_notify)(struct ufs_hba *, u8, bool); - int (*hibern8_prepare)(struct ufs_hba *, u8, bool); + void (*hibern8_notify)(struct ufs_hba *, u8, int); + int (*hibern8_prepare)(struct ufs_hba *, u8, int); int (*suspend)(struct ufs_hba *, enum ufs_pm_op); int (*resume)(struct ufs_hba *, enum ufs_pm_op); void (*dbg_register_dump)(struct ufs_hba *hba); diff --git a/drivers/sensorhub/brcm/bbdpl/bbd.h b/drivers/sensorhub/brcm/bbdpl/bbd.h index 34f41c8a948f..6946b690bb12 100755 --- a/drivers/sensorhub/brcm/bbdpl/bbd.h +++ b/drivers/sensorhub/brcm/bbdpl/bbd.h @@ -19,9 +19,6 @@ #define __BBD_H__ #pragma pack(4) -typedef unsigned char uint8_t; -typedef unsigned short uint16_t; -typedef unsigned uint32_t; union long_union_t { diff --git a/drivers/sensorhub/brcm/ssp_bbd.c b/drivers/sensorhub/brcm/ssp_bbd.c index b8447b8b4bdf..e742dafd4651 100755 --- a/drivers/sensorhub/brcm/ssp_bbd.c +++ b/drivers/sensorhub/brcm/ssp_bbd.c @@ -163,7 +163,7 @@ int bbd_do_transfer(struct ssp_data *data, struct ssp_msg *msg, bcm4773_debug_info(); status = -2; - + mutex_lock(&data->pending_mutex); if (!use_no_irq && !msg_dead) { if ((msg->list.next != NULL) && @@ -300,11 +300,11 @@ int callback_bbd_on_mcu_ready(void *ssh_data, bool ready) int i, idx = 0, dstLen = (int)strlen(dst), totalLen = (int)strlen(src); for(i = 0; i < totalLen && idx < dstLen; i++) { - if(src[i] == '"' || src[i] == '<' || src[i] == '>') - continue; - if(src[i] == ';') - break; - dst[idx++] = src[i]; + if(src[i] == '"' || src[i] == '<' || src[i] == '>') + continue; + if(src[i] == ';') + break; + dst[idx++] = src[i]; } } int callback_bbd_on_control(void *ssh_data, const char *str_ctrl) @@ -325,9 +325,9 @@ int callback_bbd_on_control(void *ssh_data, const char *str_ctrl) int copyLen = totalLen - prefixLen <= sizeof(data->resetInfo) ? totalLen - prefixLen : sizeof(data->resetInfo); memcpy(data->resetInfo, str_ctrl + prefixLen, copyLen); - + if(totalLen != prefixLen) { - + /* this value is used on debug work func */ memset(data->resetInfoDebug, 0, sizeof(data->resetInfoDebug)); makeResetInfoString(data->resetInfo, data->resetInfoDebug); @@ -352,9 +352,8 @@ int callback_bbd_on_mcu_reset(void *ssh_data, bool IsNoResp) if (!data) return -1; - - if (IsNoResp && !data->resetting) - data->IsNoRespCnt++; + if(IsNoResp && !data->resetting) + data->IsNoRespCnt++; data->resetting = true; //data->uResetCnt++; diff --git a/drivers/sensorhub/brcm/ssp_i2c.c b/drivers/sensorhub/brcm/ssp_i2c.c index 084366b1a568..5867d0394daf 100755 --- a/drivers/sensorhub/brcm/ssp_i2c.c +++ b/drivers/sensorhub/brcm/ssp_i2c.c @@ -315,7 +315,7 @@ int send_instruction(struct ssp_data *data, u8 uInst, if (uLength >= 9) BatchTimeforReset = *(unsigned int *)(&uSendBuf[4]);// Add / change normal case, not factory. //pr_info("[SSP] %s timeForRest %d", __func__, BatchTimeforReset); - data->IsBypassMode[uSensorType] = (BatchTimeforReset == 0); + data->IsBypassMode[uSensorType] = (BatchTimeforReset == 0); //pr_info("[SSP] sensor%d mode%d Time %lld\n", uSensorType, data->IsBypassMode[uSensorType], current_Ts); } return iRet; diff --git a/drivers/soc/samsung/cal-if/Makefile b/drivers/soc/samsung/cal-if/Makefile index 745a61581b6c..f92a835a78de 100755 --- a/drivers/soc/samsung/cal-if/Makefile +++ b/drivers/soc/samsung/cal-if/Makefile @@ -4,7 +4,7 @@ # Object files in subdirectories -obj-y += cal-if.o +obj-y += cal-if.o obj-$(CONFIG_PMUCAL) += pmucal_system.o pmucal_local.o pmucal_cpu.o pmucal_rae.o obj-$(CONFIG_FLEXPMU) += pmucal_powermode.o obj-$(CONFIG_CP_PMUCAL) += pmucal_cp.o @@ -15,6 +15,8 @@ obj-$(CONFIG_CMU_EWF) += cmu_ewf.o ifndef CONFIG_SOC_EMULATOR8895 obj-$(CONFIG_SOC_EXYNOS8895) += exynos8895/cal_data.o +# not gonna even bother with this +ccflags-y += $(call cc-disable-warning, sizeof-pointer-div) else obj-$(CONFIG_SOC_EMULATOR8895) += emulator8895/cal_data.o endif diff --git a/drivers/soc/samsung/cal-if/exynos8895/asv_exynos8895.h b/drivers/soc/samsung/cal-if/exynos8895/asv_exynos8895.h index 6d76f7df1575..b76162fa9a47 100755 --- a/drivers/soc/samsung/cal-if/exynos8895/asv_exynos8895.h +++ b/drivers/soc/samsung/cal-if/exynos8895/asv_exynos8895.h @@ -69,8 +69,8 @@ struct id_tbl_info { unsigned reserved_5:8; }; -static struct asv_tbl_info *asv_tbl; -static struct id_tbl_info *id_tbl; +static volatile struct asv_tbl_info *asv_tbl; +static volatile struct id_tbl_info *id_tbl; int asv_get_grp(unsigned int id) { diff --git a/drivers/soc/samsung/cal-if/exynos9810/cmucal-node.c b/drivers/soc/samsung/cal-if/exynos9810/cmucal-node.c index aa72e35efdcf..ea503bb392ac 100755 --- a/drivers/soc/samsung/cal-if/exynos9810/cmucal-node.c +++ b/drivers/soc/samsung/cal-if/exynos9810/cmucal-node.c @@ -31,7 +31,7 @@ struct cmucal_pll_table pll_shared0_rate_table[] = { }; struct cmucal_pll_table pll_mmc_rate_table[] = { - PLL_RATE_MPSK(825999878, 31, 1, 0, 50412), + PLL_RATE_MPSK(825999878, 31, 1, 0, (short)50412), PLL_RATE_MPSK(26000000, 0, 0, 0, 0), }; diff --git a/drivers/soc/samsung/cal-if/fvmap.c b/drivers/soc/samsung/cal-if/fvmap.c index 63db28cd8458..ed47d1ab565b 100755 --- a/drivers/soc/samsung/cal-if/fvmap.c +++ b/drivers/soc/samsung/cal-if/fvmap.c @@ -440,7 +440,7 @@ static const struct attribute_group percent_margin_group = { static void fvmap_copy_from_sram(void __iomem *map_base, void __iomem *sram_base) { - struct fvmap_header *fvmap_header, *header; + volatile struct fvmap_header *fvmap_header, *header; struct rate_volt_header *old, *new; struct clocks *clks; struct pll_header *plls; diff --git a/drivers/soc/samsung/exynos-hdcp/exynos-hdcp2-teeif.c b/drivers/soc/samsung/exynos-hdcp/exynos-hdcp2-teeif.c index 981bdccf71ed..a50834ee48ec 100755 --- a/drivers/soc/samsung/exynos-hdcp/exynos-hdcp2-teeif.c +++ b/drivers/soc/samsung/exynos-hdcp/exynos-hdcp2-teeif.c @@ -55,7 +55,7 @@ int hdcp_tee_open(void) return 0; } -int hdcp_tee_close() +int hdcp_tee_close(void) { int ret; diff --git a/drivers/staging/android/ion/exynos/exynos_ion.c b/drivers/staging/android/ion/exynos/exynos_ion.c index 263aa17b3ed1..4b206e0abf5a 100755 --- a/drivers/staging/android/ion/exynos/exynos_ion.c +++ b/drivers/staging/android/ion/exynos/exynos_ion.c @@ -389,7 +389,7 @@ unsigned int ion_buffer_flag_sanity_check(unsigned int heap_id_mask, unsigned in * This is the exynos9810-specific requirement. * - SEC MOBILE, kernel core memory */ - if (flags && ION_FLAG_PROTECTED) { + if (flags & ION_FLAG_PROTECTED) { if ((camera_heap_id && (heap_id_mask == (1 << camera_heap_id))) || (camera_contig_heap_id && (heap_id_mask == (1 << camera_contig_heap_id)))) return flags & ~ION_FLAG_PROTECTED; diff --git a/drivers/staging/samsung/sec_debug_test.c b/drivers/staging/samsung/sec_debug_test.c index 58d3545d4f08..66c9cb37f5a4 100755 --- a/drivers/staging/samsung/sec_debug_test.c +++ b/drivers/staging/samsung/sec_debug_test.c @@ -181,7 +181,7 @@ static void pull_down_other_cpus(void) static void simulate_KP(char *arg) { pr_crit("%s()\n", __func__); - *(unsigned int *)0x0 = 0x0; /* SVACE: intended */ + *(volatile unsigned int *)0x0 = 0x0; /* SVACE: intended */ } static void simulate_DP(char *arg) @@ -315,7 +315,7 @@ static void simulate_WARN(char *arg) static void simulate_DABRT(char *arg) { pr_crit("%s()\n", __func__); - *((int *)0) = 0; /* SVACE: intended */ + *((volatile int *)0) = 0; /* SVACE: intended */ } static void simulate_PABRT(char *arg) @@ -504,7 +504,7 @@ static void simulate_WRITE_RO(char *arg) pr_crit("%s()\n", __func__); - ptr = (unsigned long *)simulate_WRITE_RO; + ptr = NULL; *ptr ^= 0x12345678; } diff --git a/drivers/staging/sti/abc/abc_common.c b/drivers/staging/sti/abc/abc_common.c index b912c65c0ae0..a592a6543b10 100755 --- a/drivers/staging/sti/abc/abc_common.c +++ b/drivers/staging/sti/abc/abc_common.c @@ -354,7 +354,7 @@ static void sec_abc_work_func(struct work_struct *work) } sprintf(timestamp, "TIMESTAMP=%lu", ktime_ms); uevent_str[idx++] = ×tamp[0]; - uevent_str[idx] = '\0'; + uevent_str[idx] = (char *)'\0'; strlcpy(event_type, uevent_str[1] + 6, sizeof(event_type)); ABC_PRINT("event type : %s\n", event_type); diff --git a/drivers/thermal/isp_cooling.c b/drivers/thermal/isp_cooling.c index 7978fcd72b11..a0d2754977a0 100755 --- a/drivers/thermal/isp_cooling.c +++ b/drivers/thermal/isp_cooling.c @@ -333,12 +333,12 @@ static int isp_set_cur_state(struct thermal_cooling_device *cdev, return isp_apply_cooling(isp_device, state); } -static enum tmu_noti_state_t isp_tstate = ISP_COLD; +static enum isp_noti_state_t isp_tstate = ISP_COLD; static int isp_set_cur_temp(struct thermal_cooling_device *cdev, bool suspended, int temp) { - enum tmu_noti_state_t tstate; + enum isp_noti_state_t tstate; if (suspended || temp < EXYNOS_COLD_TEMP) tstate = ISP_COLD; diff --git a/drivers/trace/exynos-ss.c b/drivers/trace/exynos-ss.c index ab0218ca525a..52e5d369832b 100755 --- a/drivers/trace/exynos-ss.c +++ b/drivers/trace/exynos-ss.c @@ -43,8 +43,6 @@ extern void register_hook_logbuf(void (*)(const char *, size_t)); #endif extern void register_hook_logger(void (*)(const char *, const char *, size_t)); -typedef int (*ess_initcall_t)(const struct device_node *); - struct exynos_ss_interface { struct exynos_ss_log *info_event; struct exynos_ss_item info_log[ESS_ITEM_MAX_NUM]; diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index d7e009f9c8bd..4fa4ccf331ce 100755 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -63,7 +63,7 @@ int dwc3_set_vbus_current(int state) } pval.intval = state; - power_supply_set_property(psy, POWER_SUPPLY_EXT_PROP_USB_CONFIGURE, &pval); + psy_do_property("battery", set, POWER_SUPPLY_EXT_PROP_USB_CONFIGURE, pval); power_supply_put(psy); return 0; } diff --git a/drivers/usb/notify/usb_notifier.c b/drivers/usb/notify/usb_notifier.c index 199189a748df..ae7b845da6ff 100755 --- a/drivers/usb/notify/usb_notifier.c +++ b/drivers/usb/notify/usb_notifier.c @@ -760,7 +760,7 @@ static int usb_notifier_probe(struct platform_device *pdev) #endif #if defined(CONFIG_VBUS_NOTIFIER) vbus_notifier_register(&pdata->vbus_nb, vbus_handle_notification, - MUIC_NOTIFY_DEV_USB); + VBUS_NOTIFY_DEV_USB); #endif dev_info(&pdev->dev, "usb notifier probe\n"); return 0; diff --git a/drivers/video/fbdev/exynos/dpu/decon.h b/drivers/video/fbdev/exynos/dpu/decon.h index cc7a810c5d3f..30eadf2fff34 100755 --- a/drivers/video/fbdev/exynos/dpu/decon.h +++ b/drivers/video/fbdev/exynos/dpu/decon.h @@ -351,9 +351,7 @@ enum decon_data_path { DPATH_DSCC_DSCENC01_FF01_FORMATTER01_DSIMIF01 = 0x0B3, /* WB_PRE */ DPATH_WBPRE_ONLY = 0x100, -}; -enum decon1_data_path { /* No comp - FF0 - FORMATTER0 - DSIM_IF0 */ DECON1_NOCOMP_FF0_FORMATTER0_DSIMIF0 = 0x001, /* No comp - FF0 - FORMATTER0 - WB_POST */ @@ -364,9 +362,7 @@ enum decon1_data_path { DECON1_DSCENC1_FF0_FORMATTER0_WBPOST = 0x014, /* WB_PRE */ DECON1_WBPRE_ONLY = 0x100, -}; - -enum decon2_data_path { + /* No comp - FF0 - FORMATTER0 - WB_POST */ DECON2_NOCOMP_FF0_FORMATTER0_WBPOST = 0x004, /* No comp - FF0 - FORMATTER0 - DISPIF */ diff --git a/drivers/video/fbdev/exynos/dpu/decon_core.c b/drivers/video/fbdev/exynos/dpu/decon_core.c index 2e22319647dd..98be221655d3 100755 --- a/drivers/video/fbdev/exynos/dpu/decon_core.c +++ b/drivers/video/fbdev/exynos/dpu/decon_core.c @@ -2595,7 +2595,7 @@ static void decon_parse_dt(struct decon_device *decon) } } - if ((decon->dt.out_type == DECON_OUT_DSI)) { + if (decon->dt.out_type == DECON_OUT_DSI) { te_eint = of_get_child_by_name(decon->dev->of_node, "te_eint"); if (!te_eint) { decon_info("No DT node for te_eint\n"); diff --git a/drivers/video/fbdev/exynos/dpu/decon_reg.c b/drivers/video/fbdev/exynos/dpu/decon_reg.c index cea8a5d0f406..05e9d57ab1ad 100755 --- a/drivers/video/fbdev/exynos/dpu/decon_reg.c +++ b/drivers/video/fbdev/exynos/dpu/decon_reg.c @@ -2512,7 +2512,7 @@ u32 decon_reg_get_height(u32 id, int dsi_mode) return (FORMATTER_HEIGHT_GET(val)); } -const unsigned long decon_clocks_table[][CLK_ID_MAX] = { +const double decon_clocks_table[][CLK_ID_MAX] = { /* VCLK, ECLK, ACLK, PCLK, DISP_PLL, resolution, MIC_ratio, DSC count */ { 71, 168, 400, 66, 71, 1080 * 1920, MIC_COMP_BYPASS, 0}, { 63, 168, 400, 66, 63, 1440 * 2560, MIC_COMP_RATIO_1_2, 0}, diff --git a/drivers/video/fbdev/exynos/dpu/displayport_drv.c b/drivers/video/fbdev/exynos/dpu/displayport_drv.c index 3288615b0629..83372414bda4 100755 --- a/drivers/video/fbdev/exynos/dpu/displayport_drv.c +++ b/drivers/video/fbdev/exynos/dpu/displayport_drv.c @@ -266,7 +266,10 @@ static int displayport_full_link_training(void) displayport_info("Voltage_Swing_Retry %02x %02x %02x %02x\n", val[0], val[1], val[2], val[3]); displayport_reg_dpcd_write_burst(DPCD_ADD_TRANING_LANE0_SET, 4, val); - udelay((training_aux_rd_interval*4000)+400); + if (training_aux_rd_interval != 0) + mdelay(training_aux_rd_interval * 4); + else + udelay(100); lane_cr_done = 0; @@ -394,7 +397,10 @@ static int displayport_full_link_training(void) lane_symbol_locked_done = 0; interlane_align_done = 0; - udelay((training_aux_rd_interval*4000)+400); + if (training_aux_rd_interval != 0) + mdelay(training_aux_rd_interval * 4); + else + udelay(100); displayport_reg_dpcd_read_burst(DPCD_ADD_LANE0_1_STATUS, 3, val); lane_cr_done |= ((val[0] & LANE0_CR_DONE) >> 0); diff --git a/drivers/video/fbdev/exynos/dpu_9810/decon.h b/drivers/video/fbdev/exynos/dpu_9810/decon.h index 99e9466cb0aa..47fcf669b887 100755 --- a/drivers/video/fbdev/exynos/dpu_9810/decon.h +++ b/drivers/video/fbdev/exynos/dpu_9810/decon.h @@ -344,9 +344,7 @@ enum decon_data_path { DPATH_DSCC_DSCENC01_OUTFIFO01_DSIMIF1 = 0x0B2, /* DSCC,DSC_ENC0/1 - OUTFIFO01 DSIM_IF0/1*/ DPATH_DSCC_DSCENC01_OUTFIFO01_DSIMIF01 = 0x0B3, -}; -enum decon1_data_path { /* No comp - OUTFIFO0 DSIM_IF0 */ DECON1_NOCOMP_OUTFIFO0_DSIMIF0 = 0x001, /* No comp - OUTFIFO0 DP_IF */ @@ -355,9 +353,7 @@ enum decon1_data_path { DECON1_DSCENC1_OUTFIFO0_DSIMIF0 = 0x021, /* DSC_ENC1 - OUTFIFO0 - DP_IF */ DECON1_DSCENC1_OUTFIFO0_DPIF = 0x028, -}; -enum decon2_data_path { /* No comp - OUTFIFO0 DP_IF */ DECON2_NOCOMP_OUTFIFO0_DPIF = 0x008, /* DSC_ENC2 - OUTFIFO0 - DP_IF0 */ diff --git a/drivers/video/fbdev/exynos/dpu_9810/decon_core.c b/drivers/video/fbdev/exynos/dpu_9810/decon_core.c index 4a0aabf14ba5..6ff1925d2dd5 100755 --- a/drivers/video/fbdev/exynos/dpu_9810/decon_core.c +++ b/drivers/video/fbdev/exynos/dpu_9810/decon_core.c @@ -3563,7 +3563,7 @@ static void decon_parse_dt(struct decon_device *decon) } } - if ((decon->dt.out_type == DECON_OUT_DSI)) { + if (decon->dt.out_type == DECON_OUT_DSI) { te_eint = of_get_child_by_name(decon->dev->of_node, "te_eint"); if (!te_eint) { decon_info("No DT node for te_eint\n"); diff --git a/drivers/vision/iva/iva_rt_table.h b/drivers/vision/iva/iva_rt_table.h index 1d3851464554..4fabc55ad2c0 100755 --- a/drivers/vision/iva/iva_rt_table.h +++ b/drivers/vision/iva/iva_rt_table.h @@ -12,8 +12,6 @@ #include "iva_ctrl.h" -typedef struct _rt_iva_table_t * rt_iva_table; - extern void iva_rt_print_iva_entries(struct iva_dev_data *iva, void *iva_tbl_ptr, int8_t *num_deps_list); diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile index 7bd882d5f025..7f188b8d0c67 100755 --- a/drivers/xen/Makefile +++ b/drivers/xen/Makefile @@ -7,11 +7,6 @@ obj-y += xenbus/ nostackp := $(call cc-option, -fno-stack-protector) CFLAGS_features.o := $(nostackp) -ifndef CONFIG_LTO_CLANG -CFLAGS_efi.o += -fshort-wchar -LDFLAGS += $(call ld-option, --no-wchar-size-warning) -endif - dom0-$(CONFIG_ARM64) += arm-device.o dom0-$(CONFIG_PCI) += pci.o dom0-$(CONFIG_USB_SUPPORT) += dbgp.o diff --git a/drivers/xen/Makefilex b/drivers/xen/Makefilex new file mode 100644 index 000000000000..7bd882d5f025 --- /dev/null +++ b/drivers/xen/Makefilex @@ -0,0 +1,46 @@ +obj-$(CONFIG_HOTPLUG_CPU) += cpu_hotplug.o +obj-$(CONFIG_X86) += fallback.o +obj-y += grant-table.o features.o balloon.o manage.o preempt.o time.o +obj-y += events/ +obj-y += xenbus/ + +nostackp := $(call cc-option, -fno-stack-protector) +CFLAGS_features.o := $(nostackp) + +ifndef CONFIG_LTO_CLANG +CFLAGS_efi.o += -fshort-wchar +LDFLAGS += $(call ld-option, --no-wchar-size-warning) +endif + +dom0-$(CONFIG_ARM64) += arm-device.o +dom0-$(CONFIG_PCI) += pci.o +dom0-$(CONFIG_USB_SUPPORT) += dbgp.o +dom0-$(CONFIG_XEN_ACPI) += acpi.o $(xen-pad-y) +xen-pad-$(CONFIG_X86) += xen-acpi-pad.o +dom0-$(CONFIG_X86) += pcpu.o +obj-$(CONFIG_XEN_DOM0) += $(dom0-y) +obj-$(CONFIG_BLOCK) += biomerge.o +obj-$(CONFIG_XEN_BALLOON) += xen-balloon.o +obj-$(CONFIG_XEN_SELFBALLOONING) += xen-selfballoon.o +obj-$(CONFIG_XEN_DEV_EVTCHN) += xen-evtchn.o +obj-$(CONFIG_XEN_GNTDEV) += xen-gntdev.o +obj-$(CONFIG_XEN_GRANT_DEV_ALLOC) += xen-gntalloc.o +obj-$(CONFIG_XENFS) += xenfs/ +obj-$(CONFIG_XEN_SYS_HYPERVISOR) += sys-hypervisor.o +obj-$(CONFIG_XEN_PVHVM) += platform-pci.o +obj-$(CONFIG_XEN_TMEM) += tmem.o +obj-$(CONFIG_SWIOTLB_XEN) += swiotlb-xen.o +obj-$(CONFIG_XEN_MCE_LOG) += mcelog.o +obj-$(CONFIG_XEN_PCIDEV_BACKEND) += xen-pciback/ +obj-$(CONFIG_XEN_PRIVCMD) += xen-privcmd.o +obj-$(CONFIG_XEN_STUB) += xen-stub.o +obj-$(CONFIG_XEN_ACPI_HOTPLUG_MEMORY) += xen-acpi-memhotplug.o +obj-$(CONFIG_XEN_ACPI_HOTPLUG_CPU) += xen-acpi-cpuhotplug.o +obj-$(CONFIG_XEN_ACPI_PROCESSOR) += xen-acpi-processor.o +obj-$(CONFIG_XEN_EFI) += efi.o +obj-$(CONFIG_XEN_SCSI_BACKEND) += xen-scsiback.o +obj-$(CONFIG_XEN_AUTO_XLATE) += xlate_mmu.o +xen-evtchn-y := evtchn.o +xen-gntdev-y := gntdev.o +xen-gntalloc-y := gntalloc.o +xen-privcmd-y := privcmd.o diff --git a/fs/ecryptfs/mm.c b/fs/ecryptfs/mm.c index 3d052073afa2..a21c2e247680 100755 --- a/fs/ecryptfs/mm.c +++ b/fs/ecryptfs/mm.c @@ -154,7 +154,7 @@ static unsigned long drop_inode_pagecache(struct inode *inode) printk("%s() cleaning [%s] pages: %lu\n", __func__, inode->i_sb->s_type->name, inode->i_mapping->nrpages); - if ((inode->i_mapping->nrpages == 0)) { + if (inode->i_mapping->nrpages == 0) { spin_unlock(&inode->i_lock); printk("%s inode having zero nrpages\n", __func__); return 0; diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index a69c6bb2f3e6..fe69bd8b68bb 100755 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -2453,7 +2453,7 @@ static const struct fscrypt_operations f2fs_cryptops = { #endif .dummy_context = f2fs_dummy_context, .empty_dir = f2fs_empty_dir, - .max_namelen = F2FS_NAME_LEN, + .max_namelen = (unsigned int (*)(struct inode *)) F2FS_NAME_LEN, }; #endif diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c index 0b71cb514031..b9661f102399 100755 --- a/fs/overlayfs/copy_up.c +++ b/fs/overlayfs/copy_up.c @@ -56,7 +56,7 @@ int ovl_copy_xattr(struct dentry *old, struct dentry *new) { ssize_t list_size, size, value_size = 0; char *buf, *name, *value = NULL; - int uninitialized_var(error); + int error = 0; size_t slen; if (!(old->d_inode->i_opflags & IOP_XATTR) || diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c index 57764da62332..7c52993b9a3b 100755 --- a/fs/overlayfs/dir.c +++ b/fs/overlayfs/dir.c @@ -482,7 +482,7 @@ static int ovl_create_or_link(struct dentry *dentry, struct inode *inode, struct dentry *hardlink) { int err; - const struct cred *old_cred; + const struct cred *old_cred, *hold_cred = NULL; struct cred *override_cred; err = ovl_copy_up(dentry->d_parent); @@ -505,7 +505,7 @@ static int ovl_create_or_link(struct dentry *dentry, struct inode *inode, goto out_revert_creds; } } - put_cred(override_creds(override_cred)); + hold_cred = override_creds(override_cred); put_cred(override_cred); if (!ovl_dentry_is_opaque(dentry)) @@ -516,7 +516,9 @@ static int ovl_create_or_link(struct dentry *dentry, struct inode *inode, link, hardlink); } out_revert_creds: - ovl_revert_creds(old_cred); + ovl_revert_creds(old_cred ?: hold_cred); + if (old_cred && hold_cred) + put_cred(hold_cred); if (!err) { struct inode *realinode = d_inode(ovl_dentry_upper(dentry)); diff --git a/include/linux/cpu_cooling.h b/include/linux/cpu_cooling.h index f0c0fe21de55..5bccdb2c3b85 100755 --- a/include/linux/cpu_cooling.h +++ b/include/linux/cpu_cooling.h @@ -28,9 +28,6 @@ #include #include -typedef int (*get_static_t)(cpumask_t *cpumask, int interval, - unsigned long voltage, u32 *power); - /** * struct cpufreq_cooling_device - data for cooling device with cpufreq * @id: unique integer value corresponding to each cpufreq_cooling_device diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 44f8cbe9be04..2ffd81d1b0bc 100755 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -505,6 +505,7 @@ static inline unsigned long cpufreq_scale(unsigned long old, u_int div, * the ondemand governor will not work. All times here are in us (microseconds). */ #define MIN_SAMPLING_RATE_RATIO (2) +#define LATENCY_MULTIPLIER (1000) #define UP_LATENCY_MULTIPLIER (50) #define DOWN_LATENCY_MULTIPLIER (100) #define MIN_LATENCY_MULTIPLIER (20) diff --git a/include/linux/gpu_cooling.h b/include/linux/gpu_cooling.h index e12db2bc3758..67d9ceaaf859 100755 --- a/include/linux/gpu_cooling.h +++ b/include/linux/gpu_cooling.h @@ -31,9 +31,6 @@ #define GPU_TABLE_END ~1 -typedef int (*get_static_t)(cpumask_t *cpumask, int interval, - unsigned long voltage, u32 *power); - #ifdef CONFIG_GPU_THERMAL /** * gpufreq_cooling_register - function to create gpufreq cooling device. diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 48c76d612d40..b699d59d0f4f 100755 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -109,6 +109,8 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr, unsigned long sz); pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr); int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep); +void adjust_range_if_pmd_sharing_possible(struct vm_area_struct *vma, + unsigned long *start, unsigned long *end); struct page *follow_huge_addr(struct mm_struct *mm, unsigned long address, int write); struct page *follow_huge_pmd(struct mm_struct *mm, unsigned long address, @@ -131,6 +133,18 @@ static inline unsigned long hugetlb_total_pages(void) return 0; } +static inline int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, + pte_t *ptep) +{ + return 0; +} + +static inline void adjust_range_if_pmd_sharing_possible( + struct vm_area_struct *vma, + unsigned long *start, unsigned long *end) +{ +} + #define follow_hugetlb_page(m,v,p,vs,a,b,i,w) ({ BUG(); 0; }) #define follow_huge_addr(mm, addr, write) ERR_PTR(-EINVAL) #define copy_hugetlb_page_range(src, dst, vma) ({ BUG(); 0; }) diff --git a/include/linux/rmap.h b/include/linux/rmap.h index 9a17d3b9b671..4a3388d7f4ad 100755 --- a/include/linux/rmap.h +++ b/include/linux/rmap.h @@ -10,6 +10,10 @@ #include #include +extern int isolate_lru_page(struct page *page); +extern void putback_lru_page(struct page *page); +extern unsigned long reclaim_pages_from_list(struct list_head *page_list, + struct vm_area_struct *vma); /* * The anon_vma heads a list of private "related" vmas, to scan if * an anonymous page pointing to this anon_vma needs to be unmapped: diff --git a/include/linux/string.h b/include/linux/string.h index 2a9180942f03..b19eb06d90bb 100755 --- a/include/linux/string.h +++ b/include/linux/string.h @@ -111,6 +111,9 @@ extern void * memscan(void *,int,__kernel_size_t); #ifndef __HAVE_ARCH_MEMCMP extern int memcmp(const void *,const void *,__kernel_size_t); #endif +#ifndef __HAVE_ARCH_BCMP +extern int bcmp(const void *,const void *,__kernel_size_t); +#endif #ifndef __HAVE_ARCH_MEMCHR extern void * memchr(const void *,int,__kernel_size_t); #endif diff --git a/include/linux/thermal.h b/include/linux/thermal.h index f5fe8ce49e6b..168278023af2 100755 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -75,6 +75,10 @@ struct thermal_zone_device; struct thermal_cooling_device; struct thermal_instance; +/* From cpu_cooling.h and gpu_cooling.h */ +typedef int (*get_static_t)(cpumask_t *cpumask, int interval, + unsigned long voltage, u32 *power); + enum thermal_device_mode { THERMAL_DEVICE_DISABLED = 0, THERMAL_DEVICE_ENABLED, diff --git a/include/net/phonet/pep.h b/include/net/phonet/pep.h index b669fe6dbc3b..98f31c7ea23d 100755 --- a/include/net/phonet/pep.h +++ b/include/net/phonet/pep.h @@ -63,10 +63,11 @@ struct pnpipehdr { u8 state_after_reset; /* reset request */ u8 error_code; /* any response */ u8 pep_type; /* status indication */ - u8 data[1]; + u8 data0; /* anything else */ }; + u8 data[]; }; -#define other_pep_type data[1] +#define other_pep_type data[0] static inline struct pnpipehdr *pnp_hdr(struct sk_buff *skb) { diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 127c7715d29f..ecdc6d826d77 100755 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6214,7 +6214,9 @@ cpu_attach_domain(struct sched_domain *sd, struct root_domain *rd, int cpu) rq_attach_root(rq, rd); tmp = rq->sd; rcu_assign_pointer(rq->sd, sd); +#if defined(CONFIG_SCHED_DEBUG) dirty_sched_domain_sysctl(cpu); +#endif destroy_sched_domains(tmp); update_top_cache_domain(cpu); diff --git a/lib/string.c b/lib/string.c index 1a7d3fd52541..3a487a4566b5 100755 --- a/lib/string.c +++ b/lib/string.c @@ -235,6 +235,30 @@ ssize_t strscpy(char *dest, const char *src, size_t count) EXPORT_SYMBOL(strscpy); #endif +/** + * stpcpy - copy a string from src to dest returning a pointer to the new end + * of dest, including src's %NUL-terminator. May overrun dest. + * @dest: pointer to end of string being copied into. Must be large enough + * to receive copy. + * @src: pointer to the beginning of string being copied from. Must not overlap + * dest. + * + * stpcpy differs from strcpy in a key way: the return value is a pointer + * to the new %NUL-terminating character in @dest. (For strcpy, the return + * value is a pointer to the start of @dest). This interface is considered + * unsafe as it doesn't perform bounds checking of the inputs. As such it's + * not recommended for usage. Instead, its definition is provided in case + * the compiler lowers other libcalls to stpcpy. + */ +char *stpcpy(char *__restrict__ dest, const char *__restrict__ src); +char *stpcpy(char *__restrict__ dest, const char *__restrict__ src) +{ + while ((*dest++ = *src++) != '\0') + /* nothing */; + return --dest; +} +EXPORT_SYMBOL(stpcpy); + #ifndef __HAVE_ARCH_STRCAT /** * strcat - Append one %NUL-terminated string to another @@ -798,6 +822,26 @@ __visible int memcmp(const void *cs, const void *ct, size_t count) EXPORT_SYMBOL(memcmp); #endif +#ifndef __HAVE_ARCH_BCMP +/** + * bcmp - returns 0 if and only if the buffers have identical contents. + * @a: pointer to first buffer. + * @b: pointer to second buffer. + * @len: size of buffers. + * + * The sign or magnitude of a non-zero return value has no particular + * meaning, and architectures may implement their own more efficient bcmp(). So + * while this particular implementation is a simple (tail) call to memcmp, do + * not rely on anything but whether the return value is zero or non-zero. + */ +#undef bcmp +int bcmp(const void *a, const void *b, size_t len) +{ + return memcmp(a, b, len); +} +EXPORT_SYMBOL(bcmp); +#endif + #ifndef __HAVE_ARCH_MEMSCAN /** * memscan - Find a character in an area of memory. diff --git a/lib/vdso/compiler.h b/lib/vdso/compiler.h new file mode 100644 index 000000000000..0e618b73e064 --- /dev/null +++ b/lib/vdso/compiler.h @@ -0,0 +1,24 @@ +/* + * Userspace implementations of fallback calls + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef __VDSO_COMPILER_H +#define __VDSO_COMPILER_H + +#error "vdso: Provide architectural overrides such as ARCH_PROVIDES_TIMER," +#error " DEFINE_FALLBACK and __arch_counter_get or any overrides. eg:" +#error " vdso entry points or compilation time helpers." + +#endif /* __VDSO_COMPILER_H */ diff --git a/lib/vdso/datapage.h b/lib/vdso/datapage.h new file mode 100644 index 000000000000..df4427e42d51 --- /dev/null +++ b/lib/vdso/datapage.h @@ -0,0 +1,24 @@ +/* + * Userspace implementations of __get_datapage + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef __VDSO_DATAPAGE_H +#define __VDSO_DATAPAGE_H + +#error "vdso: Provide a user space architecture specific definition or" +#error "prototype for struct vdso_data *__get_datapage(void). Also define" +#error "ARCH_CLOCK_FIXED_MASK if not provided by cs_mask." + +#endif /* __VDSO_DATAPAGE_H */ diff --git a/lib/vdso/vgettimeofday.c b/lib/vdso/vgettimeofday.c new file mode 100644 index 000000000000..8ca2b5374c2d --- /dev/null +++ b/lib/vdso/vgettimeofday.c @@ -0,0 +1,398 @@ +/* + * Userspace implementations of gettimeofday() and friends. + * + * Copyright (C) 2017 Cavium, Inc. + * Copyright (C) 2015 Mentor Graphics Corporation + * Copyright (C) 2012 ARM Limited + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Author: Will Deacon + * Rewriten from arch64 version into C by: Andrew Pinski + * Reworked and rebased over arm version by: Mark Salyzyn + */ + +#include +#include /* for notrace */ +#include /* for __iter_div_u64_rem() */ +#include /* for struct timespec */ + +#include "compiler.h" +#include "datapage.h" + +#ifdef ARCH_PROVIDES_TIMER +DEFINE_FALLBACK(gettimeofday, struct timeval *, tv, struct timezone *, tz) +#endif +DEFINE_FALLBACK(clock_gettime, clockid_t, clock, struct timespec *, ts) +DEFINE_FALLBACK(clock_getres, clockid_t, clock, struct timespec *, ts) + +static notrace u32 vdso_read_begin(const struct vdso_data *vd) +{ + u32 seq; + + do { + seq = READ_ONCE(vd->tb_seq_count); + + if ((seq & 1) == 0) + break; + + cpu_relax(); + } while (true); + + smp_rmb(); /* Pairs with second smp_wmb in update_vsyscall */ + return seq; +} + +static notrace int vdso_read_retry(const struct vdso_data *vd, u32 start) +{ + u32 seq; + + smp_rmb(); /* Pairs with first smp_wmb in update_vsyscall */ + seq = READ_ONCE(vd->tb_seq_count); + return seq != start; +} + +static notrace int do_realtime_coarse(const struct vdso_data *vd, + struct timespec *ts) +{ + u32 seq; + + do { + seq = vdso_read_begin(vd); + + ts->tv_sec = vd->xtime_coarse_sec; + ts->tv_nsec = vd->xtime_coarse_nsec; + + } while (vdso_read_retry(vd, seq)); + + return 0; +} + +static notrace int do_monotonic_coarse(const struct vdso_data *vd, + struct timespec *ts) +{ + struct timespec tomono; + u32 seq; + u64 nsec; + + do { + seq = vdso_read_begin(vd); + + ts->tv_sec = vd->xtime_coarse_sec; + ts->tv_nsec = vd->xtime_coarse_nsec; + + tomono.tv_sec = vd->wtm_clock_sec; + tomono.tv_nsec = vd->wtm_clock_nsec; + + } while (vdso_read_retry(vd, seq)); + + ts->tv_sec += tomono.tv_sec; + /* open coding timespec_add_ns */ + ts->tv_sec += __iter_div_u64_rem(ts->tv_nsec + tomono.tv_nsec, + NSEC_PER_SEC, &nsec); + ts->tv_nsec = nsec; + + return 0; +} + +#ifdef ARCH_PROVIDES_TIMER + +/* + * Returns the clock delta, in nanoseconds left-shifted by the clock + * shift. + */ +static notrace u64 get_clock_shifted_nsec(const u64 cycle_last, + const u32 mult, + const u64 mask) +{ + u64 res; + + /* Read the virtual counter. */ + res = arch_vdso_read_counter(); + + res = res - cycle_last; + + res &= mask; + return res * mult; +} + +static notrace int do_realtime(const struct vdso_data *vd, struct timespec *ts) +{ + u32 seq, mult, shift; + u64 nsec, cycle_last; +#ifdef ARCH_CLOCK_FIXED_MASK + static const u64 mask = ARCH_CLOCK_FIXED_MASK; +#else + u64 mask; +#endif + vdso_xtime_clock_sec_t sec; + + do { + seq = vdso_read_begin(vd); + + if (vd->use_syscall) + return -1; + + cycle_last = vd->cs_cycle_last; + + mult = vd->cs_mono_mult; + shift = vd->cs_shift; +#ifndef ARCH_CLOCK_FIXED_MASK + mask = vd->cs_mask; +#endif + + sec = vd->xtime_clock_sec; + nsec = vd->xtime_clock_snsec; + + } while (unlikely(vdso_read_retry(vd, seq))); + + nsec += get_clock_shifted_nsec(cycle_last, mult, mask); + nsec >>= shift; + /* open coding timespec_add_ns to save a ts->tv_nsec = 0 */ + ts->tv_sec = sec + __iter_div_u64_rem(nsec, NSEC_PER_SEC, &nsec); + ts->tv_nsec = nsec; + + return 0; +} + +static notrace int do_monotonic(const struct vdso_data *vd, struct timespec *ts) +{ + u32 seq, mult, shift; + u64 nsec, cycle_last; +#ifdef ARCH_CLOCK_FIXED_MASK + static const u64 mask = ARCH_CLOCK_FIXED_MASK; +#else + u64 mask; +#endif + vdso_wtm_clock_nsec_t wtm_nsec; + __kernel_time_t sec; + + do { + seq = vdso_read_begin(vd); + + if (vd->use_syscall) + return -1; + + cycle_last = vd->cs_cycle_last; + + mult = vd->cs_mono_mult; + shift = vd->cs_shift; +#ifndef ARCH_CLOCK_FIXED_MASK + mask = vd->cs_mask; +#endif + + sec = vd->xtime_clock_sec; + nsec = vd->xtime_clock_snsec; + + sec += vd->wtm_clock_sec; + wtm_nsec = vd->wtm_clock_nsec; + + } while (unlikely(vdso_read_retry(vd, seq))); + + nsec += get_clock_shifted_nsec(cycle_last, mult, mask); + nsec >>= shift; + nsec += wtm_nsec; + /* open coding timespec_add_ns to save a ts->tv_nsec = 0 */ + ts->tv_sec = sec + __iter_div_u64_rem(nsec, NSEC_PER_SEC, &nsec); + ts->tv_nsec = nsec; + + return 0; +} + +static notrace int do_monotonic_raw(const struct vdso_data *vd, + struct timespec *ts) +{ + u32 seq, mult, shift; + u64 nsec, cycle_last; +#ifdef ARCH_CLOCK_FIXED_MASK + static const u64 mask = ARCH_CLOCK_FIXED_MASK; +#else + u64 mask; +#endif + vdso_raw_time_sec_t sec; + + do { + seq = vdso_read_begin(vd); + + if (vd->use_syscall) + return -1; + + cycle_last = vd->cs_cycle_last; + + mult = vd->cs_raw_mult; + shift = vd->cs_shift; +#ifndef ARCH_CLOCK_FIXED_MASK + mask = vd->cs_mask; +#endif + + sec = vd->raw_time_sec; + nsec = vd->raw_time_nsec; + + } while (unlikely(vdso_read_retry(vd, seq))); + + nsec += get_clock_shifted_nsec(cycle_last, mult, mask); + nsec >>= shift; + /* open coding timespec_add_ns to save a ts->tv_nsec = 0 */ + ts->tv_sec = sec + __iter_div_u64_rem(nsec, NSEC_PER_SEC, &nsec); + ts->tv_nsec = nsec; + + return 0; +} + +static notrace int do_boottime(const struct vdso_data *vd, struct timespec *ts) +{ + u32 seq, mult, shift; + u64 nsec, cycle_last; + vdso_wtm_clock_nsec_t wtm_nsec; +#ifdef ARCH_CLOCK_FIXED_MASK + static const u64 mask = ARCH_CLOCK_FIXED_MASK; +#else + u64 mask; +#endif + __kernel_time_t sec; + + do { + seq = vdso_read_begin(vd); + + if (vd->use_syscall) + return -1; + + cycle_last = vd->cs_cycle_last; + + mult = vd->cs_mono_mult; + shift = vd->cs_shift; +#ifndef ARCH_CLOCK_FIXED_MASK + mask = vd->cs_mask; +#endif + + sec = vd->xtime_clock_sec; + nsec = vd->xtime_clock_snsec; + + sec += vd->wtm_clock_sec + vd->btm_sec; + wtm_nsec = vd->wtm_clock_nsec + vd->btm_nsec; + + } while (unlikely(vdso_read_retry(vd, seq))); + + nsec += get_clock_shifted_nsec(cycle_last, mult, mask); + nsec >>= shift; + nsec += wtm_nsec; + + /* open coding timespec_add_ns to save a ts->tv_nsec = 0 */ + ts->tv_sec = sec + __iter_div_u64_rem(nsec, NSEC_PER_SEC, &nsec); + ts->tv_nsec = nsec; + + return 0; +} + +#endif /* ARCH_PROVIDES_TIMER */ + +notrace int __vdso_clock_gettime(clockid_t clock, struct timespec *ts) +{ + const struct vdso_data *vd = __get_datapage(); + + switch (clock) { + case CLOCK_REALTIME_COARSE: + do_realtime_coarse(vd, ts); + break; + case CLOCK_MONOTONIC_COARSE: + do_monotonic_coarse(vd, ts); + break; +#ifdef ARCH_PROVIDES_TIMER + case CLOCK_REALTIME: + if (do_realtime(vd, ts)) + goto fallback; + break; + case CLOCK_MONOTONIC: + if (do_monotonic(vd, ts)) + goto fallback; + break; + case CLOCK_MONOTONIC_RAW: + if (do_monotonic_raw(vd, ts)) + goto fallback; + break; + case CLOCK_BOOTTIME: + if (do_boottime(vd, ts)) + goto fallback; + break; +#endif + default: + goto fallback; + } + + return 0; +fallback: + return clock_gettime_fallback(clock, ts); +} + +#ifdef ARCH_PROVIDES_TIMER +notrace int __vdso_gettimeofday(struct timeval *tv, struct timezone *tz) +{ + const struct vdso_data *vd = __get_datapage(); + + if (likely(tv != NULL)) { + struct timespec ts; + + if (do_realtime(vd, &ts)) + return gettimeofday_fallback(tv, tz); + + tv->tv_sec = ts.tv_sec; + tv->tv_usec = ts.tv_nsec / 1000; + } + + if (unlikely(tz != NULL)) { + tz->tz_minuteswest = vd->tz_minuteswest; + tz->tz_dsttime = vd->tz_dsttime; + } + + return 0; +} +#endif + +int __vdso_clock_getres(clockid_t clock, struct timespec *res) +{ + long nsec; + + switch (clock) { + case CLOCK_REALTIME_COARSE: + case CLOCK_MONOTONIC_COARSE: + nsec = LOW_RES_NSEC; + break; +#ifdef ARCH_PROVIDES_TIMER + case CLOCK_REALTIME: + case CLOCK_MONOTONIC: + case CLOCK_MONOTONIC_RAW: + case CLOCK_BOOTTIME: + nsec = MONOTONIC_RES_NSEC; + break; +#endif + default: + return clock_getres_fallback(clock, res); + } + + if (likely(res != NULL)) { + res->tv_sec = 0; + res->tv_nsec = nsec; + } + + return 0; +} + +notrace time_t __vdso_time(time_t *t) +{ + const struct vdso_data *vd = __get_datapage(); + time_t result = READ_ONCE(vd->xtime_coarse_sec); + + if (t) + *t = result; + return result; +} diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 0b31de7a6080..b6c206ce0353 100755 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -511,7 +511,7 @@ static bool is_zspage_isolated(struct zspage *zspage) return zspage->isolated; } -static int is_first_page(struct page *page) +static __maybe_unused int is_first_page(struct page *page) { return PagePrivate(page); } @@ -596,20 +596,23 @@ static int get_size_class_index(int size) return min(zs_size_classes - 1, idx); } +/* type can be of enum type zs_stat_type or fullness_group */ static inline void zs_stat_inc(struct size_class *class, - enum zs_stat_type type, unsigned long cnt) + int type, unsigned long cnt) { class->stats.objs[type] += cnt; } +/* type can be of enum type zs_stat_type or fullness_group */ static inline void zs_stat_dec(struct size_class *class, - enum zs_stat_type type, unsigned long cnt) + int type, unsigned long cnt) { class->stats.objs[type] -= cnt; } +/* type can be of enum type zs_stat_type or fullness_group */ static inline unsigned long zs_stat_get(struct size_class *class, - enum zs_stat_type type) + int type) { return class->stats.objs[type]; } diff --git a/net/mptcp/Makefile b/net/mptcp/Makefile index af7c455bc43d..cefe13417c3d 100755 --- a/net/mptcp/Makefile +++ b/net/mptcp/Makefile @@ -8,6 +8,11 @@ obj-$(CONFIG_MPTCP) += mptcp.o mptcp-y := mptcp_ctrl.o mptcp_ipv4.o mptcp_pm.o \ mptcp_output.o mptcp_input.o mptcp_sched.o +# you wouldnt believe how fucked this code are, just look at mptcp repo +CFLAGS_mptcp_ctrl.o += $(call cc-disable-warning, incompatible-pointer-types) +CFLAGS_mptcp_ofo_queue.o += $(call cc-disable-warning, incompatible-pointer-types) +CFLAGS_mptcp_input.o += $(call cc-disable-warning, incompatible-pointer-types) + obj-$(CONFIG_TCP_CONG_LIA) += mptcp_coupled.o obj-$(CONFIG_TCP_CONG_OLIA) += mptcp_olia.o obj-$(CONFIG_TCP_CONG_WVEGAS) += mptcp_wvegas.o diff --git a/net/netfilter/xt_qtaguid.c b/net/netfilter/xt_qtaguid.c index 633ee128367f..98afc67d71b4 100755 --- a/net/netfilter/xt_qtaguid.c +++ b/net/netfilter/xt_qtaguid.c @@ -1182,11 +1182,6 @@ static void get_dev_and_dir(const struct sk_buff *skb, par->hooknum, __func__); BUG(); } - if (unlikely(!(*el_dev)->name)) { - pr_err("qtaguid[%d]: %s(): no dev->name?!!\n", - par->hooknum, __func__); - BUG(); - } if (skb->dev && *el_dev != skb->dev) { MT_DEBUG("qtaguid[%d]: skb->dev=%p %s vs par->%s=%p %s\n", par->hooknum, skb->dev, skb->dev->name, diff --git a/net/phonet/pep.c b/net/phonet/pep.c index 850a86cde0b3..f6aa532bcbf6 100755 --- a/net/phonet/pep.c +++ b/net/phonet/pep.c @@ -131,7 +131,7 @@ static int pep_indicate(struct sock *sk, u8 id, u8 code, ph->utid = 0; ph->message_id = id; ph->pipe_handle = pn->pipe_handle; - ph->data[0] = code; + ph->error_code = code; return pn_skb_send(sk, skb, NULL); } @@ -152,7 +152,7 @@ static int pipe_handler_request(struct sock *sk, u8 id, u8 code, ph->utid = id; /* whatever */ ph->message_id = id; ph->pipe_handle = pn->pipe_handle; - ph->data[0] = code; + ph->error_code = code; return pn_skb_send(sk, skb, NULL); } @@ -207,7 +207,7 @@ static int pep_ctrlreq_error(struct sock *sk, struct sk_buff *oskb, u8 code, struct pnpipehdr *ph; struct sockaddr_pn dst; u8 data[4] = { - oph->data[0], /* PEP type */ + oph->pep_type, /* PEP type */ code, /* error code, at an unusual offset */ PAD, PAD, }; @@ -220,7 +220,7 @@ static int pep_ctrlreq_error(struct sock *sk, struct sk_buff *oskb, u8 code, ph->utid = oph->utid; ph->message_id = PNS_PEP_CTRL_RESP; ph->pipe_handle = oph->pipe_handle; - ph->data[0] = oph->data[1]; /* CTRL id */ + ph->data0 = oph->data[0]; /* CTRL id */ pn_skb_get_src_sockaddr(oskb, &dst); return pn_skb_send(sk, skb, &dst); @@ -271,17 +271,17 @@ static int pipe_rcv_status(struct sock *sk, struct sk_buff *skb) return -EINVAL; hdr = pnp_hdr(skb); - if (hdr->data[0] != PN_PEP_TYPE_COMMON) { + if (hdr->pep_type != PN_PEP_TYPE_COMMON) { net_dbg_ratelimited("Phonet unknown PEP type: %u\n", - (unsigned int)hdr->data[0]); + (unsigned int)hdr->pep_type); return -EOPNOTSUPP; } - switch (hdr->data[1]) { + switch (hdr->data[0]) { case PN_PEP_IND_FLOW_CONTROL: switch (pn->tx_fc) { case PN_LEGACY_FLOW_CONTROL: - switch (hdr->data[4]) { + switch (hdr->data[3]) { case PEP_IND_BUSY: atomic_set(&pn->tx_credits, 0); break; @@ -291,7 +291,7 @@ static int pipe_rcv_status(struct sock *sk, struct sk_buff *skb) } break; case PN_ONE_CREDIT_FLOW_CONTROL: - if (hdr->data[4] == PEP_IND_READY) + if (hdr->data[3] == PEP_IND_READY) atomic_set(&pn->tx_credits, wake = 1); break; } @@ -300,12 +300,12 @@ static int pipe_rcv_status(struct sock *sk, struct sk_buff *skb) case PN_PEP_IND_ID_MCFC_GRANT_CREDITS: if (pn->tx_fc != PN_MULTI_CREDIT_FLOW_CONTROL) break; - atomic_add(wake = hdr->data[4], &pn->tx_credits); + atomic_add(wake = hdr->data[3], &pn->tx_credits); break; default: net_dbg_ratelimited("Phonet unknown PEP indication: %u\n", - (unsigned int)hdr->data[1]); + (unsigned int)hdr->data[0]); return -EOPNOTSUPP; } if (wake) @@ -317,7 +317,7 @@ static int pipe_rcv_created(struct sock *sk, struct sk_buff *skb) { struct pep_sock *pn = pep_sk(sk); struct pnpipehdr *hdr = pnp_hdr(skb); - u8 n_sb = hdr->data[0]; + u8 n_sb = hdr->data0; pn->rx_fc = pn->tx_fc = PN_LEGACY_FLOW_CONTROL; __skb_pull(skb, sizeof(*hdr)); @@ -505,7 +505,7 @@ static int pep_connresp_rcv(struct sock *sk, struct sk_buff *skb) return -ECONNREFUSED; /* Parse sub-blocks */ - n_sb = hdr->data[4]; + n_sb = hdr->data[3]; while (n_sb > 0) { u8 type, buf[6], len = sizeof(buf); const u8 *data = pep_get_sb(skb, &type, &len, buf); @@ -738,7 +738,7 @@ static int pipe_do_remove(struct sock *sk) ph->utid = 0; ph->message_id = PNS_PIPE_REMOVE_REQ; ph->pipe_handle = pn->pipe_handle; - ph->data[0] = PAD; + ph->data0 = PAD; return pn_skb_send(sk, skb, NULL); } @@ -815,7 +815,7 @@ static struct sock *pep_sock_accept(struct sock *sk, int flags, int *errp) peer_type = hdr->other_pep_type << 8; /* Parse sub-blocks (options) */ - n_sb = hdr->data[4]; + n_sb = hdr->data[3]; while (n_sb > 0) { u8 type, buf[1], len = sizeof(buf); const u8 *data = pep_get_sb(skb, &type, &len, buf); @@ -1106,7 +1106,7 @@ static int pipe_skb_send(struct sock *sk, struct sk_buff *skb) ph->utid = 0; if (pn->aligned) { ph->message_id = PNS_PIPE_ALIGNED_DATA; - ph->data[0] = 0; /* padding */ + ph->data0 = 0; /* padding */ } else ph->message_id = PNS_PIPE_DATA; ph->pipe_handle = pn->pipe_handle; diff --git a/scripts/Makefile.kasan b/scripts/Makefile.kasan index 5f08b1f8a7cd..420581077142 100755 --- a/scripts/Makefile.kasan +++ b/scripts/Makefile.kasan @@ -39,4 +39,7 @@ else endif endif + +CFLAGS_KASAN_NOSANITIZE := -fno-builtin + endif diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 253b5260db39..fc547f5ac6f3 100755 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -127,7 +127,7 @@ endif ifeq ($(CONFIG_KASAN),y) _c_flags += $(if $(patsubst n%,, \ $(KASAN_SANITIZE_$(basetarget).o)$(KASAN_SANITIZE)y), \ - $(CFLAGS_KASAN)) + $(CFLAGS_KASAN), $(CFLAGS_KASAN_NOSANITIZE)) endif ifeq ($(CONFIG_UBSAN),y) diff --git a/scripts/fmp/ELF.py b/scripts/fmp/ELF.py index e333905a2bd7..438104326ba4 100755 --- a/scripts/fmp/ELF.py +++ b/scripts/fmp/ELF.py @@ -10,8 +10,10 @@ import subprocess import re import os +import struct from Utils import Utils from collections import OrderedDict +from binascii import unhexlify __author__ = "Vadym Stupakov" __copyright__ = "Copyright (c) 2017 Samsung Electronics" @@ -64,7 +66,7 @@ class ELF: """ Utils for manipulating over ELF """ - def __init__(self, elf_file, readelf_path="readelf"): + def __init__(self, elf_file, readelf_path=os.environ.get('CROSS_COMPILE')+"readelf"): self.__elf_file = elf_file self.utils = Utils() self.__readelf_path = readelf_path @@ -137,9 +139,15 @@ def get_symbols(self): size = int(size, 16) else: size = int(size, 10) - self.__symbols[int(line[0], 16)] = Symbol(addr=int(line[0], 16), size=size, sym_type=line[2], - bind=line[3], visibility=line[4], ndx=line[5], - name=line[6]) + """ + Do not include additional compiler information with name $d and $x + $d and $x is mapping symbols, their virtual addresses may coincide with virtual addresses + of the real objects + """ + if line[6] not in ("$d", "$x") and (size != 0): + self.__symbols[int(line[0], 16)] = Symbol(addr=int(line[0], 16), size=size, sym_type=line[2], + bind=line[3], visibility=line[4], ndx=line[5], + name=line[6]) self.__symbols = OrderedDict(sorted(self.__symbols.items())) return self.__symbols @@ -162,6 +170,71 @@ def get_relocs(self, start_addr=None, end_addr=None): return ranged_rela return self.__relocs + def get_altinstructions(self, start_addr=None, end_addr=None): + """ + :param start_addr: start address :int + :param end_addr: end address: int + :returns list: [[alt_inst1_addr, length1], [alt_inst2_addr, length2], ...] + + .altinstructions section contains an array of struct alt_instr. + As instance, for kernel 4.14 from /arch/arm64/include/asm/alternative.h + struct alt_instr { + s32 orig_offset; /* offset to original instruction */ + s32 alt_offset; /* offset to replacement instruction */ + u16 cpufeature; /* cpufeature bit set for replacement */ + u8 orig_len; /* size of original instruction(s) */ + u8 alt_len; /* size of new instruction(s), <= orig_len */ + }; + + Later, address of original instruction can be calculated as + at runtime : &(alt_instr->orig_offset) + alt_instr->orig_offset + kernel offset + ELF processing : address of .altinstruction section + in section offset of alt_instr structure + value of alt_instr.orig_offset + details in /arch/arm64/kernel/alternative.c, void __apply_alternatives(void *, bool) + """ + + # The struct_format should reflect content + struct_format = 'comm : %s\n", current->comm); #if 1 if(is_root()) { @@ -118,7 +118,7 @@ int is_current_adbd() { #endif } -int is_current_epmd() { +int is_current_epmd(void) { DEK_LOGD("current->comm : %s\n", current->comm); #if 1 if(is_root()) { diff --git a/sound/soc/codecs/max98512.c b/sound/soc/codecs/max98512.c index 28815d4046ea..78026280f5b0 100755 --- a/sound/soc/codecs/max98512.c +++ b/sound/soc/codecs/max98512.c @@ -3034,8 +3034,7 @@ static int max98512_i2c_probe(struct i2c_client *i2c, #ifdef CONFIG_SND_SOC_MAXIM_DSM /* If maxdsm module was already registerd, will be ignored. */ maxdsm_init(); - if (pdata->pinfo) - maxdsm_update_info(pdata->pinfo); + maxdsm_update_info(pdata->pinfo); maxdsm_update_sub_reg(pdata->sub_reg); maxdsm_update_ppr_info(pdata->ppr_info); #endif