From 33722cdb1582542a81266b9ec6442d86e6d00991 Mon Sep 17 00:00:00 2001 From: Igor Pecovnik Date: Sun, 27 May 2018 13:45:21 +0200 Subject: [PATCH] Merge UDOO next patches from development and add remaining ones --- config/kernel/linux-udoo-next.config | 4 +- .../odroidc1-dev/add_load_address.patch | 14 + ..._DMA_block_memory_allocation_to_2048.patch | 13 + .../odroidc1-dev/bash_to_afterinstall.patch | 11 + .../odroidc1-dev/packaging-4.x-dev.patch | 199 + .../udoo-next/04-patch-4.4.117-118.patch | 9662 +++++++++++++++++ .../udoo-next/04-patch-4.4.118-119.patch | 696 ++ .../udoo-next/04-patch-4.4.119-120.patch | 1104 ++ .../udoo-next/04-patch-4.4.120-121.patch | 1085 ++ .../udoo-next/04-patch-4.4.121-122.patch | 2177 ++++ .../udoo-next/04-patch-4.4.122-123.patch | 3500 ++++++ .../udoo-next/04-patch-4.4.123-124.patch | 3077 ++++++ .../udoo-next/04-patch-4.4.124-125.patch | 1326 +++ .../udoo-next/04-patch-4.4.125-126.patch | 455 + .../udoo-next/04-patch-4.4.126-127.patch | 2344 ++++ .../udoo-next/04-patch-4.4.127-128.patch | 5333 +++++++++ .../udoo-next/04-patch-4.4.128-129.patch | 3460 ++++++ .../udoo-next/04-patch-4.4.129-130.patch | 2698 +++++ .../udoo-next/04-patch-4.4.130-131.patch | 1558 +++ .../udoo-next/04-patch-4.4.131-132.patch | 2948 +++++ .../udoo-next/04-patch-4.4.132-133.patch | 4957 +++++++++ 21 files changed, 46619 insertions(+), 2 deletions(-) create mode 100644 patch/kernel/odroidc1-dev/add_load_address.patch create mode 100644 patch/kernel/odroidc1-dev/arm64_increasing_DMA_block_memory_allocation_to_2048.patch create mode 100644 patch/kernel/odroidc1-dev/bash_to_afterinstall.patch create mode 100644 patch/kernel/odroidc1-dev/packaging-4.x-dev.patch create mode 100644 patch/kernel/udoo-next/04-patch-4.4.117-118.patch create mode 100644 patch/kernel/udoo-next/04-patch-4.4.118-119.patch create mode 100644 patch/kernel/udoo-next/04-patch-4.4.119-120.patch create mode 100644 patch/kernel/udoo-next/04-patch-4.4.120-121.patch create mode 100644 patch/kernel/udoo-next/04-patch-4.4.121-122.patch create mode 100644 patch/kernel/udoo-next/04-patch-4.4.122-123.patch create mode 100644 patch/kernel/udoo-next/04-patch-4.4.123-124.patch create mode 100644 patch/kernel/udoo-next/04-patch-4.4.124-125.patch create mode 100644 patch/kernel/udoo-next/04-patch-4.4.125-126.patch create mode 100644 patch/kernel/udoo-next/04-patch-4.4.126-127.patch create mode 100644 patch/kernel/udoo-next/04-patch-4.4.127-128.patch create mode 100644 patch/kernel/udoo-next/04-patch-4.4.128-129.patch create mode 100644 patch/kernel/udoo-next/04-patch-4.4.129-130.patch create mode 100644 patch/kernel/udoo-next/04-patch-4.4.130-131.patch create mode 100644 patch/kernel/udoo-next/04-patch-4.4.131-132.patch create mode 100644 patch/kernel/udoo-next/04-patch-4.4.132-133.patch diff --git a/config/kernel/linux-udoo-next.config b/config/kernel/linux-udoo-next.config index 24f808f48..c363515f3 100644 --- a/config/kernel/linux-udoo-next.config +++ b/config/kernel/linux-udoo-next.config @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/arm 4.4.122 Kernel Configuration +# Linux/arm 4.4.133 Kernel Configuration # CONFIG_ARM=y CONFIG_ARM_HAS_SG_CHAIN=y @@ -4058,7 +4058,7 @@ CONFIG_PRINT_QUOTA_WARNING=y CONFIG_QUOTA_TREE=m # CONFIG_QFMT_V1 is not set # CONFIG_QFMT_V2 is not set -CONFIG_QUOTACTL=m +CONFIG_QUOTACTL=y CONFIG_AUTOFS4_FS=m CONFIG_FUSE_FS=m CONFIG_CUSE=m diff --git a/patch/kernel/odroidc1-dev/add_load_address.patch b/patch/kernel/odroidc1-dev/add_load_address.patch new file mode 100644 index 000000000..ad55bce45 --- /dev/null +++ b/patch/kernel/odroidc1-dev/add_load_address.patch @@ -0,0 +1,14 @@ +diff --git a/Makefile b/Makefile +index e811e0c..f1af403 +--- a/Makefile ++++ b/Makefile +@@ -11,6 +11,9 @@ NAME = Fearless Coyote + # Comments in this file are targeted only to the developer, do not + # expect to learn how to build the kernel reading this file. + ++LOADADDR=0x00208000 ++export LOADADDR ++ + # That's our default target when none is given on the command line + PHONY := _all + _all: diff --git a/patch/kernel/odroidc1-dev/arm64_increasing_DMA_block_memory_allocation_to_2048.patch b/patch/kernel/odroidc1-dev/arm64_increasing_DMA_block_memory_allocation_to_2048.patch new file mode 100644 index 000000000..652c75bd3 --- /dev/null +++ b/patch/kernel/odroidc1-dev/arm64_increasing_DMA_block_memory_allocation_to_2048.patch @@ -0,0 +1,13 @@ +diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c +index 3216e09..21bce28 +--- a/arch/arm64/mm/dma-mapping.c ++++ b/arch/arm64/mm/dma-mapping.c +@@ -44,7 +44,7 @@ static pgprot_t __get_dma_pgprot(unsigned long attrs, pgprot_t prot, + + static struct gen_pool *atomic_pool; + +-#define DEFAULT_DMA_COHERENT_POOL_SIZE SZ_256K ++#define DEFAULT_DMA_COHERENT_POOL_SIZE SZ_2M + static size_t atomic_pool_size __initdata = DEFAULT_DMA_COHERENT_POOL_SIZE; + + static int __init early_coherent_pool(char *p) diff --git a/patch/kernel/odroidc1-dev/bash_to_afterinstall.patch b/patch/kernel/odroidc1-dev/bash_to_afterinstall.patch new file mode 100644 index 000000000..ce95ec007 --- /dev/null +++ b/patch/kernel/odroidc1-dev/bash_to_afterinstall.patch @@ -0,0 +1,11 @@ +--- a/scripts/package/builddeb ++++ b/scripts/package/builddeb +@@ -218,7 +218,7 @@ + for script in postinst postrm preinst prerm ; do + mkdir -p "$tmpdir$debhookdir/$script.d" + cat < "$tmpdir/DEBIAN/$script" +-#!/bin/sh ++#!/bin/bash + + set -e + diff --git a/patch/kernel/odroidc1-dev/packaging-4.x-dev.patch b/patch/kernel/odroidc1-dev/packaging-4.x-dev.patch new file mode 100644 index 000000000..811af0793 --- /dev/null +++ b/patch/kernel/odroidc1-dev/packaging-4.x-dev.patch @@ -0,0 +1,199 @@ +diff --git a/scripts/package/builddeb b/scripts/package/builddeb +index 90c9a8a..d64e047 100755 +--- a/scripts/package/builddeb ++++ b/scripts/package/builddeb +@@ -29,6 +29,27 @@ create_package() { + # in case we are in a restrictive umask environment like 0077 + chmod -R a+rX "$pdir" + ++ # Create preinstall and post install script to remove dtb ++ if [[ "$1" == *dtb* ]]; then ++ echo "if [ -d /boot/dtb-$version ]; then mv /boot/dtb-$version /boot/dtb-$version.old; fi" >> $pdir/DEBIAN/preinst ++ echo "if [ -d /boot/dtb.old ]; then rm -rf /boot/dtb.old; fi" >> $pdir/DEBIAN/preinst ++ echo "if [ -d /boot/dtb ]; then mv /boot/dtb /boot/dtb.old; fi" >> $pdir/DEBIAN/preinst ++ echo "exit 0" >> $pdir/DEBIAN/preinst ++ chmod 775 $pdir/DEBIAN/preinst ++ ++ echo "if [ -d /boot/dtb-$version.old ]; then rm -rf /boot/dtb-$version.old; fi" >> $pdir/DEBIAN/postinst ++ echo "ln -sf dtb-$version /boot/dtb > /dev/null 2>&1 || mv /boot/dtb-$version /boot/dtb" >> $pdir/DEBIAN/postinst ++ echo "exit 0" >> $pdir/DEBIAN/postinst ++ chmod 775 $pdir/DEBIAN/postinst ++ fi ++ ++ # Create postinstall script for headers ++ if [[ "$1" == *headers* ]]; then ++ echo "cd /usr/src/linux-headers-$version; echo \"Compiling headers - please wait ...\"; make -s scripts >/dev/null 2>&1" >> $pdir/DEBIAN/postinst ++ echo "exit 0" >> $pdir/DEBIAN/postinst ++ chmod 775 $pdir/DEBIAN/postinst ++ fi ++ + # Create the package + dpkg-gencontrol -p$pname -P"$pdir" + dpkg --build "$pdir" .. +@@ -39,9 +60,11 @@ tmpdir="$objtree/debian/tmp" + kernel_headers_dir="$objtree/debian/hdrtmp" + libc_headers_dir="$objtree/debian/headertmp" + dbg_dir="$objtree/debian/dbgtmp" +-packagename=linux-image-$version +-kernel_headers_packagename=linux-headers-$version +-libc_headers_packagename=linux-libc-dev ++dtb_dir="$objtree/debian/dtbtmp" ++packagename=linux-image-dev"$LOCALVERSION" ++kernel_headers_packagename=linux-headers-dev"$LOCALVERSION" ++dtb_packagename=linux-dtb-dev"$LOCALVERSION" ++libc_headers_packagename=linux-libc-dev-dev"$LOCALVERSION" + dbg_packagename=$packagename-dbg + + if [ "$ARCH" = "um" ] ; then +@@ -52,6 +75,15 @@ fi + # XXX: have each arch Makefile export a variable of the canonical image install + # path instead + case $ARCH in ++aarch64|arm64) ++ image_name=Image ++ installed_image_path="boot/vmlinuz-$version" ++ ++ ;; ++arm*) ++ image_name=zImage ++ installed_image_path="boot/vmlinuz-$version" ++ ;; + um) + installed_image_path="usr/bin/linux-$version" + ;; +@@ -65,7 +97,9 @@ esac + BUILD_DEBUG="$(grep -s '^CONFIG_DEBUG_INFO=y' $KCONFIG_CONFIG || true)" + + # Setup the directory structure +-rm -rf "$tmpdir" "$kernel_headers_dir" "$libc_headers_dir" "$dbg_dir" $objtree/debian/files ++rm -rf "$tmpdir" "$kernel_headers_dir" "$libc_headers_dir" "$dbg_dir" "$dtb_dir" $objtree/debian/files ++mkdir -m 755 -p "$dtb_dir/DEBIAN" ++mkdir -p "$dtb_dir/boot/dtb-$version" "$dtb_dir/usr/share/doc/$dtb_packagename" + mkdir -m 755 -p "$tmpdir/DEBIAN" + mkdir -p "$tmpdir/lib" "$tmpdir/boot" + mkdir -p "$kernel_headers_dir/lib/modules/$version/" +@@ -118,6 +152,11 @@ if grep -q '^CONFIG_MODULES=y' $KCONFIG_CONFIG ; then + fi + fi + ++if grep -q '^CONFIG_OF=y' $KCONFIG_CONFIG ; then ++ #mkdir -p "$tmpdir/boot/dtb" ++ INSTALL_DTBS_PATH="$dtb_dir/boot/dtb-$version" $MAKE KBUILD_SRC= dtbs_install ++fi ++ + if [ "$ARCH" != "um" ]; then + $MAKE headers_check KBUILD_SRC= + $MAKE headers_install KBUILD_SRC= INSTALL_HDR_PATH="$libc_headers_dir/usr" +@@ -153,9 +192,60 @@ EOF + chmod 755 "$tmpdir/DEBIAN/$script" + done + ++## ++## Create sym link to kernel image ++## ++sed -e "s/set -e//g" -i $tmpdir/DEBIAN/postinst ++sed -e "s/exit 0//g" -i $tmpdir/DEBIAN/postinst ++cat >> $tmpdir/DEBIAN/postinst < /dev/null 2>&1 ++ cp /boot/uImage /tmp/uImage ++ sync ++ mountpoint -q /boot || mount /boot ++ cp /tmp/uImage /boot/uImage ++ rm -f /$installed_image_path ++else ++ ln -sf $(basename $installed_image_path) /boot/$image_name || mv /$installed_image_path /boot/$image_name ++fi ++touch /boot/.next ++exit 0 ++EOT ++ ++## ++## FAT install workaround ++## ++sed -e "s/set -e//g" -i $tmpdir/DEBIAN/preinst ++sed -e "s/exit 0//g" -i $tmpdir/DEBIAN/preinst ++cat >> $tmpdir/DEBIAN/preinst <> $tmpdir/DEBIAN/preinst ++ + # Build kernel header package + (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl) > "$objtree/debian/hdrsrcfiles" + (cd $srctree; find arch/*/include include scripts -type f -o -type l) >> "$objtree/debian/hdrsrcfiles" ++(cd $srctree; find security/*/include -type f) >> "$objtree/debian/hdrsrcfiles" + (cd $srctree; find arch/$SRCARCH -name module.lds -o -name Kbuild.platforms -o -name Platform) >> "$objtree/debian/hdrsrcfiles" + (cd $srctree; find $(find arch/$SRCARCH -name include -o -name scripts -type d) -type f) >> "$objtree/debian/hdrsrcfiles" + if grep -q '^CONFIG_STACK_VALIDATION=y' $KCONFIG_CONFIG ; then +@@ -167,15 +257,19 @@ if grep -q '^CONFIG_GCC_PLUGINS=y' $KCONFIG_CONFIG ; then + fi + destdir=$kernel_headers_dir/usr/src/linux-headers-$version + mkdir -p "$destdir" ++(cd $destdir; patch -p1 < /tmp/headers-debian-byteshift.patch) + (cd $srctree; tar -c -f - -T -) < "$objtree/debian/hdrsrcfiles" | (cd $destdir; tar -xf -) + (cd $objtree; tar -c -f - -T -) < "$objtree/debian/hdrobjfiles" | (cd $destdir; tar -xf -) + (cd $objtree; cp $KCONFIG_CONFIG $destdir/.config) # copy .config manually to be where it's expected to be + ln -sf "/usr/src/linux-headers-$version" "$kernel_headers_dir/lib/modules/$version/build" + rm -f "$objtree/debian/hdrsrcfiles" "$objtree/debian/hdrobjfiles" + ++(cd $destdir; make M=scripts clean) ++ + if [ "$ARCH" != "um" ]; then + create_package "$kernel_headers_packagename" "$kernel_headers_dir" +- create_package "$libc_headers_packagename" "$libc_headers_dir" ++ # create_package "$libc_headers_packagename" "$libc_headers_dir" ++ create_package "$dtb_packagename" "$dtb_dir" + fi + + create_package "$packagename" "$tmpdir" +diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian +index 6adb3a1..00e12eb 100755 +--- a/scripts/package/mkdebian ++++ b/scripts/package/mkdebian +@@ -61,10 +61,12 @@ else + packageversion=$version-$revision + fi + sourcename=$KDEB_SOURCENAME +-packagename=linux-image-$version +-kernel_headers_packagename=linux-headers-$version ++packagename=linux-image-dev$LOCALVERSION ++kernel_headers_packagename=linux-headers-dev$LOCALVERSION ++dtb_packagename=linux-dtb-dev$LOCALVERSION + dbg_packagename=$packagename-dbg + debarch= ++image_name= + set_debarch + + if [ "$ARCH" = "um" ] ; then +@@ -168,6 +170,11 @@ Architecture: $debarch + Description: Linux kernel debugging symbols for $version + This package will come in handy if you need to debug the kernel. It provides + all the necessary debug symbols for the kernel and its modules. ++ ++Package: $dtb_packagename ++Architecture: $debarch ++Description: Linux DTB, version $version ++ This package contains device blobs from the Linux kernel, version $version + EOF + + cat < debian/rules diff --git a/patch/kernel/udoo-next/04-patch-4.4.117-118.patch b/patch/kernel/udoo-next/04-patch-4.4.117-118.patch new file mode 100644 index 000000000..2d07d1bd1 --- /dev/null +++ b/patch/kernel/udoo-next/04-patch-4.4.117-118.patch @@ -0,0 +1,9662 @@ +diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt +index 22a4688dc0c8..f53ef1ac3122 100644 +--- a/Documentation/kernel-parameters.txt ++++ b/Documentation/kernel-parameters.txt +@@ -2565,8 +2565,6 @@ bytes respectively. Such letter suffixes can also be entirely omitted. + norandmaps Don't use address space randomization. Equivalent to + echo 0 > /proc/sys/kernel/randomize_va_space + +- noreplace-paravirt [X86,IA-64,PV_OPS] Don't patch paravirt_ops +- + noreplace-smp [X86-32,SMP] Don't replace SMP instructions + with UP alternatives + +diff --git a/Documentation/speculation.txt b/Documentation/speculation.txt +new file mode 100644 +index 000000000000..e9e6cbae2841 +--- /dev/null ++++ b/Documentation/speculation.txt +@@ -0,0 +1,90 @@ ++This document explains potential effects of speculation, and how undesirable ++effects can be mitigated portably using common APIs. ++ ++=========== ++Speculation ++=========== ++ ++To improve performance and minimize average latencies, many contemporary CPUs ++employ speculative execution techniques such as branch prediction, performing ++work which may be discarded at a later stage. ++ ++Typically speculative execution cannot be observed from architectural state, ++such as the contents of registers. However, in some cases it is possible to ++observe its impact on microarchitectural state, such as the presence or ++absence of data in caches. Such state may form side-channels which can be ++observed to extract secret information. ++ ++For example, in the presence of branch prediction, it is possible for bounds ++checks to be ignored by code which is speculatively executed. Consider the ++following code: ++ ++ int load_array(int *array, unsigned int index) ++ { ++ if (index >= MAX_ARRAY_ELEMS) ++ return 0; ++ else ++ return array[index]; ++ } ++ ++Which, on arm64, may be compiled to an assembly sequence such as: ++ ++ CMP , #MAX_ARRAY_ELEMS ++ B.LT less ++ MOV , #0 ++ RET ++ less: ++ LDR , [, ] ++ RET ++ ++It is possible that a CPU mis-predicts the conditional branch, and ++speculatively loads array[index], even if index >= MAX_ARRAY_ELEMS. This ++value will subsequently be discarded, but the speculated load may affect ++microarchitectural state which can be subsequently measured. ++ ++More complex sequences involving multiple dependent memory accesses may ++result in sensitive information being leaked. Consider the following ++code, building on the prior example: ++ ++ int load_dependent_arrays(int *arr1, int *arr2, int index) ++ { ++ int val1, val2, ++ ++ val1 = load_array(arr1, index); ++ val2 = load_array(arr2, val1); ++ ++ return val2; ++ } ++ ++Under speculation, the first call to load_array() may return the value ++of an out-of-bounds address, while the second call will influence ++microarchitectural state dependent on this value. This may provide an ++arbitrary read primitive. ++ ++==================================== ++Mitigating speculation side-channels ++==================================== ++ ++The kernel provides a generic API to ensure that bounds checks are ++respected even under speculation. Architectures which are affected by ++speculation-based side-channels are expected to implement these ++primitives. ++ ++The array_index_nospec() helper in can be used to ++prevent information from being leaked via side-channels. ++ ++A call to array_index_nospec(index, size) returns a sanitized index ++value that is bounded to [0, size) even under cpu speculation ++conditions. ++ ++This can be used to protect the earlier load_array() example: ++ ++ int load_array(int *array, unsigned int index) ++ { ++ if (index >= MAX_ARRAY_ELEMS) ++ return 0; ++ else { ++ index = array_index_nospec(index, MAX_ARRAY_ELEMS); ++ return array[index]; ++ } ++ } +diff --git a/Makefile b/Makefile +index 9f53ba1835ad..1e01148744f3 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,6 +1,6 @@ + VERSION = 4 + PATCHLEVEL = 4 +-SUBLEVEL = 117 ++SUBLEVEL = 118 + EXTRAVERSION = + NAME = Blurry Fish Butt + +@@ -87,10 +87,12 @@ endif + ifneq ($(filter 4.%,$(MAKE_VERSION)),) # make-4 + ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),) + quiet=silent_ ++ tools_silent=s + endif + else # make-3.8x + ifneq ($(filter s% -s%,$(MAKEFLAGS)),) + quiet=silent_ ++ tools_silent=-s + endif + endif + +@@ -1523,11 +1525,11 @@ image_name: + # Clear a bunch of variables before executing the submake + tools/: FORCE + $(Q)mkdir -p $(objtree)/tools +- $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(filter --j% -j,$(MAKEFLAGS))" O=$(shell cd $(objtree) && /bin/pwd) subdir=tools -C $(src)/tools/ ++ $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(shell cd $(objtree) && /bin/pwd) subdir=tools -C $(src)/tools/ + + tools/%: FORCE + $(Q)mkdir -p $(objtree)/tools +- $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(filter --j% -j,$(MAKEFLAGS))" O=$(shell cd $(objtree) && /bin/pwd) subdir=tools -C $(src)/tools/ $* ++ $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(shell cd $(objtree) && /bin/pwd) subdir=tools -C $(src)/tools/ $* + + # Single targets + # --------------------------------------------------------------------------- +diff --git a/arch/arm/boot/dts/am4372.dtsi b/arch/arm/boot/dts/am4372.dtsi +index de8791a4d131..3ef1d5a26389 100644 +--- a/arch/arm/boot/dts/am4372.dtsi ++++ b/arch/arm/boot/dts/am4372.dtsi +@@ -807,7 +807,8 @@ + reg = <0x48038000 0x2000>, + <0x46000000 0x400000>; + reg-names = "mpu", "dat"; +- interrupts = <80>, <81>; ++ interrupts = , ++ ; + interrupt-names = "tx", "rx"; + status = "disabled"; + dmas = <&edma 8>, +@@ -821,7 +822,8 @@ + reg = <0x4803C000 0x2000>, + <0x46400000 0x400000>; + reg-names = "mpu", "dat"; +- interrupts = <82>, <83>; ++ interrupts = , ++ ; + interrupt-names = "tx", "rx"; + status = "disabled"; + dmas = <&edma 10>, +diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi +index 5a206c100ce2..8a5628c4b135 100644 +--- a/arch/arm/boot/dts/omap4.dtsi ++++ b/arch/arm/boot/dts/omap4.dtsi +@@ -844,14 +844,12 @@ + usbhsohci: ohci@4a064800 { + compatible = "ti,ohci-omap3"; + reg = <0x4a064800 0x400>; +- interrupt-parent = <&gic>; + interrupts = ; + }; + + usbhsehci: ehci@4a064c00 { + compatible = "ti,ehci-omap"; + reg = <0x4a064c00 0x400>; +- interrupt-parent = <&gic>; + interrupts = ; + }; + }; +diff --git a/arch/arm/mach-omap2/omap-secure.c b/arch/arm/mach-omap2/omap-secure.c +index 5ac122e88f67..9ff92050053c 100644 +--- a/arch/arm/mach-omap2/omap-secure.c ++++ b/arch/arm/mach-omap2/omap-secure.c +@@ -73,6 +73,25 @@ phys_addr_t omap_secure_ram_mempool_base(void) + return omap_secure_memblock_base; + } + ++u32 omap3_save_secure_ram(void __iomem *addr, int size) ++{ ++ u32 ret; ++ u32 param[5]; ++ ++ if (size != OMAP3_SAVE_SECURE_RAM_SZ) ++ return OMAP3_SAVE_SECURE_RAM_SZ; ++ ++ param[0] = 4; /* Number of arguments */ ++ param[1] = __pa(addr); /* Physical address for saving */ ++ param[2] = 0; ++ param[3] = 1; ++ param[4] = 1; ++ ++ ret = save_secure_ram_context(__pa(param)); ++ ++ return ret; ++} ++ + /** + * rx51_secure_dispatcher: Routine to dispatch secure PPA API calls + * @idx: The PPA API index +diff --git a/arch/arm/mach-omap2/omap-secure.h b/arch/arm/mach-omap2/omap-secure.h +index af2851fbcdf0..ab6ce2597a88 100644 +--- a/arch/arm/mach-omap2/omap-secure.h ++++ b/arch/arm/mach-omap2/omap-secure.h +@@ -31,6 +31,8 @@ + /* Maximum Secure memory storage size */ + #define OMAP_SECURE_RAM_STORAGE (88 * SZ_1K) + ++#define OMAP3_SAVE_SECURE_RAM_SZ 0x803F ++ + /* Secure low power HAL API index */ + #define OMAP4_HAL_SAVESECURERAM_INDEX 0x1a + #define OMAP4_HAL_SAVEHW_INDEX 0x1b +@@ -64,6 +66,8 @@ extern u32 omap_smc2(u32 id, u32 falg, u32 pargs); + extern u32 omap_smc3(u32 id, u32 process, u32 flag, u32 pargs); + extern phys_addr_t omap_secure_ram_mempool_base(void); + extern int omap_secure_ram_reserve_memblock(void); ++extern u32 save_secure_ram_context(u32 args_pa); ++extern u32 omap3_save_secure_ram(void __iomem *save_regs, int size); + + extern u32 rx51_secure_dispatcher(u32 idx, u32 process, u32 flag, u32 nargs, + u32 arg1, u32 arg2, u32 arg3, u32 arg4); +diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h +index b668719b9b25..8e30772cfe32 100644 +--- a/arch/arm/mach-omap2/pm.h ++++ b/arch/arm/mach-omap2/pm.h +@@ -81,10 +81,6 @@ extern unsigned int omap3_do_wfi_sz; + /* ... and its pointer from SRAM after copy */ + extern void (*omap3_do_wfi_sram)(void); + +-/* save_secure_ram_context function pointer and size, for copy to SRAM */ +-extern int save_secure_ram_context(u32 *addr); +-extern unsigned int save_secure_ram_context_sz; +- + extern void omap3_save_scratchpad_contents(void); + + #define PM_RTA_ERRATUM_i608 (1 << 0) +diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c +index 2dbd3785ee6f..181da202f981 100644 +--- a/arch/arm/mach-omap2/pm34xx.c ++++ b/arch/arm/mach-omap2/pm34xx.c +@@ -48,6 +48,7 @@ + #include "prm3xxx.h" + #include "pm.h" + #include "sdrc.h" ++#include "omap-secure.h" + #include "sram.h" + #include "control.h" + #include "vc.h" +@@ -66,7 +67,6 @@ struct power_state { + + static LIST_HEAD(pwrst_list); + +-static int (*_omap_save_secure_sram)(u32 *addr); + void (*omap3_do_wfi_sram)(void); + + static struct powerdomain *mpu_pwrdm, *neon_pwrdm; +@@ -121,8 +121,8 @@ static void omap3_save_secure_ram_context(void) + * will hang the system. + */ + pwrdm_set_next_pwrst(mpu_pwrdm, PWRDM_POWER_ON); +- ret = _omap_save_secure_sram((u32 *)(unsigned long) +- __pa(omap3_secure_ram_storage)); ++ ret = omap3_save_secure_ram(omap3_secure_ram_storage, ++ OMAP3_SAVE_SECURE_RAM_SZ); + pwrdm_set_next_pwrst(mpu_pwrdm, mpu_next_state); + /* Following is for error tracking, it should not happen */ + if (ret) { +@@ -431,15 +431,10 @@ static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused) + * + * The minimum set of functions is pushed to SRAM for execution: + * - omap3_do_wfi for erratum i581 WA, +- * - save_secure_ram_context for security extensions. + */ + void omap_push_sram_idle(void) + { + omap3_do_wfi_sram = omap_sram_push(omap3_do_wfi, omap3_do_wfi_sz); +- +- if (omap_type() != OMAP2_DEVICE_TYPE_GP) +- _omap_save_secure_sram = omap_sram_push(save_secure_ram_context, +- save_secure_ram_context_sz); + } + + static void __init pm_errata_configure(void) +@@ -551,7 +546,7 @@ int __init omap3_pm_init(void) + clkdm_add_wkdep(neon_clkdm, mpu_clkdm); + if (omap_type() != OMAP2_DEVICE_TYPE_GP) { + omap3_secure_ram_storage = +- kmalloc(0x803F, GFP_KERNEL); ++ kmalloc(OMAP3_SAVE_SECURE_RAM_SZ, GFP_KERNEL); + if (!omap3_secure_ram_storage) + pr_err("Memory allocation failed when allocating for secure sram context\n"); + +diff --git a/arch/arm/mach-omap2/prm33xx.c b/arch/arm/mach-omap2/prm33xx.c +index dcb5001d77da..973bcd754e1c 100644 +--- a/arch/arm/mach-omap2/prm33xx.c ++++ b/arch/arm/mach-omap2/prm33xx.c +@@ -176,17 +176,6 @@ static int am33xx_pwrdm_read_pwrst(struct powerdomain *pwrdm) + return v; + } + +-static int am33xx_pwrdm_read_prev_pwrst(struct powerdomain *pwrdm) +-{ +- u32 v; +- +- v = am33xx_prm_read_reg(pwrdm->prcm_offs, pwrdm->pwrstst_offs); +- v &= AM33XX_LASTPOWERSTATEENTERED_MASK; +- v >>= AM33XX_LASTPOWERSTATEENTERED_SHIFT; +- +- return v; +-} +- + static int am33xx_pwrdm_set_lowpwrstchange(struct powerdomain *pwrdm) + { + am33xx_prm_rmw_reg_bits(AM33XX_LOWPOWERSTATECHANGE_MASK, +@@ -357,7 +346,6 @@ struct pwrdm_ops am33xx_pwrdm_operations = { + .pwrdm_set_next_pwrst = am33xx_pwrdm_set_next_pwrst, + .pwrdm_read_next_pwrst = am33xx_pwrdm_read_next_pwrst, + .pwrdm_read_pwrst = am33xx_pwrdm_read_pwrst, +- .pwrdm_read_prev_pwrst = am33xx_pwrdm_read_prev_pwrst, + .pwrdm_set_logic_retst = am33xx_pwrdm_set_logic_retst, + .pwrdm_read_logic_pwrst = am33xx_pwrdm_read_logic_pwrst, + .pwrdm_read_logic_retst = am33xx_pwrdm_read_logic_retst, +diff --git a/arch/arm/mach-omap2/sleep34xx.S b/arch/arm/mach-omap2/sleep34xx.S +index 1b9f0520dea9..3e0d802c59da 100644 +--- a/arch/arm/mach-omap2/sleep34xx.S ++++ b/arch/arm/mach-omap2/sleep34xx.S +@@ -93,20 +93,13 @@ ENTRY(enable_omap3630_toggle_l2_on_restore) + ENDPROC(enable_omap3630_toggle_l2_on_restore) + + /* +- * Function to call rom code to save secure ram context. This gets +- * relocated to SRAM, so it can be all in .data section. Otherwise +- * we need to initialize api_params separately. ++ * Function to call rom code to save secure ram context. ++ * ++ * r0 = physical address of the parameters + */ +- .data +- .align 3 + ENTRY(save_secure_ram_context) + stmfd sp!, {r4 - r11, lr} @ save registers on stack +- adr r3, api_params @ r3 points to parameters +- str r0, [r3,#0x4] @ r0 has sdram address +- ldr r12, high_mask +- and r3, r3, r12 +- ldr r12, sram_phy_addr_mask +- orr r3, r3, r12 ++ mov r3, r0 @ physical address of parameters + mov r0, #25 @ set service ID for PPA + mov r12, r0 @ copy secure service ID in r12 + mov r1, #0 @ set task id for ROM code in r1 +@@ -120,18 +113,7 @@ ENTRY(save_secure_ram_context) + nop + nop + ldmfd sp!, {r4 - r11, pc} +- .align +-sram_phy_addr_mask: +- .word SRAM_BASE_P +-high_mask: +- .word 0xffff +-api_params: +- .word 0x4, 0x0, 0x0, 0x1, 0x1 + ENDPROC(save_secure_ram_context) +-ENTRY(save_secure_ram_context_sz) +- .word . - save_secure_ram_context +- +- .text + + /* + * ====================== +diff --git a/arch/arm/mach-tegra/Kconfig b/arch/arm/mach-tegra/Kconfig +index 0fa4c5f8b1be..2d43357d4a0a 100644 +--- a/arch/arm/mach-tegra/Kconfig ++++ b/arch/arm/mach-tegra/Kconfig +@@ -12,8 +12,6 @@ menuconfig ARCH_TEGRA + select ARCH_HAS_RESET_CONTROLLER + select RESET_CONTROLLER + select SOC_BUS +- select USB_ULPI if USB_PHY +- select USB_ULPI_VIEWPORT if USB_PHY + help + This enables support for NVIDIA Tegra based systems. + +diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig +index 83af36d9439f..02c08671553e 100644 +--- a/arch/arm64/Kconfig ++++ b/arch/arm64/Kconfig +@@ -785,7 +785,7 @@ source "fs/Kconfig.binfmt" + config COMPAT + bool "Kernel support for 32-bit EL0" + depends on ARM64_4K_PAGES || EXPERT +- select COMPAT_BINFMT_ELF ++ select COMPAT_BINFMT_ELF if BINFMT_ELF + select HAVE_UID16 + select OLD_SIGSUSPEND3 + select COMPAT_OLD_SIGACTION +diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms +index 4043c35962cc..5edb50772c11 100644 +--- a/arch/arm64/Kconfig.platforms ++++ b/arch/arm64/Kconfig.platforms +@@ -90,8 +90,6 @@ config ARCH_TEGRA_132_SOC + bool "NVIDIA Tegra132 SoC" + depends on ARCH_TEGRA + select PINCTRL_TEGRA124 +- select USB_ULPI if USB_PHY +- select USB_ULPI_VIEWPORT if USB_PHY + help + Enable support for NVIDIA Tegra132 SoC, based on the Denver + ARMv8 CPU. The Tegra132 SoC is similar to the Tegra124 SoC, +diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi b/arch/arm64/boot/dts/mediatek/mt8173.dtsi +index 4dd5f93d0303..7f42b646d528 100644 +--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi ++++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi +@@ -54,6 +54,7 @@ + reg = <0x000>; + enable-method = "psci"; + cpu-idle-states = <&CPU_SLEEP_0>; ++ #cooling-cells = <2>; + }; + + cpu1: cpu@1 { +@@ -70,6 +71,7 @@ + reg = <0x100>; + enable-method = "psci"; + cpu-idle-states = <&CPU_SLEEP_0>; ++ #cooling-cells = <2>; + }; + + cpu3: cpu@101 { +diff --git a/arch/arm64/include/asm/bug.h b/arch/arm64/include/asm/bug.h +index 4a748ce9ba1a..ac6382b25add 100644 +--- a/arch/arm64/include/asm/bug.h ++++ b/arch/arm64/include/asm/bug.h +@@ -20,9 +20,6 @@ + + #include + +-#ifdef CONFIG_GENERIC_BUG +-#define HAVE_ARCH_BUG +- + #ifdef CONFIG_DEBUG_BUGVERBOSE + #define _BUGVERBOSE_LOCATION(file, line) __BUGVERBOSE_LOCATION(file, line) + #define __BUGVERBOSE_LOCATION(file, line) \ +@@ -36,28 +33,36 @@ + #define _BUGVERBOSE_LOCATION(file, line) + #endif + +-#define _BUG_FLAGS(flags) __BUG_FLAGS(flags) ++#ifdef CONFIG_GENERIC_BUG + +-#define __BUG_FLAGS(flags) asm volatile ( \ ++#define __BUG_ENTRY(flags) \ + ".pushsection __bug_table,\"a\"\n\t" \ + ".align 2\n\t" \ + "0: .long 1f - 0b\n\t" \ + _BUGVERBOSE_LOCATION(__FILE__, __LINE__) \ + ".short " #flags "\n\t" \ + ".popsection\n" \ +- \ +- "1: brk %[imm]" \ +- :: [imm] "i" (BUG_BRK_IMM) \ +-) ++ "1: " ++#else ++#define __BUG_ENTRY(flags) "" ++#endif ++ ++#define __BUG_FLAGS(flags) \ ++ asm volatile ( \ ++ __BUG_ENTRY(flags) \ ++ "brk %[imm]" :: [imm] "i" (BUG_BRK_IMM) \ ++ ); + +-#define BUG() do { \ +- _BUG_FLAGS(0); \ +- unreachable(); \ ++ ++#define BUG() do { \ ++ __BUG_FLAGS(0); \ ++ unreachable(); \ + } while (0) + +-#define __WARN_TAINT(taint) _BUG_FLAGS(BUGFLAG_TAINT(taint)) ++#define __WARN_TAINT(taint) \ ++ __BUG_FLAGS(BUGFLAG_TAINT(taint)) + +-#endif /* ! CONFIG_GENERIC_BUG */ ++#define HAVE_ARCH_BUG + + #include + +diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c +index b2ab164a8094..4eba7c00ea1f 100644 +--- a/arch/powerpc/perf/core-book3s.c ++++ b/arch/powerpc/perf/core-book3s.c +@@ -1381,7 +1381,7 @@ static int collect_events(struct perf_event *group, int max_count, + int n = 0; + struct perf_event *event; + +- if (!is_software_event(group)) { ++ if (group->pmu->task_ctx_nr == perf_hw_context) { + if (n >= max_count) + return -1; + ctrs[n] = group; +@@ -1389,7 +1389,7 @@ static int collect_events(struct perf_event *group, int max_count, + events[n++] = group->hw.config; + } + list_for_each_entry(event, &group->sibling_list, group_entry) { +- if (!is_software_event(event) && ++ if (event->pmu->task_ctx_nr == perf_hw_context && + event->state != PERF_EVENT_STATE_OFF) { + if (n >= max_count) + return -1; +diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig +index 2db93042f2f3..bb6aab2fa7f5 100644 +--- a/arch/x86/Kconfig ++++ b/arch/x86/Kconfig +@@ -1009,7 +1009,7 @@ config X86_MCE_THRESHOLD + def_bool y + + config X86_MCE_INJECT +- depends on X86_MCE ++ depends on X86_MCE && X86_LOCAL_APIC + tristate "Machine check injector support" + ---help--- + Provide support for injecting machine checks for testing purposes. +diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug +index 137dfa96aa14..da00fe1f48f4 100644 +--- a/arch/x86/Kconfig.debug ++++ b/arch/x86/Kconfig.debug +@@ -391,6 +391,7 @@ config X86_DEBUG_FPU + + config PUNIT_ATOM_DEBUG + tristate "ATOM Punit debug driver" ++ depends on PCI + select DEBUG_FS + select IOSF_MBI + ---help--- +diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile +index c0cc2a6be0bf..6da2cd0897f3 100644 +--- a/arch/x86/boot/Makefile ++++ b/arch/x86/boot/Makefile +@@ -64,12 +64,13 @@ GCOV_PROFILE := n + $(obj)/bzImage: asflags-y := $(SVGA_MODE) + + quiet_cmd_image = BUILD $@ ++silent_redirect_image = >/dev/null + cmd_image = $(obj)/tools/build $(obj)/setup.bin $(obj)/vmlinux.bin \ +- $(obj)/zoffset.h $@ ++ $(obj)/zoffset.h $@ $($(quiet)redirect_image) + + $(obj)/bzImage: $(obj)/setup.bin $(obj)/vmlinux.bin $(obj)/tools/build FORCE + $(call if_changed,image) +- @echo 'Kernel: $@ is ready' ' (#'`cat .version`')' ++ @$(kecho) 'Kernel: $@ is ready' ' (#'`cat .version`')' + + OBJCOPYFLAGS_vmlinux.bin := -O binary -R .note -R .comment -S + $(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE +diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S +index 1c3b7ceb36d2..e7273a606a07 100644 +--- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S ++++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S +@@ -55,29 +55,31 @@ + #define RAB1bl %bl + #define RAB2bl %cl + ++#define CD0 0x0(%rsp) ++#define CD1 0x8(%rsp) ++#define CD2 0x10(%rsp) ++ ++# used only before/after all rounds + #define RCD0 %r8 + #define RCD1 %r9 + #define RCD2 %r10 + +-#define RCD0d %r8d +-#define RCD1d %r9d +-#define RCD2d %r10d +- +-#define RX0 %rbp +-#define RX1 %r11 +-#define RX2 %r12 ++# used only during rounds ++#define RX0 %r8 ++#define RX1 %r9 ++#define RX2 %r10 + +-#define RX0d %ebp +-#define RX1d %r11d +-#define RX2d %r12d ++#define RX0d %r8d ++#define RX1d %r9d ++#define RX2d %r10d + +-#define RY0 %r13 +-#define RY1 %r14 +-#define RY2 %r15 ++#define RY0 %r11 ++#define RY1 %r12 ++#define RY2 %r13 + +-#define RY0d %r13d +-#define RY1d %r14d +-#define RY2d %r15d ++#define RY0d %r11d ++#define RY1d %r12d ++#define RY2d %r13d + + #define RT0 %rdx + #define RT1 %rsi +@@ -85,6 +87,8 @@ + #define RT0d %edx + #define RT1d %esi + ++#define RT1bl %sil ++ + #define do16bit_ror(rot, op1, op2, T0, T1, tmp1, tmp2, ab, dst) \ + movzbl ab ## bl, tmp2 ## d; \ + movzbl ab ## bh, tmp1 ## d; \ +@@ -92,6 +96,11 @@ + op1##l T0(CTX, tmp2, 4), dst ## d; \ + op2##l T1(CTX, tmp1, 4), dst ## d; + ++#define swap_ab_with_cd(ab, cd, tmp) \ ++ movq cd, tmp; \ ++ movq ab, cd; \ ++ movq tmp, ab; ++ + /* + * Combined G1 & G2 function. Reordered with help of rotates to have moves + * at begining. +@@ -110,15 +119,15 @@ + /* G1,2 && G2,2 */ \ + do16bit_ror(32, xor, xor, Tx2, Tx3, RT0, RT1, ab ## 0, x ## 0); \ + do16bit_ror(16, xor, xor, Ty3, Ty0, RT0, RT1, ab ## 0, y ## 0); \ +- xchgq cd ## 0, ab ## 0; \ ++ swap_ab_with_cd(ab ## 0, cd ## 0, RT0); \ + \ + do16bit_ror(32, xor, xor, Tx2, Tx3, RT0, RT1, ab ## 1, x ## 1); \ + do16bit_ror(16, xor, xor, Ty3, Ty0, RT0, RT1, ab ## 1, y ## 1); \ +- xchgq cd ## 1, ab ## 1; \ ++ swap_ab_with_cd(ab ## 1, cd ## 1, RT0); \ + \ + do16bit_ror(32, xor, xor, Tx2, Tx3, RT0, RT1, ab ## 2, x ## 2); \ + do16bit_ror(16, xor, xor, Ty3, Ty0, RT0, RT1, ab ## 2, y ## 2); \ +- xchgq cd ## 2, ab ## 2; ++ swap_ab_with_cd(ab ## 2, cd ## 2, RT0); + + #define enc_round_end(ab, x, y, n) \ + addl y ## d, x ## d; \ +@@ -168,6 +177,16 @@ + decrypt_round3(ba, dc, (n*2)+1); \ + decrypt_round3(ba, dc, (n*2)); + ++#define push_cd() \ ++ pushq RCD2; \ ++ pushq RCD1; \ ++ pushq RCD0; ++ ++#define pop_cd() \ ++ popq RCD0; \ ++ popq RCD1; \ ++ popq RCD2; ++ + #define inpack3(in, n, xy, m) \ + movq 4*(n)(in), xy ## 0; \ + xorq w+4*m(CTX), xy ## 0; \ +@@ -223,11 +242,8 @@ ENTRY(__twofish_enc_blk_3way) + * %rdx: src, RIO + * %rcx: bool, if true: xor output + */ +- pushq %r15; +- pushq %r14; + pushq %r13; + pushq %r12; +- pushq %rbp; + pushq %rbx; + + pushq %rcx; /* bool xor */ +@@ -235,40 +251,36 @@ ENTRY(__twofish_enc_blk_3way) + + inpack_enc3(); + +- encrypt_cycle3(RAB, RCD, 0); +- encrypt_cycle3(RAB, RCD, 1); +- encrypt_cycle3(RAB, RCD, 2); +- encrypt_cycle3(RAB, RCD, 3); +- encrypt_cycle3(RAB, RCD, 4); +- encrypt_cycle3(RAB, RCD, 5); +- encrypt_cycle3(RAB, RCD, 6); +- encrypt_cycle3(RAB, RCD, 7); ++ push_cd(); ++ encrypt_cycle3(RAB, CD, 0); ++ encrypt_cycle3(RAB, CD, 1); ++ encrypt_cycle3(RAB, CD, 2); ++ encrypt_cycle3(RAB, CD, 3); ++ encrypt_cycle3(RAB, CD, 4); ++ encrypt_cycle3(RAB, CD, 5); ++ encrypt_cycle3(RAB, CD, 6); ++ encrypt_cycle3(RAB, CD, 7); ++ pop_cd(); + + popq RIO; /* dst */ +- popq %rbp; /* bool xor */ ++ popq RT1; /* bool xor */ + +- testb %bpl, %bpl; ++ testb RT1bl, RT1bl; + jnz .L__enc_xor3; + + outunpack_enc3(mov); + + popq %rbx; +- popq %rbp; + popq %r12; + popq %r13; +- popq %r14; +- popq %r15; + ret; + + .L__enc_xor3: + outunpack_enc3(xor); + + popq %rbx; +- popq %rbp; + popq %r12; + popq %r13; +- popq %r14; +- popq %r15; + ret; + ENDPROC(__twofish_enc_blk_3way) + +@@ -278,35 +290,31 @@ ENTRY(twofish_dec_blk_3way) + * %rsi: dst + * %rdx: src, RIO + */ +- pushq %r15; +- pushq %r14; + pushq %r13; + pushq %r12; +- pushq %rbp; + pushq %rbx; + + pushq %rsi; /* dst */ + + inpack_dec3(); + +- decrypt_cycle3(RAB, RCD, 7); +- decrypt_cycle3(RAB, RCD, 6); +- decrypt_cycle3(RAB, RCD, 5); +- decrypt_cycle3(RAB, RCD, 4); +- decrypt_cycle3(RAB, RCD, 3); +- decrypt_cycle3(RAB, RCD, 2); +- decrypt_cycle3(RAB, RCD, 1); +- decrypt_cycle3(RAB, RCD, 0); ++ push_cd(); ++ decrypt_cycle3(RAB, CD, 7); ++ decrypt_cycle3(RAB, CD, 6); ++ decrypt_cycle3(RAB, CD, 5); ++ decrypt_cycle3(RAB, CD, 4); ++ decrypt_cycle3(RAB, CD, 3); ++ decrypt_cycle3(RAB, CD, 2); ++ decrypt_cycle3(RAB, CD, 1); ++ decrypt_cycle3(RAB, CD, 0); ++ pop_cd(); + + popq RIO; /* dst */ + + outunpack_dec3(); + + popq %rbx; +- popq %rbp; + popq %r12; + popq %r13; +- popq %r14; +- popq %r15; + ret; + ENDPROC(twofish_dec_blk_3way) +diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c +index 1a4477cedc49..b5eb1cca70a0 100644 +--- a/arch/x86/entry/common.c ++++ b/arch/x86/entry/common.c +@@ -20,6 +20,7 @@ + #include + #include + #include ++#include + #include + + #include +@@ -381,6 +382,7 @@ __always_inline void do_syscall_32_irqs_on(struct pt_regs *regs) + } + + if (likely(nr < IA32_NR_syscalls)) { ++ nr = array_index_nospec(nr, IA32_NR_syscalls); + /* + * It's possible that a 32-bit syscall implementation + * takes a 64-bit parameter but nonetheless assumes that +diff --git a/arch/x86/include/asm/asm-prototypes.h b/arch/x86/include/asm/asm-prototypes.h +index b15aa4083dfd..5a25ada75aeb 100644 +--- a/arch/x86/include/asm/asm-prototypes.h ++++ b/arch/x86/include/asm/asm-prototypes.h +@@ -37,5 +37,4 @@ INDIRECT_THUNK(dx) + INDIRECT_THUNK(si) + INDIRECT_THUNK(di) + INDIRECT_THUNK(bp) +-INDIRECT_THUNK(sp) + #endif /* CONFIG_RETPOLINE */ +diff --git a/arch/x86/include/asm/barrier.h b/arch/x86/include/asm/barrier.h +index 0681d2532527..814ef83c6720 100644 +--- a/arch/x86/include/asm/barrier.h ++++ b/arch/x86/include/asm/barrier.h +@@ -24,6 +24,34 @@ + #define wmb() asm volatile("sfence" ::: "memory") + #endif + ++/** ++ * array_index_mask_nospec() - generate a mask that is ~0UL when the ++ * bounds check succeeds and 0 otherwise ++ * @index: array element index ++ * @size: number of elements in array ++ * ++ * Returns: ++ * 0 - (index < size) ++ */ ++static inline unsigned long array_index_mask_nospec(unsigned long index, ++ unsigned long size) ++{ ++ unsigned long mask; ++ ++ asm ("cmp %1,%2; sbb %0,%0;" ++ :"=r" (mask) ++ :"r"(size),"r" (index) ++ :"cc"); ++ return mask; ++} ++ ++/* Override the default implementation from linux/nospec.h. */ ++#define array_index_mask_nospec array_index_mask_nospec ++ ++/* Prevent speculative execution past this barrier. */ ++#define barrier_nospec() alternative_2("", "mfence", X86_FEATURE_MFENCE_RDTSC, \ ++ "lfence", X86_FEATURE_LFENCE_RDTSC) ++ + #ifdef CONFIG_X86_PPRO_FENCE + #define dma_rmb() rmb() + #else +diff --git a/arch/x86/include/asm/microcode_amd.h b/arch/x86/include/asm/microcode_amd.h +index adfc847a395e..fb163f02ebb1 100644 +--- a/arch/x86/include/asm/microcode_amd.h ++++ b/arch/x86/include/asm/microcode_amd.h +@@ -59,7 +59,6 @@ static inline u16 find_equiv_id(struct equiv_cpu_entry *equiv_cpu_table, + + extern int __apply_microcode_amd(struct microcode_amd *mc_amd); + extern int apply_microcode_amd(int cpu); +-extern enum ucode_state load_microcode_amd(int cpu, u8 family, const u8 *data, size_t size); + + #define PATCH_MAX_SIZE PAGE_SIZE + extern u8 amd_ucode_patch[PATCH_MAX_SIZE]; +diff --git a/arch/x86/include/asm/msr.h b/arch/x86/include/asm/msr.h +index 77d8b284e4a7..5a10ac8c131e 100644 +--- a/arch/x86/include/asm/msr.h ++++ b/arch/x86/include/asm/msr.h +@@ -147,8 +147,7 @@ static __always_inline unsigned long long rdtsc_ordered(void) + * that some other imaginary CPU is updating continuously with a + * time stamp. + */ +- alternative_2("", "mfence", X86_FEATURE_MFENCE_RDTSC, +- "lfence", X86_FEATURE_LFENCE_RDTSC); ++ barrier_nospec(); + return rdtsc(); + } + +diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h +index 492370b9b35b..66094a0473a8 100644 +--- a/arch/x86/include/asm/nospec-branch.h ++++ b/arch/x86/include/asm/nospec-branch.h +@@ -1,7 +1,7 @@ + /* SPDX-License-Identifier: GPL-2.0 */ + +-#ifndef __NOSPEC_BRANCH_H__ +-#define __NOSPEC_BRANCH_H__ ++#ifndef _ASM_X86_NOSPEC_BRANCH_H_ ++#define _ASM_X86_NOSPEC_BRANCH_H_ + + #include + #include +@@ -178,7 +178,7 @@ extern char __indirect_thunk_end[]; + * On VMEXIT we must ensure that no RSB predictions learned in the guest + * can be followed in the host, by overwriting the RSB completely. Both + * retpoline and IBRS mitigations for Spectre v2 need this; only on future +- * CPUs with IBRS_ATT *might* it be avoided. ++ * CPUs with IBRS_ALL *might* it be avoided. + */ + static inline void vmexit_fill_RSB(void) + { +@@ -195,4 +195,4 @@ static inline void vmexit_fill_RSB(void) + } + + #endif /* __ASSEMBLY__ */ +-#endif /* __NOSPEC_BRANCH_H__ */ ++#endif /* _ASM_X86_NOSPEC_BRANCH_H_ */ +diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h +index 14c63c7e8337..6b6e16d813b9 100644 +--- a/arch/x86/include/asm/vmx.h ++++ b/arch/x86/include/asm/vmx.h +@@ -400,10 +400,11 @@ enum vmcs_field { + #define IDENTITY_PAGETABLE_PRIVATE_MEMSLOT (KVM_USER_MEM_SLOTS + 2) + + #define VMX_NR_VPIDS (1 << 16) ++#define VMX_VPID_EXTENT_INDIVIDUAL_ADDR 0 + #define VMX_VPID_EXTENT_SINGLE_CONTEXT 1 + #define VMX_VPID_EXTENT_ALL_CONTEXT 2 ++#define VMX_VPID_EXTENT_SINGLE_NON_GLOBAL 3 + +-#define VMX_EPT_EXTENT_INDIVIDUAL_ADDR 0 + #define VMX_EPT_EXTENT_CONTEXT 1 + #define VMX_EPT_EXTENT_GLOBAL 2 + #define VMX_EPT_EXTENT_SHIFT 24 +@@ -420,8 +421,10 @@ enum vmcs_field { + #define VMX_EPT_EXTENT_GLOBAL_BIT (1ull << 26) + + #define VMX_VPID_INVVPID_BIT (1ull << 0) /* (32 - 32) */ ++#define VMX_VPID_EXTENT_INDIVIDUAL_ADDR_BIT (1ull << 8) /* (40 - 32) */ + #define VMX_VPID_EXTENT_SINGLE_CONTEXT_BIT (1ull << 9) /* (41 - 32) */ + #define VMX_VPID_EXTENT_GLOBAL_CONTEXT_BIT (1ull << 10) /* (42 - 32) */ ++#define VMX_VPID_EXTENT_SINGLE_NON_GLOBAL_BIT (1ull << 11) /* (43 - 32) */ + + #define VMX_EPT_DEFAULT_GAW 3 + #define VMX_EPT_MAX_GAW 0x4 +diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c +index d6f375f1b928..89829c3d5a74 100644 +--- a/arch/x86/kernel/alternative.c ++++ b/arch/x86/kernel/alternative.c +@@ -45,17 +45,6 @@ static int __init setup_noreplace_smp(char *str) + } + __setup("noreplace-smp", setup_noreplace_smp); + +-#ifdef CONFIG_PARAVIRT +-static int __initdata_or_module noreplace_paravirt = 0; +- +-static int __init setup_noreplace_paravirt(char *str) +-{ +- noreplace_paravirt = 1; +- return 1; +-} +-__setup("noreplace-paravirt", setup_noreplace_paravirt); +-#endif +- + #define DPRINTK(fmt, args...) \ + do { \ + if (debug_alternative) \ +@@ -587,9 +576,6 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start, + struct paravirt_patch_site *p; + char insnbuf[MAX_PATCH_LEN]; + +- if (noreplace_paravirt) +- return; +- + for (p = start; p < end; p++) { + unsigned int used; + +diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c +index 8cacf62ec458..ecaf7c9baf75 100644 +--- a/arch/x86/kernel/cpu/bugs.c ++++ b/arch/x86/kernel/cpu/bugs.c +@@ -10,6 +10,7 @@ + #include + #include + #include ++#include + + #include + #include +@@ -89,20 +90,42 @@ static const char *spectre_v2_strings[] = { + }; + + #undef pr_fmt +-#define pr_fmt(fmt) "Spectre V2 mitigation: " fmt ++#define pr_fmt(fmt) "Spectre V2 : " fmt + + static enum spectre_v2_mitigation spectre_v2_enabled = SPECTRE_V2_NONE; + ++ ++#ifdef RETPOLINE ++static bool spectre_v2_bad_module; ++ ++bool retpoline_module_ok(bool has_retpoline) ++{ ++ if (spectre_v2_enabled == SPECTRE_V2_NONE || has_retpoline) ++ return true; ++ ++ pr_err("System may be vulnerable to spectre v2\n"); ++ spectre_v2_bad_module = true; ++ return false; ++} ++ ++static inline const char *spectre_v2_module_string(void) ++{ ++ return spectre_v2_bad_module ? " - vulnerable module loaded" : ""; ++} ++#else ++static inline const char *spectre_v2_module_string(void) { return ""; } ++#endif ++ + static void __init spec2_print_if_insecure(const char *reason) + { + if (boot_cpu_has_bug(X86_BUG_SPECTRE_V2)) +- pr_info("%s\n", reason); ++ pr_info("%s selected on command line.\n", reason); + } + + static void __init spec2_print_if_secure(const char *reason) + { + if (!boot_cpu_has_bug(X86_BUG_SPECTRE_V2)) +- pr_info("%s\n", reason); ++ pr_info("%s selected on command line.\n", reason); + } + + static inline bool retp_compiler(void) +@@ -117,42 +140,68 @@ static inline bool match_option(const char *arg, int arglen, const char *opt) + return len == arglen && !strncmp(arg, opt, len); + } + ++static const struct { ++ const char *option; ++ enum spectre_v2_mitigation_cmd cmd; ++ bool secure; ++} mitigation_options[] = { ++ { "off", SPECTRE_V2_CMD_NONE, false }, ++ { "on", SPECTRE_V2_CMD_FORCE, true }, ++ { "retpoline", SPECTRE_V2_CMD_RETPOLINE, false }, ++ { "retpoline,amd", SPECTRE_V2_CMD_RETPOLINE_AMD, false }, ++ { "retpoline,generic", SPECTRE_V2_CMD_RETPOLINE_GENERIC, false }, ++ { "auto", SPECTRE_V2_CMD_AUTO, false }, ++}; ++ + static enum spectre_v2_mitigation_cmd __init spectre_v2_parse_cmdline(void) + { + char arg[20]; +- int ret; +- +- ret = cmdline_find_option(boot_command_line, "spectre_v2", arg, +- sizeof(arg)); +- if (ret > 0) { +- if (match_option(arg, ret, "off")) { +- goto disable; +- } else if (match_option(arg, ret, "on")) { +- spec2_print_if_secure("force enabled on command line."); +- return SPECTRE_V2_CMD_FORCE; +- } else if (match_option(arg, ret, "retpoline")) { +- spec2_print_if_insecure("retpoline selected on command line."); +- return SPECTRE_V2_CMD_RETPOLINE; +- } else if (match_option(arg, ret, "retpoline,amd")) { +- if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD) { +- pr_err("retpoline,amd selected but CPU is not AMD. Switching to AUTO select\n"); +- return SPECTRE_V2_CMD_AUTO; +- } +- spec2_print_if_insecure("AMD retpoline selected on command line."); +- return SPECTRE_V2_CMD_RETPOLINE_AMD; +- } else if (match_option(arg, ret, "retpoline,generic")) { +- spec2_print_if_insecure("generic retpoline selected on command line."); +- return SPECTRE_V2_CMD_RETPOLINE_GENERIC; +- } else if (match_option(arg, ret, "auto")) { ++ int ret, i; ++ enum spectre_v2_mitigation_cmd cmd = SPECTRE_V2_CMD_AUTO; ++ ++ if (cmdline_find_option_bool(boot_command_line, "nospectre_v2")) ++ return SPECTRE_V2_CMD_NONE; ++ else { ++ ret = cmdline_find_option(boot_command_line, "spectre_v2", arg, ++ sizeof(arg)); ++ if (ret < 0) ++ return SPECTRE_V2_CMD_AUTO; ++ ++ for (i = 0; i < ARRAY_SIZE(mitigation_options); i++) { ++ if (!match_option(arg, ret, mitigation_options[i].option)) ++ continue; ++ cmd = mitigation_options[i].cmd; ++ break; ++ } ++ ++ if (i >= ARRAY_SIZE(mitigation_options)) { ++ pr_err("unknown option (%s). Switching to AUTO select\n", ++ mitigation_options[i].option); + return SPECTRE_V2_CMD_AUTO; + } + } + +- if (!cmdline_find_option_bool(boot_command_line, "nospectre_v2")) ++ if ((cmd == SPECTRE_V2_CMD_RETPOLINE || ++ cmd == SPECTRE_V2_CMD_RETPOLINE_AMD || ++ cmd == SPECTRE_V2_CMD_RETPOLINE_GENERIC) && ++ !IS_ENABLED(CONFIG_RETPOLINE)) { ++ pr_err("%s selected but not compiled in. Switching to AUTO select\n", ++ mitigation_options[i].option); + return SPECTRE_V2_CMD_AUTO; +-disable: +- spec2_print_if_insecure("disabled on command line."); +- return SPECTRE_V2_CMD_NONE; ++ } ++ ++ if (cmd == SPECTRE_V2_CMD_RETPOLINE_AMD && ++ boot_cpu_data.x86_vendor != X86_VENDOR_AMD) { ++ pr_err("retpoline,amd selected but CPU is not AMD. Switching to AUTO select\n"); ++ return SPECTRE_V2_CMD_AUTO; ++ } ++ ++ if (mitigation_options[i].secure) ++ spec2_print_if_secure(mitigation_options[i].option); ++ else ++ spec2_print_if_insecure(mitigation_options[i].option); ++ ++ return cmd; + } + + /* Check for Skylake-like CPUs (for RSB handling) */ +@@ -190,10 +239,10 @@ static void __init spectre_v2_select_mitigation(void) + return; + + case SPECTRE_V2_CMD_FORCE: +- /* FALLTRHU */ + case SPECTRE_V2_CMD_AUTO: +- goto retpoline_auto; +- ++ if (IS_ENABLED(CONFIG_RETPOLINE)) ++ goto retpoline_auto; ++ break; + case SPECTRE_V2_CMD_RETPOLINE_AMD: + if (IS_ENABLED(CONFIG_RETPOLINE)) + goto retpoline_amd; +@@ -268,7 +317,7 @@ ssize_t cpu_show_spectre_v1(struct device *dev, + { + if (!boot_cpu_has_bug(X86_BUG_SPECTRE_V1)) + return sprintf(buf, "Not affected\n"); +- return sprintf(buf, "Vulnerable\n"); ++ return sprintf(buf, "Mitigation: __user pointer sanitization\n"); + } + + ssize_t cpu_show_spectre_v2(struct device *dev, +@@ -277,6 +326,7 @@ ssize_t cpu_show_spectre_v2(struct device *dev, + if (!boot_cpu_has_bug(X86_BUG_SPECTRE_V2)) + return sprintf(buf, "Not affected\n"); + +- return sprintf(buf, "%s\n", spectre_v2_strings[spectre_v2_enabled]); ++ return sprintf(buf, "%s%s\n", spectre_v2_strings[spectre_v2_enabled], ++ spectre_v2_module_string()); + } + #endif +diff --git a/arch/x86/kernel/cpu/mcheck/mce-inject.c b/arch/x86/kernel/cpu/mcheck/mce-inject.c +index 4cfba4371a71..101bfae369e1 100644 +--- a/arch/x86/kernel/cpu/mcheck/mce-inject.c ++++ b/arch/x86/kernel/cpu/mcheck/mce-inject.c +@@ -152,7 +152,6 @@ static void raise_mce(struct mce *m) + if (context == MCJ_CTX_RANDOM) + return; + +-#ifdef CONFIG_X86_LOCAL_APIC + if (m->inject_flags & (MCJ_IRQ_BROADCAST | MCJ_NMI_BROADCAST)) { + unsigned long start; + int cpu; +@@ -193,9 +192,7 @@ static void raise_mce(struct mce *m) + raise_local(); + put_cpu(); + put_online_cpus(); +- } else +-#endif +- { ++ } else { + preempt_disable(); + raise_local(); + preempt_enable(); +diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c +index 2a0f44d225fe..6da6f9cd6d2d 100644 +--- a/arch/x86/kernel/cpu/microcode/amd.c ++++ b/arch/x86/kernel/cpu/microcode/amd.c +@@ -131,6 +131,9 @@ static size_t compute_container_size(u8 *data, u32 total_size) + return size; + } + ++static enum ucode_state ++load_microcode_amd(bool save, u8 family, const u8 *data, size_t size); ++ + /* + * Early load occurs before we can vmalloc(). So we look for the microcode + * patch container file in initrd, traverse equivalent cpu table, look for a +@@ -438,7 +441,7 @@ int __init save_microcode_in_initrd_amd(void) + eax = cpuid_eax(0x00000001); + eax = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff); + +- ret = load_microcode_amd(smp_processor_id(), eax, container, container_size); ++ ret = load_microcode_amd(true, eax, container, container_size); + if (ret != UCODE_OK) + retval = -EINVAL; + +@@ -854,7 +857,8 @@ static enum ucode_state __load_microcode_amd(u8 family, const u8 *data, + return UCODE_OK; + } + +-enum ucode_state load_microcode_amd(int cpu, u8 family, const u8 *data, size_t size) ++static enum ucode_state ++load_microcode_amd(bool save, u8 family, const u8 *data, size_t size) + { + enum ucode_state ret; + +@@ -868,8 +872,8 @@ enum ucode_state load_microcode_amd(int cpu, u8 family, const u8 *data, size_t s + + #ifdef CONFIG_X86_32 + /* save BSP's matching patch for early load */ +- if (cpu_data(cpu).cpu_index == boot_cpu_data.cpu_index) { +- struct ucode_patch *p = find_patch(cpu); ++ if (save) { ++ struct ucode_patch *p = find_patch(0); + if (p) { + memset(amd_ucode_patch, 0, PATCH_MAX_SIZE); + memcpy(amd_ucode_patch, p->data, min_t(u32, ksize(p->data), +@@ -901,11 +905,12 @@ static enum ucode_state request_microcode_amd(int cpu, struct device *device, + { + char fw_name[36] = "amd-ucode/microcode_amd.bin"; + struct cpuinfo_x86 *c = &cpu_data(cpu); ++ bool bsp = c->cpu_index == boot_cpu_data.cpu_index; + enum ucode_state ret = UCODE_NFOUND; + const struct firmware *fw; + + /* reload ucode container only on the boot cpu */ +- if (!refresh_fw || c->cpu_index != boot_cpu_data.cpu_index) ++ if (!refresh_fw || !bsp) + return UCODE_OK; + + if (c->x86 >= 0x15) +@@ -922,7 +927,7 @@ static enum ucode_state request_microcode_amd(int cpu, struct device *device, + goto fw_release; + } + +- ret = load_microcode_amd(cpu, c->x86, fw->data, fw->size); ++ ret = load_microcode_amd(bsp, c->x86, fw->data, fw->size); + + fw_release: + release_firmware(fw); +diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c +index 5b2f2306fbcc..b52a8d08ab36 100644 +--- a/arch/x86/kernel/cpu/perf_event.c ++++ b/arch/x86/kernel/cpu/perf_event.c +@@ -188,8 +188,8 @@ static void release_pmc_hardware(void) {} + + static bool check_hw_exists(void) + { +- u64 val, val_fail, val_new= ~0; +- int i, reg, reg_fail, ret = 0; ++ u64 val, val_fail = -1, val_new= ~0; ++ int i, reg, reg_fail = -1, ret = 0; + int bios_fail = 0; + int reg_safe = -1; + +diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S +index 8f1a3f443f7d..70284d38fdc2 100644 +--- a/arch/x86/kernel/head_32.S ++++ b/arch/x86/kernel/head_32.S +@@ -669,14 +669,17 @@ __PAGE_ALIGNED_BSS + initial_pg_pmd: + .fill 1024*KPMDS,4,0 + #else +-ENTRY(initial_page_table) ++.globl initial_page_table ++initial_page_table: + .fill 1024,4,0 + #endif + initial_pg_fixmap: + .fill 1024,4,0 +-ENTRY(empty_zero_page) ++.globl empty_zero_page ++empty_zero_page: + .fill 4096,1,0 +-ENTRY(swapper_pg_dir) ++.globl swapper_pg_dir ++swapper_pg_dir: + .fill 1024,4,0 + + /* +diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig +index 639a6e34500c..53b7f53f6207 100644 +--- a/arch/x86/kvm/Kconfig ++++ b/arch/x86/kvm/Kconfig +@@ -22,7 +22,8 @@ config KVM + depends on HAVE_KVM + depends on HIGH_RES_TIMERS + # for TASKSTATS/TASK_DELAY_ACCT: +- depends on NET ++ depends on NET && MULTIUSER ++ depends on X86_LOCAL_APIC + select PREEMPT_NOTIFIERS + select MMU_NOTIFIER + select ANON_INODES +diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c +index e4eb1d2bf849..8864fec63a20 100644 +--- a/arch/x86/kvm/emulate.c ++++ b/arch/x86/kvm/emulate.c +@@ -26,6 +26,7 @@ + #include + #include + #include ++#include + + #include "x86.h" + #include "tss.h" +@@ -1000,8 +1001,8 @@ static u8 test_cc(unsigned int condition, unsigned long flags) + void (*fop)(void) = (void *)em_setcc + 4 * (condition & 0xf); + + flags = (flags & EFLAGS_MASK) | X86_EFLAGS_IF; +- asm("push %[flags]; popf; call *%[fastop]" +- : "=a"(rc) : [fastop]"r"(fop), [flags]"r"(flags)); ++ asm("push %[flags]; popf; " CALL_NOSPEC ++ : "=a"(rc) : [thunk_target]"r"(fop), [flags]"r"(flags)); + return rc; + } + +@@ -5297,9 +5298,9 @@ static int fastop(struct x86_emulate_ctxt *ctxt, void (*fop)(struct fastop *)) + ulong flags = (ctxt->eflags & EFLAGS_MASK) | X86_EFLAGS_IF; + if (!(ctxt->d & ByteOp)) + fop += __ffs(ctxt->dst.bytes) * FASTOP_SIZE; +- asm("push %[flags]; popf; call *%[fastop]; pushf; pop %[flags]\n" ++ asm("push %[flags]; popf; " CALL_NOSPEC "; pushf; pop %[flags]\n" + : "+a"(ctxt->dst.val), "+d"(ctxt->src.val), [flags]"+D"(flags), +- [fastop]"+S"(fop) ++ [thunk_target]"+S"(fop) + : "c"(ctxt->src2.val)); + ctxt->eflags = (ctxt->eflags & ~EFLAGS_MASK) | (flags & EFLAGS_MASK); + if (!fop) /* exception is returned in fop variable */ +diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c +index 2a1a8737015b..849517805eef 100644 +--- a/arch/x86/kvm/vmx.c ++++ b/arch/x86/kvm/vmx.c +@@ -32,6 +32,7 @@ + #include + #include + #include ++#include + #include "kvm_cache_regs.h" + #include "x86.h" + +@@ -125,6 +126,12 @@ module_param_named(pml, enable_pml, bool, S_IRUGO); + + #define VMX_MISC_EMULATED_PREEMPTION_TIMER_RATE 5 + ++#define VMX_VPID_EXTENT_SUPPORTED_MASK \ ++ (VMX_VPID_EXTENT_INDIVIDUAL_ADDR_BIT | \ ++ VMX_VPID_EXTENT_SINGLE_CONTEXT_BIT | \ ++ VMX_VPID_EXTENT_GLOBAL_CONTEXT_BIT | \ ++ VMX_VPID_EXTENT_SINGLE_NON_GLOBAL_BIT) ++ + /* + * These 2 parameters are used to config the controls for Pause-Loop Exiting: + * ple_gap: upper bound on the amount of time between two successive +@@ -827,21 +834,18 @@ static const unsigned short vmcs_field_to_offset_table[] = { + + static inline short vmcs_field_to_offset(unsigned long field) + { +- BUILD_BUG_ON(ARRAY_SIZE(vmcs_field_to_offset_table) > SHRT_MAX); ++ const size_t size = ARRAY_SIZE(vmcs_field_to_offset_table); ++ unsigned short offset; + +- if (field >= ARRAY_SIZE(vmcs_field_to_offset_table)) ++ BUILD_BUG_ON(size > SHRT_MAX); ++ if (field >= size) + return -ENOENT; + +- /* +- * FIXME: Mitigation for CVE-2017-5753. To be replaced with a +- * generic mechanism. +- */ +- asm("lfence"); +- +- if (vmcs_field_to_offset_table[field] == 0) ++ field = array_index_nospec(field, size); ++ offset = vmcs_field_to_offset_table[field]; ++ if (offset == 0) + return -ENOENT; +- +- return vmcs_field_to_offset_table[field]; ++ return offset; + } + + static inline struct vmcs12 *get_vmcs12(struct kvm_vcpu *vcpu) +@@ -2659,8 +2663,7 @@ static void nested_vmx_setup_ctls_msrs(struct vcpu_vmx *vmx) + */ + if (enable_vpid) + vmx->nested.nested_vmx_vpid_caps = VMX_VPID_INVVPID_BIT | +- VMX_VPID_EXTENT_SINGLE_CONTEXT_BIT | +- VMX_VPID_EXTENT_GLOBAL_CONTEXT_BIT; ++ VMX_VPID_EXTENT_SUPPORTED_MASK; + else + vmx->nested.nested_vmx_vpid_caps = 0; + +@@ -4514,7 +4517,7 @@ static int vmx_cpu_uses_apicv(struct kvm_vcpu *vcpu) + return enable_apicv && lapic_in_kernel(vcpu); + } + +-static int vmx_complete_nested_posted_interrupt(struct kvm_vcpu *vcpu) ++static void vmx_complete_nested_posted_interrupt(struct kvm_vcpu *vcpu) + { + struct vcpu_vmx *vmx = to_vmx(vcpu); + int max_irr; +@@ -4525,19 +4528,15 @@ static int vmx_complete_nested_posted_interrupt(struct kvm_vcpu *vcpu) + vmx->nested.pi_pending) { + vmx->nested.pi_pending = false; + if (!pi_test_and_clear_on(vmx->nested.pi_desc)) +- return 0; ++ return; + + max_irr = find_last_bit( + (unsigned long *)vmx->nested.pi_desc->pir, 256); + + if (max_irr == 256) +- return 0; ++ return; + + vapic_page = kmap(vmx->nested.virtual_apic_page); +- if (!vapic_page) { +- WARN_ON(1); +- return -ENOMEM; +- } + __kvm_apic_update_irr(vmx->nested.pi_desc->pir, vapic_page); + kunmap(vmx->nested.virtual_apic_page); + +@@ -4548,7 +4547,6 @@ static int vmx_complete_nested_posted_interrupt(struct kvm_vcpu *vcpu) + vmcs_write16(GUEST_INTR_STATUS, status); + } + } +- return 0; + } + + static inline bool kvm_vcpu_trigger_posted_interrupt(struct kvm_vcpu *vcpu) +@@ -7368,7 +7366,7 @@ static int handle_invept(struct kvm_vcpu *vcpu) + + types = (vmx->nested.nested_vmx_ept_caps >> VMX_EPT_EXTENT_SHIFT) & 6; + +- if (!(types & (1UL << type))) { ++ if (type >= 32 || !(types & (1 << type))) { + nested_vmx_failValid(vcpu, + VMXERR_INVALID_OPERAND_TO_INVEPT_INVVPID); + skip_emulated_instruction(vcpu); +@@ -7425,9 +7423,10 @@ static int handle_invvpid(struct kvm_vcpu *vcpu) + vmx_instruction_info = vmcs_read32(VMX_INSTRUCTION_INFO); + type = kvm_register_readl(vcpu, (vmx_instruction_info >> 28) & 0xf); + +- types = (vmx->nested.nested_vmx_vpid_caps >> 8) & 0x7; ++ types = (vmx->nested.nested_vmx_vpid_caps & ++ VMX_VPID_EXTENT_SUPPORTED_MASK) >> 8; + +- if (!(types & (1UL << type))) { ++ if (type >= 32 || !(types & (1 << type))) { + nested_vmx_failValid(vcpu, + VMXERR_INVALID_OPERAND_TO_INVEPT_INVVPID); + skip_emulated_instruction(vcpu); +@@ -7447,21 +7446,27 @@ static int handle_invvpid(struct kvm_vcpu *vcpu) + } + + switch (type) { ++ case VMX_VPID_EXTENT_INDIVIDUAL_ADDR: + case VMX_VPID_EXTENT_SINGLE_CONTEXT: +- /* +- * Old versions of KVM use the single-context version so we +- * have to support it; just treat it the same as all-context. +- */ ++ case VMX_VPID_EXTENT_SINGLE_NON_GLOBAL: ++ if (!vpid) { ++ nested_vmx_failValid(vcpu, ++ VMXERR_INVALID_OPERAND_TO_INVEPT_INVVPID); ++ skip_emulated_instruction(vcpu); ++ return 1; ++ } ++ break; + case VMX_VPID_EXTENT_ALL_CONTEXT: +- __vmx_flush_tlb(vcpu, to_vmx(vcpu)->nested.vpid02); +- nested_vmx_succeed(vcpu); + break; + default: +- /* Trap individual address invalidation invvpid calls */ +- BUG_ON(1); +- break; ++ WARN_ON_ONCE(1); ++ skip_emulated_instruction(vcpu); ++ return 1; + } + ++ __vmx_flush_tlb(vcpu, vmx->nested.vpid02); ++ nested_vmx_succeed(vcpu); ++ + skip_emulated_instruction(vcpu); + return 1; + } +@@ -8377,13 +8382,13 @@ static void vmx_handle_external_intr(struct kvm_vcpu *vcpu) + "pushf\n\t" + "orl $0x200, (%%" _ASM_SP ")\n\t" + __ASM_SIZE(push) " $%c[cs]\n\t" +- "call *%[entry]\n\t" ++ CALL_NOSPEC + : + #ifdef CONFIG_X86_64 + [sp]"=&r"(tmp) + #endif + : +- [entry]"r"(entry), ++ THUNK_TARGET(entry), + [ss]"i"(__KERNEL_DS), + [cs]"i"(__KERNEL_CS) + ); +@@ -9240,11 +9245,6 @@ static inline bool nested_vmx_merge_msr_bitmap(struct kvm_vcpu *vcpu, + return false; + } + msr_bitmap = (unsigned long *)kmap(page); +- if (!msr_bitmap) { +- nested_release_page_clean(page); +- WARN_ON(1); +- return false; +- } + + if (nested_cpu_has_virt_x2apic_mode(vmcs12)) { + if (nested_cpu_has_apic_reg_virt(vmcs12)) +@@ -10166,7 +10166,8 @@ static int vmx_check_nested_events(struct kvm_vcpu *vcpu, bool external_intr) + return 0; + } + +- return vmx_complete_nested_posted_interrupt(vcpu); ++ vmx_complete_nested_posted_interrupt(vcpu); ++ return 0; + } + + static u32 vmx_get_preemption_timer_value(struct kvm_vcpu *vcpu) +diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c +index 3900d34980de..f37f0c72b22a 100644 +--- a/arch/x86/kvm/x86.c ++++ b/arch/x86/kvm/x86.c +@@ -2755,6 +2755,12 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu) + kvm_x86_ops->vcpu_put(vcpu); + kvm_put_guest_fpu(vcpu); + vcpu->arch.last_host_tsc = rdtsc(); ++ /* ++ * If userspace has set any breakpoints or watchpoints, dr6 is restored ++ * on every vmexit, but if not, we might have a stale dr6 from the ++ * guest. do_debug expects dr6 to be cleared after it runs, do the same. ++ */ ++ set_debugreg(0, 6); + } + + static int kvm_vcpu_ioctl_get_lapic(struct kvm_vcpu *vcpu, +@@ -8204,6 +8210,13 @@ static int apf_put_user(struct kvm_vcpu *vcpu, u32 val) + sizeof(val)); + } + ++static int apf_get_user(struct kvm_vcpu *vcpu, u32 *val) ++{ ++ ++ return kvm_read_guest_cached(vcpu->kvm, &vcpu->arch.apf.data, val, ++ sizeof(u32)); ++} ++ + void kvm_arch_async_page_not_present(struct kvm_vcpu *vcpu, + struct kvm_async_pf *work) + { +@@ -8230,6 +8243,7 @@ void kvm_arch_async_page_present(struct kvm_vcpu *vcpu, + struct kvm_async_pf *work) + { + struct x86_exception fault; ++ u32 val; + + if (work->wakeup_all) + work->arch.token = ~0; /* broadcast wakeup */ +@@ -8237,14 +8251,24 @@ void kvm_arch_async_page_present(struct kvm_vcpu *vcpu, + kvm_del_async_pf_gfn(vcpu, work->arch.gfn); + trace_kvm_async_pf_ready(work->arch.token, work->gva); + +- if ((vcpu->arch.apf.msr_val & KVM_ASYNC_PF_ENABLED) && +- !apf_put_user(vcpu, KVM_PV_REASON_PAGE_READY)) { +- fault.vector = PF_VECTOR; +- fault.error_code_valid = true; +- fault.error_code = 0; +- fault.nested_page_fault = false; +- fault.address = work->arch.token; +- kvm_inject_page_fault(vcpu, &fault); ++ if (vcpu->arch.apf.msr_val & KVM_ASYNC_PF_ENABLED && ++ !apf_get_user(vcpu, &val)) { ++ if (val == KVM_PV_REASON_PAGE_NOT_PRESENT && ++ vcpu->arch.exception.pending && ++ vcpu->arch.exception.nr == PF_VECTOR && ++ !apf_put_user(vcpu, 0)) { ++ vcpu->arch.exception.pending = false; ++ vcpu->arch.exception.nr = 0; ++ vcpu->arch.exception.has_error_code = false; ++ vcpu->arch.exception.error_code = 0; ++ } else if (!apf_put_user(vcpu, KVM_PV_REASON_PAGE_READY)) { ++ fault.vector = PF_VECTOR; ++ fault.error_code_valid = true; ++ fault.error_code = 0; ++ fault.nested_page_fault = false; ++ fault.address = work->arch.token; ++ kvm_inject_page_fault(vcpu, &fault); ++ } + } + vcpu->arch.apf.halted = false; + vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE; +diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S +index 46668cda4ffd..490b2ee4e4bb 100644 +--- a/arch/x86/lib/getuser.S ++++ b/arch/x86/lib/getuser.S +@@ -38,6 +38,8 @@ ENTRY(__get_user_1) + GET_THREAD_INFO(%_ASM_DX) + cmp TI_addr_limit(%_ASM_DX),%_ASM_AX + jae bad_get_user ++ sbb %_ASM_DX, %_ASM_DX /* array_index_mask_nospec() */ ++ and %_ASM_DX, %_ASM_AX + ASM_STAC + 1: movzbl (%_ASM_AX),%edx + xor %eax,%eax +@@ -51,6 +53,8 @@ ENTRY(__get_user_2) + GET_THREAD_INFO(%_ASM_DX) + cmp TI_addr_limit(%_ASM_DX),%_ASM_AX + jae bad_get_user ++ sbb %_ASM_DX, %_ASM_DX /* array_index_mask_nospec() */ ++ and %_ASM_DX, %_ASM_AX + ASM_STAC + 2: movzwl -1(%_ASM_AX),%edx + xor %eax,%eax +@@ -64,6 +68,8 @@ ENTRY(__get_user_4) + GET_THREAD_INFO(%_ASM_DX) + cmp TI_addr_limit(%_ASM_DX),%_ASM_AX + jae bad_get_user ++ sbb %_ASM_DX, %_ASM_DX /* array_index_mask_nospec() */ ++ and %_ASM_DX, %_ASM_AX + ASM_STAC + 3: movl -3(%_ASM_AX),%edx + xor %eax,%eax +@@ -78,6 +84,8 @@ ENTRY(__get_user_8) + GET_THREAD_INFO(%_ASM_DX) + cmp TI_addr_limit(%_ASM_DX),%_ASM_AX + jae bad_get_user ++ sbb %_ASM_DX, %_ASM_DX /* array_index_mask_nospec() */ ++ and %_ASM_DX, %_ASM_AX + ASM_STAC + 4: movq -7(%_ASM_AX),%rdx + xor %eax,%eax +@@ -89,6 +97,8 @@ ENTRY(__get_user_8) + GET_THREAD_INFO(%_ASM_DX) + cmp TI_addr_limit(%_ASM_DX),%_ASM_AX + jae bad_get_user_8 ++ sbb %_ASM_DX, %_ASM_DX /* array_index_mask_nospec() */ ++ and %_ASM_DX, %_ASM_AX + ASM_STAC + 4: movl -7(%_ASM_AX),%edx + 5: movl -3(%_ASM_AX),%ecx +diff --git a/arch/x86/lib/retpoline.S b/arch/x86/lib/retpoline.S +index e611a124c442..3d06b482ebc7 100644 +--- a/arch/x86/lib/retpoline.S ++++ b/arch/x86/lib/retpoline.S +@@ -36,7 +36,6 @@ GENERATE_THUNK(_ASM_DX) + GENERATE_THUNK(_ASM_SI) + GENERATE_THUNK(_ASM_DI) + GENERATE_THUNK(_ASM_BP) +-GENERATE_THUNK(_ASM_SP) + #ifdef CONFIG_64BIT + GENERATE_THUNK(r8) + GENERATE_THUNK(r9) +diff --git a/arch/x86/math-emu/Makefile b/arch/x86/math-emu/Makefile +index 9b0c63b60302..1b2dac174321 100644 +--- a/arch/x86/math-emu/Makefile ++++ b/arch/x86/math-emu/Makefile +@@ -5,8 +5,8 @@ + #DEBUG = -DDEBUGGING + DEBUG = + PARANOID = -DPARANOID +-EXTRA_CFLAGS := $(PARANOID) $(DEBUG) -fno-builtin $(MATH_EMULATION) +-EXTRA_AFLAGS := $(PARANOID) ++ccflags-y += $(PARANOID) $(DEBUG) -fno-builtin $(MATH_EMULATION) ++asflags-y += $(PARANOID) + + # From 'C' language sources: + C_OBJS =fpu_entry.o errors.o \ +diff --git a/arch/x86/math-emu/reg_compare.c b/arch/x86/math-emu/reg_compare.c +index b77360fdbf4a..19b33b50adfa 100644 +--- a/arch/x86/math-emu/reg_compare.c ++++ b/arch/x86/math-emu/reg_compare.c +@@ -168,7 +168,7 @@ static int compare(FPU_REG const *b, int tagb) + /* This function requires that st(0) is not empty */ + int FPU_compare_st_data(FPU_REG const *loaded_data, u_char loaded_tag) + { +- int f = 0, c; ++ int f, c; + + c = compare(loaded_data, loaded_tag); + +@@ -189,12 +189,12 @@ int FPU_compare_st_data(FPU_REG const *loaded_data, u_char loaded_tag) + case COMP_No_Comp: + f = SW_C3 | SW_C2 | SW_C0; + break; +-#ifdef PARANOID + default: ++#ifdef PARANOID + EXCEPTION(EX_INTERNAL | 0x121); ++#endif /* PARANOID */ + f = SW_C3 | SW_C2 | SW_C0; + break; +-#endif /* PARANOID */ + } + setcc(f); + if (c & COMP_Denormal) { +@@ -205,7 +205,7 @@ int FPU_compare_st_data(FPU_REG const *loaded_data, u_char loaded_tag) + + static int compare_st_st(int nr) + { +- int f = 0, c; ++ int f, c; + FPU_REG *st_ptr; + + if (!NOT_EMPTY(0) || !NOT_EMPTY(nr)) { +@@ -235,12 +235,12 @@ static int compare_st_st(int nr) + case COMP_No_Comp: + f = SW_C3 | SW_C2 | SW_C0; + break; +-#ifdef PARANOID + default: ++#ifdef PARANOID + EXCEPTION(EX_INTERNAL | 0x122); ++#endif /* PARANOID */ + f = SW_C3 | SW_C2 | SW_C0; + break; +-#endif /* PARANOID */ + } + setcc(f); + if (c & COMP_Denormal) { +@@ -283,12 +283,12 @@ static int compare_i_st_st(int nr) + case COMP_No_Comp: + f = X86_EFLAGS_ZF | X86_EFLAGS_PF | X86_EFLAGS_CF; + break; +-#ifdef PARANOID + default: ++#ifdef PARANOID + EXCEPTION(EX_INTERNAL | 0x122); ++#endif /* PARANOID */ + f = 0; + break; +-#endif /* PARANOID */ + } + FPU_EFLAGS = (FPU_EFLAGS & ~(X86_EFLAGS_ZF | X86_EFLAGS_PF | X86_EFLAGS_CF)) | f; + if (c & COMP_Denormal) { +diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c +index b9c78f3bcd67..53ab3f367472 100644 +--- a/arch/x86/mm/ioremap.c ++++ b/arch/x86/mm/ioremap.c +@@ -348,11 +348,11 @@ void iounmap(volatile void __iomem *addr) + (void __force *)addr < phys_to_virt(ISA_END_ADDRESS)) + return; + ++ mmiotrace_iounmap(addr); ++ + addr = (volatile void __iomem *) + (PAGE_MASK & (unsigned long __force)addr); + +- mmiotrace_iounmap(addr); +- + /* Use the vm area unlocked, assuming the caller + ensures there isn't another iounmap for the same address + in parallel. Reuse of the virtual address is prevented by +diff --git a/arch/x86/mm/kmmio.c b/arch/x86/mm/kmmio.c +index ddb2244b06a1..76604c8a2a48 100644 +--- a/arch/x86/mm/kmmio.c ++++ b/arch/x86/mm/kmmio.c +@@ -434,17 +434,18 @@ int register_kmmio_probe(struct kmmio_probe *p) + unsigned long flags; + int ret = 0; + unsigned long size = 0; ++ unsigned long addr = p->addr & PAGE_MASK; + const unsigned long size_lim = p->len + (p->addr & ~PAGE_MASK); + unsigned int l; + pte_t *pte; + + spin_lock_irqsave(&kmmio_lock, flags); +- if (get_kmmio_probe(p->addr)) { ++ if (get_kmmio_probe(addr)) { + ret = -EEXIST; + goto out; + } + +- pte = lookup_address(p->addr, &l); ++ pte = lookup_address(addr, &l); + if (!pte) { + ret = -EINVAL; + goto out; +@@ -453,7 +454,7 @@ int register_kmmio_probe(struct kmmio_probe *p) + kmmio_count++; + list_add_rcu(&p->list, &kmmio_probes); + while (size < size_lim) { +- if (add_kmmio_fault_page(p->addr + size)) ++ if (add_kmmio_fault_page(addr + size)) + pr_err("Unable to set page fault.\n"); + size += page_level_size(l); + } +@@ -527,19 +528,20 @@ void unregister_kmmio_probe(struct kmmio_probe *p) + { + unsigned long flags; + unsigned long size = 0; ++ unsigned long addr = p->addr & PAGE_MASK; + const unsigned long size_lim = p->len + (p->addr & ~PAGE_MASK); + struct kmmio_fault_page *release_list = NULL; + struct kmmio_delayed_release *drelease; + unsigned int l; + pte_t *pte; + +- pte = lookup_address(p->addr, &l); ++ pte = lookup_address(addr, &l); + if (!pte) + return; + + spin_lock_irqsave(&kmmio_lock, flags); + while (size < size_lim) { +- release_kmmio_fault_page(p->addr + size, &release_list); ++ release_kmmio_fault_page(addr + size, &release_list); + size += page_level_size(l); + } + list_del_rcu(&p->list); +diff --git a/arch/x86/platform/olpc/olpc-xo15-sci.c b/arch/x86/platform/olpc/olpc-xo15-sci.c +index 55130846ac87..c0533fbc39e3 100644 +--- a/arch/x86/platform/olpc/olpc-xo15-sci.c ++++ b/arch/x86/platform/olpc/olpc-xo15-sci.c +@@ -196,6 +196,7 @@ static int xo15_sci_remove(struct acpi_device *device) + return 0; + } + ++#ifdef CONFIG_PM_SLEEP + static int xo15_sci_resume(struct device *dev) + { + /* Enable all EC events */ +@@ -207,6 +208,7 @@ static int xo15_sci_resume(struct device *dev) + + return 0; + } ++#endif + + static SIMPLE_DEV_PM_OPS(xo15_sci_pm, NULL, xo15_sci_resume); + +diff --git a/certs/Makefile b/certs/Makefile +index 28ac694dd11a..2773c4afa24c 100644 +--- a/certs/Makefile ++++ b/certs/Makefile +@@ -36,29 +36,34 @@ ifndef CONFIG_MODULE_SIG_HASH + $(error Could not determine digest type to use from kernel config) + endif + ++redirect_openssl = 2>&1 ++quiet_redirect_openssl = 2>&1 ++silent_redirect_openssl = 2>/dev/null ++ + # We do it this way rather than having a boolean option for enabling an + # external private key, because 'make randconfig' might enable such a + # boolean option and we unfortunately can't make it depend on !RANDCONFIG. + ifeq ($(CONFIG_MODULE_SIG_KEY),"certs/signing_key.pem") + $(obj)/signing_key.pem: $(obj)/x509.genkey +- @echo "###" +- @echo "### Now generating an X.509 key pair to be used for signing modules." +- @echo "###" +- @echo "### If this takes a long time, you might wish to run rngd in the" +- @echo "### background to keep the supply of entropy topped up. It" +- @echo "### needs to be run as root, and uses a hardware random" +- @echo "### number generator if one is available." +- @echo "###" +- openssl req -new -nodes -utf8 -$(CONFIG_MODULE_SIG_HASH) -days 36500 \ ++ @$(kecho) "###" ++ @$(kecho) "### Now generating an X.509 key pair to be used for signing modules." ++ @$(kecho) "###" ++ @$(kecho) "### If this takes a long time, you might wish to run rngd in the" ++ @$(kecho) "### background to keep the supply of entropy topped up. It" ++ @$(kecho) "### needs to be run as root, and uses a hardware random" ++ @$(kecho) "### number generator if one is available." ++ @$(kecho) "###" ++ $(Q)openssl req -new -nodes -utf8 -$(CONFIG_MODULE_SIG_HASH) -days 36500 \ + -batch -x509 -config $(obj)/x509.genkey \ + -outform PEM -out $(obj)/signing_key.pem \ +- -keyout $(obj)/signing_key.pem 2>&1 +- @echo "###" +- @echo "### Key pair generated." +- @echo "###" ++ -keyout $(obj)/signing_key.pem \ ++ $($(quiet)redirect_openssl) ++ @$(kecho) "###" ++ @$(kecho) "### Key pair generated." ++ @$(kecho) "###" + + $(obj)/x509.genkey: +- @echo Generating X.509 key generation config ++ @$(kecho) Generating X.509 key generation config + @echo >$@ "[ req ]" + @echo >>$@ "default_bits = 4096" + @echo >>$@ "distinguished_name = req_distinguished_name" +diff --git a/drivers/Makefile b/drivers/Makefile +index 098997f2cc3a..f42a74ebc1be 100644 +--- a/drivers/Makefile ++++ b/drivers/Makefile +@@ -96,6 +96,7 @@ obj-$(CONFIG_TC) += tc/ + obj-$(CONFIG_UWB) += uwb/ + obj-$(CONFIG_USB_PHY) += usb/ + obj-$(CONFIG_USB) += usb/ ++obj-$(CONFIG_USB_SUPPORT) += usb/ + obj-$(CONFIG_PCI) += usb/ + obj-$(CONFIG_USB_GADGET) += usb/ + obj-$(CONFIG_OF) += usb/ +diff --git a/drivers/android/binder.c b/drivers/android/binder.c +index 5531f020e561..55613f6f7c0e 100644 +--- a/drivers/android/binder.c ++++ b/drivers/android/binder.c +@@ -2622,6 +2622,8 @@ static unsigned int binder_poll(struct file *filp, + binder_lock(__func__); + + thread = binder_get_thread(proc); ++ if (!thread) ++ return POLLERR; + + wait_for_proc_work = thread->transaction_stack == NULL && + list_empty(&thread->todo) && thread->return_error == BR_OK; +diff --git a/drivers/char/hw_random/exynos-rng.c b/drivers/char/hw_random/exynos-rng.c +index 7845a38b6604..7ba0ae060d61 100644 +--- a/drivers/char/hw_random/exynos-rng.c ++++ b/drivers/char/hw_random/exynos-rng.c +@@ -155,8 +155,7 @@ static int exynos_rng_probe(struct platform_device *pdev) + return ret; + } + +-#ifdef CONFIG_PM +-static int exynos_rng_runtime_suspend(struct device *dev) ++static int __maybe_unused exynos_rng_runtime_suspend(struct device *dev) + { + struct platform_device *pdev = to_platform_device(dev); + struct exynos_rng *exynos_rng = platform_get_drvdata(pdev); +@@ -166,7 +165,7 @@ static int exynos_rng_runtime_suspend(struct device *dev) + return 0; + } + +-static int exynos_rng_runtime_resume(struct device *dev) ++static int __maybe_unused exynos_rng_runtime_resume(struct device *dev) + { + struct platform_device *pdev = to_platform_device(dev); + struct exynos_rng *exynos_rng = platform_get_drvdata(pdev); +@@ -174,12 +173,12 @@ static int exynos_rng_runtime_resume(struct device *dev) + return clk_prepare_enable(exynos_rng->clk); + } + +-static int exynos_rng_suspend(struct device *dev) ++static int __maybe_unused exynos_rng_suspend(struct device *dev) + { + return pm_runtime_force_suspend(dev); + } + +-static int exynos_rng_resume(struct device *dev) ++static int __maybe_unused exynos_rng_resume(struct device *dev) + { + struct platform_device *pdev = to_platform_device(dev); + struct exynos_rng *exynos_rng = platform_get_drvdata(pdev); +@@ -191,7 +190,6 @@ static int exynos_rng_resume(struct device *dev) + + return exynos_rng_configure(exynos_rng); + } +-#endif + + static const struct dev_pm_ops exynos_rng_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(exynos_rng_suspend, exynos_rng_resume) +diff --git a/drivers/crypto/s5p-sss.c b/drivers/crypto/s5p-sss.c +index fd39893079d5..45ea8957a73a 100644 +--- a/drivers/crypto/s5p-sss.c ++++ b/drivers/crypto/s5p-sss.c +@@ -401,16 +401,21 @@ static void s5p_aes_crypt_start(struct s5p_aes_dev *dev, unsigned long mode) + uint32_t aes_control; + int err; + unsigned long flags; ++ u8 *iv; + + aes_control = SSS_AES_KEY_CHANGE_MODE; + if (mode & FLAGS_AES_DECRYPT) + aes_control |= SSS_AES_MODE_DECRYPT; + +- if ((mode & FLAGS_AES_MODE_MASK) == FLAGS_AES_CBC) ++ if ((mode & FLAGS_AES_MODE_MASK) == FLAGS_AES_CBC) { + aes_control |= SSS_AES_CHAIN_MODE_CBC; +- else if ((mode & FLAGS_AES_MODE_MASK) == FLAGS_AES_CTR) ++ iv = req->info; ++ } else if ((mode & FLAGS_AES_MODE_MASK) == FLAGS_AES_CTR) { + aes_control |= SSS_AES_CHAIN_MODE_CTR; +- ++ iv = req->info; ++ } else { ++ iv = NULL; /* AES_ECB */ ++ } + if (dev->ctx->keylen == AES_KEYSIZE_192) + aes_control |= SSS_AES_KEY_SIZE_192; + else if (dev->ctx->keylen == AES_KEYSIZE_256) +@@ -440,7 +445,7 @@ static void s5p_aes_crypt_start(struct s5p_aes_dev *dev, unsigned long mode) + goto outdata_error; + + SSS_AES_WRITE(dev, AES_CONTROL, aes_control); +- s5p_set_aes(dev, dev->ctx->aes_key, req->info, dev->ctx->keylen); ++ s5p_set_aes(dev, dev->ctx->aes_key, iv, dev->ctx->keylen); + + s5p_set_dma_indata(dev, req->src); + s5p_set_dma_outdata(dev, req->dst); +diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c +index 53d22eb73b56..be26f625bb3e 100644 +--- a/drivers/dma/at_hdmac.c ++++ b/drivers/dma/at_hdmac.c +@@ -716,7 +716,7 @@ atc_prep_dma_interleaved(struct dma_chan *chan, + unsigned long flags) + { + struct at_dma_chan *atchan = to_at_dma_chan(chan); +- struct data_chunk *first = xt->sgl; ++ struct data_chunk *first; + struct at_desc *desc = NULL; + size_t xfer_count; + unsigned int dwidth; +@@ -728,6 +728,8 @@ atc_prep_dma_interleaved(struct dma_chan *chan, + if (unlikely(!xt || xt->numf != 1 || !xt->frame_size)) + return NULL; + ++ first = xt->sgl; ++ + dev_info(chan2dev(chan), + "%s: src=%pad, dest=%pad, numf=%d, frame_size=%d, flags=0x%lx\n", + __func__, &xt->src_start, &xt->dst_start, xt->numf, +diff --git a/drivers/dma/dma-jz4740.c b/drivers/dma/dma-jz4740.c +index 7638b24ce8d0..35fc58f4bf4b 100644 +--- a/drivers/dma/dma-jz4740.c ++++ b/drivers/dma/dma-jz4740.c +@@ -557,7 +557,7 @@ static int jz4740_dma_probe(struct platform_device *pdev) + + ret = dma_async_device_register(dd); + if (ret) +- return ret; ++ goto err_clk; + + irq = platform_get_irq(pdev, 0); + ret = request_irq(irq, jz4740_dma_irq, 0, dev_name(&pdev->dev), dmadev); +@@ -570,6 +570,8 @@ static int jz4740_dma_probe(struct platform_device *pdev) + + err_unregister: + dma_async_device_unregister(dd); ++err_clk: ++ clk_disable_unprepare(dmadev->clk); + return ret; + } + +diff --git a/drivers/dma/ioat/init.c b/drivers/dma/ioat/init.c +index abb75ebd65ea..ac8c28968422 100644 +--- a/drivers/dma/ioat/init.c ++++ b/drivers/dma/ioat/init.c +@@ -395,7 +395,7 @@ static int ioat_dma_self_test(struct ioatdma_device *ioat_dma) + if (memcmp(src, dest, IOAT_TEST_SIZE)) { + dev_err(dev, "Self-test copy failed compare, disabling\n"); + err = -ENODEV; +- goto free_resources; ++ goto unmap_dma; + } + + unmap_dma: +diff --git a/drivers/dma/zx296702_dma.c b/drivers/dma/zx296702_dma.c +index 6059d81e701a..8e55403847b2 100644 +--- a/drivers/dma/zx296702_dma.c ++++ b/drivers/dma/zx296702_dma.c +@@ -26,7 +26,7 @@ + + #define DRIVER_NAME "zx-dma" + #define DMA_ALIGN 4 +-#define DMA_MAX_SIZE (0x10000 - PAGE_SIZE) ++#define DMA_MAX_SIZE (0x10000 - 512) + #define LLI_BLOCK_SIZE (4 * PAGE_SIZE) + + #define REG_ZX_SRC_ADDR 0x00 +diff --git a/drivers/gpio/gpio-intel-mid.c b/drivers/gpio/gpio-intel-mid.c +index c50e930d97d3..297121acc57d 100644 +--- a/drivers/gpio/gpio-intel-mid.c ++++ b/drivers/gpio/gpio-intel-mid.c +@@ -326,7 +326,7 @@ static void intel_mid_irq_init_hw(struct intel_mid_gpio *priv) + } + } + +-static int intel_gpio_runtime_idle(struct device *dev) ++static int __maybe_unused intel_gpio_runtime_idle(struct device *dev) + { + int err = pm_schedule_suspend(dev, 500); + return err ?: -EBUSY; +diff --git a/drivers/gpio/gpio-xgene.c b/drivers/gpio/gpio-xgene.c +index 18a8182d4fec..7f1f32324504 100644 +--- a/drivers/gpio/gpio-xgene.c ++++ b/drivers/gpio/gpio-xgene.c +@@ -42,9 +42,7 @@ struct xgene_gpio { + struct gpio_chip chip; + void __iomem *base; + spinlock_t lock; +-#ifdef CONFIG_PM + u32 set_dr_val[XGENE_MAX_GPIO_BANKS]; +-#endif + }; + + static inline struct xgene_gpio *to_xgene_gpio(struct gpio_chip *chip) +@@ -132,8 +130,7 @@ static int xgene_gpio_dir_out(struct gpio_chip *gc, + return 0; + } + +-#ifdef CONFIG_PM +-static int xgene_gpio_suspend(struct device *dev) ++static __maybe_unused int xgene_gpio_suspend(struct device *dev) + { + struct xgene_gpio *gpio = dev_get_drvdata(dev); + unsigned long bank_offset; +@@ -146,7 +143,7 @@ static int xgene_gpio_suspend(struct device *dev) + return 0; + } + +-static int xgene_gpio_resume(struct device *dev) ++static __maybe_unused int xgene_gpio_resume(struct device *dev) + { + struct xgene_gpio *gpio = dev_get_drvdata(dev); + unsigned long bank_offset; +@@ -160,10 +157,6 @@ static int xgene_gpio_resume(struct device *dev) + } + + static SIMPLE_DEV_PM_OPS(xgene_gpio_pm, xgene_gpio_suspend, xgene_gpio_resume); +-#define XGENE_GPIO_PM_OPS (&xgene_gpio_pm) +-#else +-#define XGENE_GPIO_PM_OPS NULL +-#endif + + static int xgene_gpio_probe(struct platform_device *pdev) + { +@@ -230,7 +223,7 @@ static struct platform_driver xgene_gpio_driver = { + .driver = { + .name = "xgene-gpio", + .of_match_table = xgene_gpio_of_match, +- .pm = XGENE_GPIO_PM_OPS, ++ .pm = &xgene_gpio_pm, + }, + .probe = xgene_gpio_probe, + .remove = xgene_gpio_remove, +diff --git a/drivers/gpu/drm/armada/armada_crtc.c b/drivers/gpu/drm/armada/armada_crtc.c +index cebcab560626..5d68189176cc 100644 +--- a/drivers/gpu/drm/armada/armada_crtc.c ++++ b/drivers/gpu/drm/armada/armada_crtc.c +@@ -1182,17 +1182,13 @@ static int armada_drm_crtc_create(struct drm_device *drm, struct device *dev, + + ret = devm_request_irq(dev, irq, armada_drm_irq, 0, "armada_drm_crtc", + dcrtc); +- if (ret < 0) { +- kfree(dcrtc); +- return ret; +- } ++ if (ret < 0) ++ goto err_crtc; + + if (dcrtc->variant->init) { + ret = dcrtc->variant->init(dcrtc, dev); +- if (ret) { +- kfree(dcrtc); +- return ret; +- } ++ if (ret) ++ goto err_crtc; + } + + /* Ensure AXI pipeline is enabled */ +@@ -1203,13 +1199,15 @@ static int armada_drm_crtc_create(struct drm_device *drm, struct device *dev, + dcrtc->crtc.port = port; + + primary = kzalloc(sizeof(*primary), GFP_KERNEL); +- if (!primary) +- return -ENOMEM; ++ if (!primary) { ++ ret = -ENOMEM; ++ goto err_crtc; ++ } + + ret = armada_drm_plane_init(primary); + if (ret) { + kfree(primary); +- return ret; ++ goto err_crtc; + } + + ret = drm_universal_plane_init(drm, &primary->base, 0, +@@ -1219,7 +1217,7 @@ static int armada_drm_crtc_create(struct drm_device *drm, struct device *dev, + DRM_PLANE_TYPE_PRIMARY); + if (ret) { + kfree(primary); +- return ret; ++ goto err_crtc; + } + + ret = drm_crtc_init_with_planes(drm, &dcrtc->crtc, &primary->base, NULL, +@@ -1238,6 +1236,9 @@ static int armada_drm_crtc_create(struct drm_device *drm, struct device *dev, + + err_crtc_init: + primary->base.funcs->destroy(&primary->base); ++err_crtc: ++ kfree(dcrtc); ++ + return ret; + } + +diff --git a/drivers/gpu/drm/drm_modeset_lock.c b/drivers/gpu/drm/drm_modeset_lock.c +index 6675b1428410..c257de351cfa 100644 +--- a/drivers/gpu/drm/drm_modeset_lock.c ++++ b/drivers/gpu/drm/drm_modeset_lock.c +@@ -69,7 +69,7 @@ void drm_modeset_lock_all(struct drm_device *dev) + struct drm_modeset_acquire_ctx *ctx; + int ret; + +- ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); ++ ctx = kzalloc(sizeof(*ctx), GFP_KERNEL | __GFP_NOFAIL); + if (WARN_ON(!ctx)) + return; + +diff --git a/drivers/gpu/drm/gma500/mdfld_dsi_dpi.c b/drivers/gpu/drm/gma500/mdfld_dsi_dpi.c +index d4813e03f5ee..00275c3856ce 100644 +--- a/drivers/gpu/drm/gma500/mdfld_dsi_dpi.c ++++ b/drivers/gpu/drm/gma500/mdfld_dsi_dpi.c +@@ -821,14 +821,18 @@ void mdfld_dsi_dpi_mode_set(struct drm_encoder *encoder, + struct drm_device *dev = dsi_config->dev; + struct drm_psb_private *dev_priv = dev->dev_private; + int pipe = mdfld_dsi_encoder_get_pipe(dsi_encoder); +- + u32 pipeconf_reg = PIPEACONF; + u32 dspcntr_reg = DSPACNTR; ++ u32 pipeconf, dspcntr; + +- u32 pipeconf = dev_priv->pipeconf[pipe]; +- u32 dspcntr = dev_priv->dspcntr[pipe]; + u32 mipi = MIPI_PORT_EN | PASS_FROM_SPHY_TO_AFE | SEL_FLOPPED_HSTX; + ++ if (WARN_ON(pipe < 0)) ++ return; ++ ++ pipeconf = dev_priv->pipeconf[pipe]; ++ dspcntr = dev_priv->dspcntr[pipe]; ++ + if (pipe) { + pipeconf_reg = PIPECCONF; + dspcntr_reg = DSPCCNTR; +diff --git a/drivers/gpu/drm/gma500/mdfld_dsi_output.c b/drivers/gpu/drm/gma500/mdfld_dsi_output.c +index 89f705c3a5eb..910a2f253990 100644 +--- a/drivers/gpu/drm/gma500/mdfld_dsi_output.c ++++ b/drivers/gpu/drm/gma500/mdfld_dsi_output.c +@@ -382,16 +382,6 @@ static int mdfld_dsi_connector_mode_valid(struct drm_connector *connector, + return MODE_OK; + } + +-static void mdfld_dsi_connector_dpms(struct drm_connector *connector, int mode) +-{ +- if (mode == connector->dpms) +- return; +- +- /*first, execute dpms*/ +- +- drm_helper_connector_dpms(connector, mode); +-} +- + static struct drm_encoder *mdfld_dsi_connector_best_encoder( + struct drm_connector *connector) + { +@@ -404,7 +394,7 @@ static struct drm_encoder *mdfld_dsi_connector_best_encoder( + + /*DSI connector funcs*/ + static const struct drm_connector_funcs mdfld_dsi_connector_funcs = { +- .dpms = /*drm_helper_connector_dpms*/mdfld_dsi_connector_dpms, ++ .dpms = drm_helper_connector_dpms, + .save = mdfld_dsi_connector_save, + .restore = mdfld_dsi_connector_restore, + .detect = mdfld_dsi_connector_detect, +diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c +index a0865c49ec83..495c279da200 100644 +--- a/drivers/gpu/drm/nouveau/nouveau_gem.c ++++ b/drivers/gpu/drm/nouveau/nouveau_gem.c +@@ -370,7 +370,7 @@ validate_init(struct nouveau_channel *chan, struct drm_file *file_priv, + struct nouveau_cli *cli = nouveau_cli(file_priv); + struct drm_device *dev = chan->drm->dev; + int trycnt = 0; +- int ret, i; ++ int ret = -EINVAL, i; + struct nouveau_bo *res_bo = NULL; + LIST_HEAD(gart_list); + LIST_HEAD(vram_list); +diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c +index 67cebb23c940..aa04fb0159a7 100644 +--- a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c ++++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c +@@ -293,13 +293,10 @@ static int vmw_cmdbuf_header_submit(struct vmw_cmdbuf_header *header) + struct vmw_cmdbuf_man *man = header->man; + u32 val; + +- if (sizeof(header->handle) > 4) +- val = (header->handle >> 32); +- else +- val = 0; ++ val = upper_32_bits(header->handle); + vmw_write(man->dev_priv, SVGA_REG_COMMAND_HIGH, val); + +- val = (header->handle & 0xFFFFFFFFULL); ++ val = lower_32_bits(header->handle); + val |= header->cb_context & SVGA_CB_CONTEXT_MASK; + vmw_write(man->dev_priv, SVGA_REG_COMMAND_LOW, val); + +diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c +index d415a804fd26..9a8976a79b29 100644 +--- a/drivers/hv/hv.c ++++ b/drivers/hv/hv.c +@@ -195,9 +195,7 @@ int hv_init(void) + { + int max_leaf; + union hv_x64_msr_hypercall_contents hypercall_msr; +- union hv_x64_msr_hypercall_contents tsc_msr; + void *virtaddr = NULL; +- void *va_tsc = NULL; + + memset(hv_context.synic_event_page, 0, sizeof(void *) * NR_CPUS); + memset(hv_context.synic_message_page, 0, +@@ -243,6 +241,9 @@ int hv_init(void) + + #ifdef CONFIG_X86_64 + if (ms_hyperv.features & HV_X64_MSR_REFERENCE_TSC_AVAILABLE) { ++ union hv_x64_msr_hypercall_contents tsc_msr; ++ void *va_tsc; ++ + va_tsc = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL); + if (!va_tsc) + goto cleanup; +diff --git a/drivers/i2c/i2c-boardinfo.c b/drivers/i2c/i2c-boardinfo.c +index 90e322959303..42c25aed671d 100644 +--- a/drivers/i2c/i2c-boardinfo.c ++++ b/drivers/i2c/i2c-boardinfo.c +@@ -56,9 +56,7 @@ EXPORT_SYMBOL_GPL(__i2c_first_dynamic_bus_num); + * The board info passed can safely be __initdata, but be careful of embedded + * pointers (for platform_data, functions, etc) since that won't be copied. + */ +-int __init +-i2c_register_board_info(int busnum, +- struct i2c_board_info const *info, unsigned len) ++int i2c_register_board_info(int busnum, struct i2c_board_info const *info, unsigned len) + { + int status; + +diff --git a/drivers/idle/Kconfig b/drivers/idle/Kconfig +index 4732dfc15447..331adc509f3a 100644 +--- a/drivers/idle/Kconfig ++++ b/drivers/idle/Kconfig +@@ -17,6 +17,7 @@ config I7300_IDLE_IOAT_CHANNEL + + config I7300_IDLE + tristate "Intel chipset idle memory power saving driver" ++ depends on PCI + select I7300_IDLE_IOAT_CHANNEL + help + Enable memory power savings when idle with certain Intel server +diff --git a/drivers/iio/adc/axp288_adc.c b/drivers/iio/adc/axp288_adc.c +index f684fe31f832..64799ad7ebad 100644 +--- a/drivers/iio/adc/axp288_adc.c ++++ b/drivers/iio/adc/axp288_adc.c +@@ -44,7 +44,7 @@ struct axp288_adc_info { + struct regmap *regmap; + }; + +-static const struct iio_chan_spec const axp288_adc_channels[] = { ++static const struct iio_chan_spec axp288_adc_channels[] = { + { + .indexed = 1, + .type = IIO_TEMP, +diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c +index e354358db77b..b6c9a370a38b 100644 +--- a/drivers/infiniband/core/cma.c ++++ b/drivers/infiniband/core/cma.c +@@ -626,6 +626,7 @@ struct rdma_cm_id *rdma_create_id(struct net *net, + INIT_LIST_HEAD(&id_priv->mc_list); + get_random_bytes(&id_priv->seq_num, sizeof id_priv->seq_num); + id_priv->id.route.addr.dev_addr.net = get_net(net); ++ id_priv->seq_num &= 0x00ffffff; + + return &id_priv->id; + } +diff --git a/drivers/infiniband/hw/cxgb4/device.c b/drivers/infiniband/hw/cxgb4/device.c +index 58fce1742b8d..337b1a5eb41c 100644 +--- a/drivers/infiniband/hw/cxgb4/device.c ++++ b/drivers/infiniband/hw/cxgb4/device.c +@@ -809,10 +809,9 @@ static int c4iw_rdev_open(struct c4iw_rdev *rdev) + rdev->lldi.vr->qp.size, + rdev->lldi.vr->cq.start, + rdev->lldi.vr->cq.size); +- PDBG("udb len 0x%x udb base %p db_reg %p gts_reg %p " ++ PDBG("udb %pR db_reg %p gts_reg %p " + "qpmask 0x%x cqmask 0x%x\n", +- (unsigned)pci_resource_len(rdev->lldi.pdev, 2), +- (void *)pci_resource_start(rdev->lldi.pdev, 2), ++ &rdev->lldi.pdev->resource[2], + rdev->lldi.db_reg, rdev->lldi.gts_reg, + rdev->qpmask, rdev->cqmask); + +diff --git a/drivers/input/keyboard/tca8418_keypad.c b/drivers/input/keyboard/tca8418_keypad.c +index 9002298698fc..3048ef3e3e16 100644 +--- a/drivers/input/keyboard/tca8418_keypad.c ++++ b/drivers/input/keyboard/tca8418_keypad.c +@@ -164,11 +164,18 @@ static void tca8418_read_keypad(struct tca8418_keypad *keypad_data) + int error, col, row; + u8 reg, state, code; + +- /* Initial read of the key event FIFO */ +- error = tca8418_read_byte(keypad_data, REG_KEY_EVENT_A, ®); ++ do { ++ error = tca8418_read_byte(keypad_data, REG_KEY_EVENT_A, ®); ++ if (error < 0) { ++ dev_err(&keypad_data->client->dev, ++ "unable to read REG_KEY_EVENT_A\n"); ++ break; ++ } ++ ++ /* Assume that key code 0 signifies empty FIFO */ ++ if (reg <= 0) ++ break; + +- /* Assume that key code 0 signifies empty FIFO */ +- while (error >= 0 && reg > 0) { + state = reg & KEY_EVENT_VALUE; + code = reg & KEY_EVENT_CODE; + +@@ -184,11 +191,7 @@ static void tca8418_read_keypad(struct tca8418_keypad *keypad_data) + + /* Read for next loop */ + error = tca8418_read_byte(keypad_data, REG_KEY_EVENT_A, ®); +- } +- +- if (error < 0) +- dev_err(&keypad_data->client->dev, +- "unable to read REG_KEY_EVENT_A\n"); ++ } while (1); + + input_sync(input); + } +diff --git a/drivers/isdn/hardware/eicon/message.c b/drivers/isdn/hardware/eicon/message.c +index 7b4ddf0a39ec..2d28530b7e82 100644 +--- a/drivers/isdn/hardware/eicon/message.c ++++ b/drivers/isdn/hardware/eicon/message.c +@@ -147,7 +147,7 @@ static word plci_remove_check(PLCI *); + static void listen_check(DIVA_CAPI_ADAPTER *); + static byte AddInfo(byte **, byte **, byte *, byte *); + static byte getChannel(API_PARSE *); +-static void IndParse(PLCI *, word *, byte **, byte); ++static void IndParse(PLCI *, const word *, byte **, byte); + static byte ie_compare(byte *, byte *); + static word find_cip(DIVA_CAPI_ADAPTER *, byte *, byte *); + static word CPN_filter_ok(byte *cpn, DIVA_CAPI_ADAPTER *, word); +@@ -4860,7 +4860,7 @@ static void sig_ind(PLCI *plci) + /* included before the ESC_MSGTYPE and MAXPARMSIDS has to be incremented */ + /* SMSG is situated at the end because its 0 (for compatibility reasons */ + /* (see Info_Mask Bit 4, first IE. then the message type) */ +- word parms_id[] = ++ static const word parms_id[] = + {MAXPARMSIDS, CPN, 0xff, DSA, OSA, BC, LLC, HLC, ESC_CAUSE, DSP, DT, CHA, + UUI, CONG_RR, CONG_RNR, ESC_CHI, KEY, CHI, CAU, ESC_LAW, + RDN, RDX, CONN_NR, RIN, NI, CAI, ESC_CR, +@@ -4868,12 +4868,12 @@ static void sig_ind(PLCI *plci) + /* 14 FTY repl by ESC_CHI */ + /* 18 PI repl by ESC_LAW */ + /* removed OAD changed to 0xff for future use, OAD is multiIE now */ +- word multi_fac_id[] = {1, FTY}; +- word multi_pi_id[] = {1, PI}; +- word multi_CiPN_id[] = {1, OAD}; +- word multi_ssext_id[] = {1, ESC_SSEXT}; ++ static const word multi_fac_id[] = {1, FTY}; ++ static const word multi_pi_id[] = {1, PI}; ++ static const word multi_CiPN_id[] = {1, OAD}; ++ static const word multi_ssext_id[] = {1, ESC_SSEXT}; + +- word multi_vswitch_id[] = {1, ESC_VSWITCH}; ++ static const word multi_vswitch_id[] = {1, ESC_VSWITCH}; + + byte *cau; + word ncci; +@@ -8926,7 +8926,7 @@ static void listen_check(DIVA_CAPI_ADAPTER *a) + /* functions for all parameters sent in INDs */ + /*------------------------------------------------------------------*/ + +-static void IndParse(PLCI *plci, word *parms_id, byte **parms, byte multiIEsize) ++static void IndParse(PLCI *plci, const word *parms_id, byte **parms, byte multiIEsize) + { + word ploc; /* points to current location within packet */ + byte w; +diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c +index 358a574d9e8b..46d957c34be1 100644 +--- a/drivers/isdn/icn/icn.c ++++ b/drivers/isdn/icn/icn.c +@@ -718,7 +718,7 @@ icn_sendbuf(int channel, int ack, struct sk_buff *skb, icn_card *card) + return 0; + if (card->sndcount[channel] > ICN_MAX_SQUEUE) + return 0; +-#warning TODO test headroom or use skb->nb to flag ACK ++ /* TODO test headroom or use skb->nb to flag ACK */ + nskb = skb_clone(skb, GFP_ATOMIC); + if (nskb) { + /* Push ACK flag as one +diff --git a/drivers/isdn/sc/init.c b/drivers/isdn/sc/init.c +index 3597ef47b28a..09fc129ef2fa 100644 +--- a/drivers/isdn/sc/init.c ++++ b/drivers/isdn/sc/init.c +@@ -441,6 +441,7 @@ static int identify_board(unsigned long rambase, unsigned int iobase) + RspMessage rcvmsg; + ReqMessage sndmsg; + HWConfig_pl hwci; ++ void __iomem *rambase_sig = (void __iomem *)rambase + SIG_OFFSET; + int x; + + pr_debug("Attempting to identify adapter @ 0x%lx io 0x%x\n", +@@ -481,7 +482,7 @@ static int identify_board(unsigned long rambase, unsigned int iobase) + */ + outb(PRI_BASEPG_VAL, pgport); + msleep_interruptible(1000); +- sig = readl(rambase + SIG_OFFSET); ++ sig = readl(rambase_sig); + pr_debug("Looking for a signature, got 0x%lx\n", sig); + if (sig == SIGNATURE) + return PRI_BOARD; +@@ -491,7 +492,7 @@ static int identify_board(unsigned long rambase, unsigned int iobase) + */ + outb(BRI_BASEPG_VAL, pgport); + msleep_interruptible(1000); +- sig = readl(rambase + SIG_OFFSET); ++ sig = readl(rambase_sig); + pr_debug("Looking for a signature, got 0x%lx\n", sig); + if (sig == SIGNATURE) + return BRI_BOARD; +@@ -501,7 +502,7 @@ static int identify_board(unsigned long rambase, unsigned int iobase) + /* + * Try to spot a card + */ +- sig = readl(rambase + SIG_OFFSET); ++ sig = readl(rambase_sig); + pr_debug("Looking for a signature, got 0x%lx\n", sig); + if (sig != SIGNATURE) + return -1; +diff --git a/drivers/md/md.c b/drivers/md/md.c +index 0a856cb181e9..62c3328e2a1d 100644 +--- a/drivers/md/md.c ++++ b/drivers/md/md.c +@@ -1028,8 +1028,9 @@ static int super_90_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor + * (not needed for Linear and RAID0 as metadata doesn't + * record this size) + */ +- if (rdev->sectors >= (2ULL << 32) && sb->level >= 1) +- rdev->sectors = (2ULL << 32) - 2; ++ if (IS_ENABLED(CONFIG_LBDAF) && (u64)rdev->sectors >= (2ULL << 32) && ++ sb->level >= 1) ++ rdev->sectors = (sector_t)(2ULL << 32) - 2; + + if (rdev->sectors < ((sector_t)sb->size) * 2 && sb->level >= 1) + /* "this cannot possibly happen" ... */ +@@ -1322,8 +1323,9 @@ super_90_rdev_size_change(struct md_rdev *rdev, sector_t num_sectors) + /* Limit to 4TB as metadata cannot record more than that. + * 4TB == 2^32 KB, or 2*2^32 sectors. + */ +- if (num_sectors >= (2ULL << 32) && rdev->mddev->level >= 1) +- num_sectors = (2ULL << 32) - 2; ++ if (IS_ENABLED(CONFIG_LBDAF) && (u64)num_sectors >= (2ULL << 32) && ++ rdev->mddev->level >= 1) ++ num_sectors = (sector_t)(2ULL << 32) - 2; + md_super_write(rdev->mddev, rdev, rdev->sb_start, rdev->sb_size, + rdev->sb_page); + md_super_wait(rdev->mddev); +diff --git a/drivers/media/common/b2c2/flexcop-fe-tuner.c b/drivers/media/common/b2c2/flexcop-fe-tuner.c +index 9c59f4306883..f5956402fc69 100644 +--- a/drivers/media/common/b2c2/flexcop-fe-tuner.c ++++ b/drivers/media/common/b2c2/flexcop-fe-tuner.c +@@ -38,7 +38,7 @@ static int flexcop_fe_request_firmware(struct dvb_frontend *fe, + #endif + + /* lnb control */ +-#if FE_SUPPORTED(MT312) || FE_SUPPORTED(STV0299) ++#if (FE_SUPPORTED(MT312) || FE_SUPPORTED(STV0299)) && FE_SUPPORTED(PLL) + static int flexcop_set_voltage(struct dvb_frontend *fe, + enum fe_sec_voltage voltage) + { +@@ -68,7 +68,7 @@ static int flexcop_set_voltage(struct dvb_frontend *fe, + #endif + + #if FE_SUPPORTED(S5H1420) || FE_SUPPORTED(STV0299) || FE_SUPPORTED(MT312) +-static int flexcop_sleep(struct dvb_frontend* fe) ++static int __maybe_unused flexcop_sleep(struct dvb_frontend* fe) + { + struct flexcop_device *fc = fe->dvb->priv; + if (fc->fe_sleep) +diff --git a/drivers/media/i2c/s5k6aa.c b/drivers/media/i2c/s5k6aa.c +index d0ad6a25bdab..5ac2babe123b 100644 +--- a/drivers/media/i2c/s5k6aa.c ++++ b/drivers/media/i2c/s5k6aa.c +@@ -421,6 +421,7 @@ static int s5k6aa_set_ahb_address(struct i2c_client *client) + + /** + * s5k6aa_configure_pixel_clock - apply ISP main clock/PLL configuration ++ * @s5k6aa: pointer to &struct s5k6aa describing the device + * + * Configure the internal ISP PLL for the required output frequency. + * Locking: called with s5k6aa.lock mutex held. +@@ -669,6 +670,7 @@ static int s5k6aa_set_input_params(struct s5k6aa *s5k6aa) + + /** + * s5k6aa_configure_video_bus - configure the video output interface ++ * @s5k6aa: pointer to &struct s5k6aa describing the device + * @bus_type: video bus type: parallel or MIPI-CSI + * @nlanes: number of MIPI lanes to be used (MIPI-CSI only) + * +@@ -724,6 +726,8 @@ static int s5k6aa_new_config_sync(struct i2c_client *client, int timeout, + + /** + * s5k6aa_set_prev_config - write user preview register set ++ * @s5k6aa: pointer to &struct s5k6aa describing the device ++ * @preset: s5kaa preset to be applied + * + * Configure output resolution and color fromat, pixel clock + * frequency range, device frame rate type and frame period range. +@@ -777,6 +781,7 @@ static int s5k6aa_set_prev_config(struct s5k6aa *s5k6aa, + + /** + * s5k6aa_initialize_isp - basic ISP MCU initialization ++ * @sd: pointer to V4L2 sub-device descriptor + * + * Configure AHB addresses for registers read/write; configure PLLs for + * required output pixel clock. The ISP power supply needs to be already +diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c +index 9ef5baaf8646..ea2777e1ee10 100644 +--- a/drivers/media/i2c/tc358743.c ++++ b/drivers/media/i2c/tc358743.c +@@ -197,57 +197,61 @@ static void i2c_wr(struct v4l2_subdev *sd, u16 reg, u8 *values, u32 n) + } + } + +-static u8 i2c_rd8(struct v4l2_subdev *sd, u16 reg) ++static noinline u32 i2c_rdreg(struct v4l2_subdev *sd, u16 reg, u32 n) + { +- u8 val; ++ __le32 val = 0; + +- i2c_rd(sd, reg, &val, 1); ++ i2c_rd(sd, reg, (u8 __force *)&val, n); + +- return val; ++ return le32_to_cpu(val); ++} ++ ++static noinline void i2c_wrreg(struct v4l2_subdev *sd, u16 reg, u32 val, u32 n) ++{ ++ __le32 raw = cpu_to_le32(val); ++ ++ i2c_wr(sd, reg, (u8 __force *)&raw, n); ++} ++ ++static u8 i2c_rd8(struct v4l2_subdev *sd, u16 reg) ++{ ++ return i2c_rdreg(sd, reg, 1); + } + + static void i2c_wr8(struct v4l2_subdev *sd, u16 reg, u8 val) + { +- i2c_wr(sd, reg, &val, 1); ++ i2c_wrreg(sd, reg, val, 1); + } + + static void i2c_wr8_and_or(struct v4l2_subdev *sd, u16 reg, + u8 mask, u8 val) + { +- i2c_wr8(sd, reg, (i2c_rd8(sd, reg) & mask) | val); ++ i2c_wrreg(sd, reg, (i2c_rdreg(sd, reg, 2) & mask) | val, 2); + } + + static u16 i2c_rd16(struct v4l2_subdev *sd, u16 reg) + { +- u16 val; +- +- i2c_rd(sd, reg, (u8 *)&val, 2); +- +- return val; ++ return i2c_rdreg(sd, reg, 2); + } + + static void i2c_wr16(struct v4l2_subdev *sd, u16 reg, u16 val) + { +- i2c_wr(sd, reg, (u8 *)&val, 2); ++ i2c_wrreg(sd, reg, val, 2); + } + + static void i2c_wr16_and_or(struct v4l2_subdev *sd, u16 reg, u16 mask, u16 val) + { +- i2c_wr16(sd, reg, (i2c_rd16(sd, reg) & mask) | val); ++ i2c_wrreg(sd, reg, (i2c_rdreg(sd, reg, 2) & mask) | val, 2); + } + + static u32 i2c_rd32(struct v4l2_subdev *sd, u16 reg) + { +- u32 val; +- +- i2c_rd(sd, reg, (u8 *)&val, 4); +- +- return val; ++ return i2c_rdreg(sd, reg, 4); + } + + static void i2c_wr32(struct v4l2_subdev *sd, u16 reg, u32 val) + { +- i2c_wr(sd, reg, (u8 *)&val, 4); ++ i2c_wrreg(sd, reg, val, 4); + } + + /* --------------- STATUS --------------- */ +@@ -1240,7 +1244,7 @@ static int tc358743_g_register(struct v4l2_subdev *sd, + + reg->size = tc358743_get_reg_size(reg->reg); + +- i2c_rd(sd, reg->reg, (u8 *)®->val, reg->size); ++ reg->val = i2c_rdreg(sd, reg->reg, reg->size); + + return 0; + } +@@ -1266,7 +1270,7 @@ static int tc358743_s_register(struct v4l2_subdev *sd, + reg->reg == BCAPS) + return 0; + +- i2c_wr(sd, (u16)reg->reg, (u8 *)®->val, ++ i2c_wrreg(sd, (u16)reg->reg, reg->val, + tc358743_get_reg_size(reg->reg)); + + return 0; +diff --git a/drivers/media/usb/em28xx/Kconfig b/drivers/media/usb/em28xx/Kconfig +index e382210c4ada..75323f5efd0f 100644 +--- a/drivers/media/usb/em28xx/Kconfig ++++ b/drivers/media/usb/em28xx/Kconfig +@@ -11,7 +11,7 @@ config VIDEO_EM28XX_V4L2 + select VIDEO_SAA711X if MEDIA_SUBDRV_AUTOSELECT + select VIDEO_TVP5150 if MEDIA_SUBDRV_AUTOSELECT + select VIDEO_MSP3400 if MEDIA_SUBDRV_AUTOSELECT +- select VIDEO_MT9V011 if MEDIA_SUBDRV_AUTOSELECT ++ select VIDEO_MT9V011 if MEDIA_SUBDRV_AUTOSELECT && MEDIA_CAMERA_SUPPORT + + ---help--- + This is a video4linux driver for Empia 28xx based TV cards. +diff --git a/drivers/media/usb/go7007/Kconfig b/drivers/media/usb/go7007/Kconfig +index 95a3af644a92..af1d02430931 100644 +--- a/drivers/media/usb/go7007/Kconfig ++++ b/drivers/media/usb/go7007/Kconfig +@@ -11,7 +11,7 @@ config VIDEO_GO7007 + select VIDEO_TW2804 if MEDIA_SUBDRV_AUTOSELECT + select VIDEO_TW9903 if MEDIA_SUBDRV_AUTOSELECT + select VIDEO_TW9906 if MEDIA_SUBDRV_AUTOSELECT +- select VIDEO_OV7640 if MEDIA_SUBDRV_AUTOSELECT ++ select VIDEO_OV7640 if MEDIA_SUBDRV_AUTOSELECT && MEDIA_CAMERA_SUPPORT + select VIDEO_UDA1342 if MEDIA_SUBDRV_AUTOSELECT + ---help--- + This is a video4linux driver for the WIS GO7007 MPEG +diff --git a/drivers/media/usb/hdpvr/hdpvr-core.c b/drivers/media/usb/hdpvr/hdpvr-core.c +index 3fc64197b4e6..08f0ca7aa012 100644 +--- a/drivers/media/usb/hdpvr/hdpvr-core.c ++++ b/drivers/media/usb/hdpvr/hdpvr-core.c +@@ -273,7 +273,9 @@ static int hdpvr_probe(struct usb_interface *interface, + struct hdpvr_device *dev; + struct usb_host_interface *iface_desc; + struct usb_endpoint_descriptor *endpoint; ++#if IS_ENABLED(CONFIG_I2C) + struct i2c_client *client; ++#endif + size_t buffer_size; + int i; + int retval = -ENOMEM; +diff --git a/drivers/media/usb/pwc/pwc-if.c b/drivers/media/usb/pwc/pwc-if.c +index 58f23bcfe94e..299750e56916 100644 +--- a/drivers/media/usb/pwc/pwc-if.c ++++ b/drivers/media/usb/pwc/pwc-if.c +@@ -1119,8 +1119,10 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id + + return 0; + ++#ifdef CONFIG_USB_PWC_INPUT_EVDEV + err_video_unreg: + video_unregister_device(&pdev->vdev); ++#endif + err_unregister_v4l2_dev: + v4l2_device_unregister(&pdev->v4l2_dev); + err_free_controls: +diff --git a/drivers/media/v4l2-core/Kconfig b/drivers/media/v4l2-core/Kconfig +index 9beece00869b..29b3436d0910 100644 +--- a/drivers/media/v4l2-core/Kconfig ++++ b/drivers/media/v4l2-core/Kconfig +@@ -37,7 +37,6 @@ config VIDEO_PCI_SKELETON + # Used by drivers that need tuner.ko + config VIDEO_TUNER + tristate +- depends on MEDIA_TUNER + + # Used by drivers that need v4l2-mem2mem.ko + config V4L2_MEM2MEM_DEV +diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c +index 5dcc0313c38a..207370d68c17 100644 +--- a/drivers/message/fusion/mptbase.c ++++ b/drivers/message/fusion/mptbase.c +@@ -6848,6 +6848,7 @@ mpt_print_ioc_summary(MPT_ADAPTER *ioc, char *buffer, int *size, int len, int sh + *size = y; + } + ++#ifdef CONFIG_PROC_FS + static void seq_mpt_print_ioc_summary(MPT_ADAPTER *ioc, struct seq_file *m, int showlan) + { + char expVer[32]; +@@ -6879,6 +6880,7 @@ static void seq_mpt_print_ioc_summary(MPT_ADAPTER *ioc, struct seq_file *m, int + + seq_putc(m, '\n'); + } ++#endif + + /** + * mpt_set_taskmgmt_in_progress_flag - set flags associated with task management +diff --git a/drivers/mtd/chips/Kconfig b/drivers/mtd/chips/Kconfig +index 8a25adced79f..bbfa1f129266 100644 +--- a/drivers/mtd/chips/Kconfig ++++ b/drivers/mtd/chips/Kconfig +@@ -67,6 +67,10 @@ endchoice + config MTD_CFI_GEOMETRY + bool "Specific CFI Flash geometry selection" + depends on MTD_CFI_ADV_OPTIONS ++ select MTD_MAP_BANK_WIDTH_1 if !(MTD_MAP_BANK_WIDTH_2 || \ ++ MTD_MAP_BANK_WIDTH_4 || MTD_MAP_BANK_WIDTH_8 || \ ++ MTD_MAP_BANK_WIDTH_16 || MTD_MAP_BANK_WIDTH_32) ++ select MTD_CFI_I1 if !(MTD_CFI_I2 || MTD_CFI_I4 || MTD_CFI_I8) + help + This option does not affect the code directly, but will enable + some other configuration options which would allow you to reduce +diff --git a/drivers/mtd/maps/ck804xrom.c b/drivers/mtd/maps/ck804xrom.c +index 0455166f05fa..4f206a99164c 100644 +--- a/drivers/mtd/maps/ck804xrom.c ++++ b/drivers/mtd/maps/ck804xrom.c +@@ -112,8 +112,8 @@ static void ck804xrom_cleanup(struct ck804xrom_window *window) + } + + +-static int ck804xrom_init_one(struct pci_dev *pdev, +- const struct pci_device_id *ent) ++static int __init ck804xrom_init_one(struct pci_dev *pdev, ++ const struct pci_device_id *ent) + { + static char *rom_probe_types[] = { "cfi_probe", "jedec_probe", NULL }; + u8 byte; +diff --git a/drivers/mtd/maps/esb2rom.c b/drivers/mtd/maps/esb2rom.c +index 76ed651b515b..9646b0766ce0 100644 +--- a/drivers/mtd/maps/esb2rom.c ++++ b/drivers/mtd/maps/esb2rom.c +@@ -144,8 +144,8 @@ static void esb2rom_cleanup(struct esb2rom_window *window) + pci_dev_put(window->pdev); + } + +-static int esb2rom_init_one(struct pci_dev *pdev, +- const struct pci_device_id *ent) ++static int __init esb2rom_init_one(struct pci_dev *pdev, ++ const struct pci_device_id *ent) + { + static char *rom_probe_types[] = { "cfi_probe", "jedec_probe", NULL }; + struct esb2rom_window *window = &esb2rom_window; +diff --git a/drivers/mtd/maps/ichxrom.c b/drivers/mtd/maps/ichxrom.c +index 8636bba42200..976d42f63aef 100644 +--- a/drivers/mtd/maps/ichxrom.c ++++ b/drivers/mtd/maps/ichxrom.c +@@ -57,10 +57,12 @@ static void ichxrom_cleanup(struct ichxrom_window *window) + { + struct ichxrom_map_info *map, *scratch; + u16 word; ++ int ret; + + /* Disable writes through the rom window */ +- pci_read_config_word(window->pdev, BIOS_CNTL, &word); +- pci_write_config_word(window->pdev, BIOS_CNTL, word & ~1); ++ ret = pci_read_config_word(window->pdev, BIOS_CNTL, &word); ++ if (!ret) ++ pci_write_config_word(window->pdev, BIOS_CNTL, word & ~1); + pci_dev_put(window->pdev); + + /* Free all of the mtd devices */ +@@ -84,8 +86,8 @@ static void ichxrom_cleanup(struct ichxrom_window *window) + } + + +-static int ichxrom_init_one(struct pci_dev *pdev, +- const struct pci_device_id *ent) ++static int __init ichxrom_init_one(struct pci_dev *pdev, ++ const struct pci_device_id *ent) + { + static char *rom_probe_types[] = { "cfi_probe", "jedec_probe", NULL }; + struct ichxrom_window *window = &ichxrom_window; +diff --git a/drivers/mtd/nand/sh_flctl.c b/drivers/mtd/nand/sh_flctl.c +index bcba1a924c75..1f2785ee909f 100644 +--- a/drivers/mtd/nand/sh_flctl.c ++++ b/drivers/mtd/nand/sh_flctl.c +@@ -160,7 +160,7 @@ static void flctl_setup_dma(struct sh_flctl *flctl) + + memset(&cfg, 0, sizeof(cfg)); + cfg.direction = DMA_MEM_TO_DEV; +- cfg.dst_addr = (dma_addr_t)FLDTFIFO(flctl); ++ cfg.dst_addr = flctl->fifo; + cfg.src_addr = 0; + ret = dmaengine_slave_config(flctl->chan_fifo0_tx, &cfg); + if (ret < 0) +@@ -176,7 +176,7 @@ static void flctl_setup_dma(struct sh_flctl *flctl) + + cfg.direction = DMA_DEV_TO_MEM; + cfg.dst_addr = 0; +- cfg.src_addr = (dma_addr_t)FLDTFIFO(flctl); ++ cfg.src_addr = flctl->fifo; + ret = dmaengine_slave_config(flctl->chan_fifo0_rx, &cfg); + if (ret < 0) + goto err; +@@ -1096,6 +1096,7 @@ static int flctl_probe(struct platform_device *pdev) + flctl->reg = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(flctl->reg)) + return PTR_ERR(flctl->reg); ++ flctl->fifo = res->start + 0x24; /* FLDTFIFO */ + + irq = platform_get_irq(pdev, 0); + if (irq < 0) { +diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig +index f184fb5bd110..5116aec3c174 100644 +--- a/drivers/net/Kconfig ++++ b/drivers/net/Kconfig +@@ -411,6 +411,9 @@ config XEN_NETDEV_BACKEND + config VMXNET3 + tristate "VMware VMXNET3 ethernet driver" + depends on PCI && INET ++ depends on !(PAGE_SIZE_64KB || ARM64_64K_PAGES || \ ++ IA64_PAGE_SIZE_64KB || MICROBLAZE_64K_PAGES || \ ++ PARISC_PAGE_SIZE_64KB || PPC_64K_PAGES) + help + This driver supports VMware's vmxnet3 virtual ethernet NIC. + To compile this driver as a module, choose M here: the +diff --git a/drivers/net/ethernet/3com/3c509.c b/drivers/net/ethernet/3com/3c509.c +index 4547a1b8b958..7677c745fb30 100644 +--- a/drivers/net/ethernet/3com/3c509.c ++++ b/drivers/net/ethernet/3com/3c509.c +@@ -562,7 +562,7 @@ static void el3_common_remove (struct net_device *dev) + } + + #ifdef CONFIG_EISA +-static int __init el3_eisa_probe (struct device *device) ++static int el3_eisa_probe(struct device *device) + { + short i; + int ioaddr, irq, if_port; +diff --git a/drivers/net/ethernet/3com/3c59x.c b/drivers/net/ethernet/3com/3c59x.c +index 2839af00f20c..1c5f3b273e6a 100644 +--- a/drivers/net/ethernet/3com/3c59x.c ++++ b/drivers/net/ethernet/3com/3c59x.c +@@ -907,7 +907,7 @@ static struct eisa_device_id vortex_eisa_ids[] = { + }; + MODULE_DEVICE_TABLE(eisa, vortex_eisa_ids); + +-static int __init vortex_eisa_probe(struct device *device) ++static int vortex_eisa_probe(struct device *device) + { + void __iomem *ioaddr; + struct eisa_device *edev; +diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-main.c b/drivers/net/ethernet/amd/xgbe/xgbe-main.c +index 618d952c2984..2ef4b4e884ae 100644 +--- a/drivers/net/ethernet/amd/xgbe/xgbe-main.c ++++ b/drivers/net/ethernet/amd/xgbe/xgbe-main.c +@@ -829,7 +829,7 @@ static int xgbe_remove(struct platform_device *pdev) + return 0; + } + +-#ifdef CONFIG_PM ++#ifdef CONFIG_PM_SLEEP + static int xgbe_suspend(struct device *dev) + { + struct net_device *netdev = dev_get_drvdata(dev); +@@ -868,7 +868,7 @@ static int xgbe_resume(struct device *dev) + + return ret; + } +-#endif /* CONFIG_PM */ ++#endif /* CONFIG_PM_SLEEP */ + + #ifdef CONFIG_ACPI + static const struct acpi_device_id xgbe_acpi_match[] = { +diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c +index 8966f3159bb2..3acde3b9b767 100644 +--- a/drivers/net/ethernet/dec/tulip/de4x5.c ++++ b/drivers/net/ethernet/dec/tulip/de4x5.c +@@ -1990,7 +1990,7 @@ SetMulticastFilter(struct net_device *dev) + + static u_char de4x5_irq[] = EISA_ALLOWED_IRQ_LIST; + +-static int __init de4x5_eisa_probe (struct device *gendev) ++static int de4x5_eisa_probe(struct device *gendev) + { + struct eisa_device *edev; + u_long iobase; +diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c +index 7923bfdc9b30..901661149b44 100644 +--- a/drivers/net/ethernet/freescale/gianfar.c ++++ b/drivers/net/ethernet/freescale/gianfar.c +@@ -1375,9 +1375,11 @@ static int gfar_probe(struct platform_device *ofdev) + + gfar_init_addr_hash_table(priv); + +- /* Insert receive time stamps into padding alignment bytes */ ++ /* Insert receive time stamps into padding alignment bytes, and ++ * plus 2 bytes padding to ensure the cpu alignment. ++ */ + if (priv->device_flags & FSL_GIANFAR_DEV_HAS_TIMER) +- priv->padding = 8; ++ priv->padding = 8 + DEFAULT_PADDING; + + if (dev->features & NETIF_F_IP_CSUM || + priv->device_flags & FSL_GIANFAR_DEV_HAS_TIMER) +diff --git a/drivers/net/ethernet/hp/hp100.c b/drivers/net/ethernet/hp/hp100.c +index ae6e30d39f0f..3daf2d4a7ca0 100644 +--- a/drivers/net/ethernet/hp/hp100.c ++++ b/drivers/net/ethernet/hp/hp100.c +@@ -194,7 +194,6 @@ static const char *hp100_isa_tbl[] = { + }; + #endif + +-#ifdef CONFIG_EISA + static struct eisa_device_id hp100_eisa_tbl[] = { + { "HWPF180" }, /* HP J2577 rev A */ + { "HWP1920" }, /* HP 27248B */ +@@ -205,9 +204,7 @@ static struct eisa_device_id hp100_eisa_tbl[] = { + { "" } /* Mandatory final entry ! */ + }; + MODULE_DEVICE_TABLE(eisa, hp100_eisa_tbl); +-#endif + +-#ifdef CONFIG_PCI + static const struct pci_device_id hp100_pci_tbl[] = { + {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_J2585A, PCI_ANY_ID, PCI_ANY_ID,}, + {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_J2585B, PCI_ANY_ID, PCI_ANY_ID,}, +@@ -219,7 +216,6 @@ static const struct pci_device_id hp100_pci_tbl[] = { + {} /* Terminating entry */ + }; + MODULE_DEVICE_TABLE(pci, hp100_pci_tbl); +-#endif + + static int hp100_rx_ratio = HP100_DEFAULT_RX_RATIO; + static int hp100_priority_tx = HP100_DEFAULT_PRIORITY_TX; +@@ -2842,8 +2838,7 @@ static void cleanup_dev(struct net_device *d) + free_netdev(d); + } + +-#ifdef CONFIG_EISA +-static int __init hp100_eisa_probe (struct device *gendev) ++static int hp100_eisa_probe(struct device *gendev) + { + struct net_device *dev = alloc_etherdev(sizeof(struct hp100_private)); + struct eisa_device *edev = to_eisa_device(gendev); +@@ -2884,9 +2879,7 @@ static struct eisa_driver hp100_eisa_driver = { + .remove = hp100_eisa_remove, + } + }; +-#endif + +-#ifdef CONFIG_PCI + static int hp100_pci_probe(struct pci_dev *pdev, + const struct pci_device_id *ent) + { +@@ -2955,7 +2948,6 @@ static struct pci_driver hp100_pci_driver = { + .probe = hp100_pci_probe, + .remove = hp100_pci_remove, + }; +-#endif + + /* + * module section +@@ -3032,23 +3024,17 @@ static int __init hp100_module_init(void) + err = hp100_isa_init(); + if (err && err != -ENODEV) + goto out; +-#ifdef CONFIG_EISA + err = eisa_driver_register(&hp100_eisa_driver); + if (err && err != -ENODEV) + goto out2; +-#endif +-#ifdef CONFIG_PCI + err = pci_register_driver(&hp100_pci_driver); + if (err && err != -ENODEV) + goto out3; +-#endif + out: + return err; + out3: +-#ifdef CONFIG_EISA + eisa_driver_unregister (&hp100_eisa_driver); + out2: +-#endif + hp100_isa_cleanup(); + goto out; + } +@@ -3057,12 +3043,8 @@ static int __init hp100_module_init(void) + static void __exit hp100_module_exit(void) + { + hp100_isa_cleanup(); +-#ifdef CONFIG_EISA + eisa_driver_unregister (&hp100_eisa_driver); +-#endif +-#ifdef CONFIG_PCI + pci_unregister_driver (&hp100_pci_driver); +-#endif + } + + module_init(hp100_module_init) +diff --git a/drivers/net/ethernet/ti/tlan.c b/drivers/net/ethernet/ti/tlan.c +index a274cd49afe9..399a89f30826 100644 +--- a/drivers/net/ethernet/ti/tlan.c ++++ b/drivers/net/ethernet/ti/tlan.c +@@ -610,8 +610,8 @@ err_out_regions: + #ifdef CONFIG_PCI + if (pdev) + pci_release_regions(pdev); +-#endif + err_out: ++#endif + if (pdev) + pci_disable_device(pdev); + return rc; +diff --git a/drivers/net/hippi/rrunner.c b/drivers/net/hippi/rrunner.c +index 95c0b45a68fb..313e006f74fe 100644 +--- a/drivers/net/hippi/rrunner.c ++++ b/drivers/net/hippi/rrunner.c +@@ -1381,8 +1381,8 @@ static int rr_close(struct net_device *dev) + rrpriv->info_dma); + rrpriv->info = NULL; + +- free_irq(pdev->irq, dev); + spin_unlock_irqrestore(&rrpriv->lock, flags); ++ free_irq(pdev->irq, dev); + + return 0; + } +diff --git a/drivers/net/ipvlan/ipvlan_core.c b/drivers/net/ipvlan/ipvlan_core.c +index af827faec7fe..8aecea0d5dbf 100644 +--- a/drivers/net/ipvlan/ipvlan_core.c ++++ b/drivers/net/ipvlan/ipvlan_core.c +@@ -353,6 +353,7 @@ static int ipvlan_process_v4_outbound(struct sk_buff *skb) + .flowi4_oif = dev->ifindex, + .flowi4_tos = RT_TOS(ip4h->tos), + .flowi4_flags = FLOWI_FLAG_ANYSRC, ++ .flowi4_mark = skb->mark, + .daddr = ip4h->daddr, + .saddr = ip4h->saddr, + }; +diff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig +index 1f6893ebce16..3a7286256db0 100644 +--- a/drivers/net/usb/Kconfig ++++ b/drivers/net/usb/Kconfig +@@ -395,6 +395,10 @@ config USB_NET_RNDIS_HOST + The protocol specification is incomplete, and is controlled by + (and for) Microsoft; it isn't an "Open" ecosystem or market. + ++config USB_NET_CDC_SUBSET_ENABLE ++ tristate ++ depends on USB_NET_CDC_SUBSET ++ + config USB_NET_CDC_SUBSET + tristate "Simple USB Network Links (CDC Ethernet subset)" + depends on USB_USBNET +@@ -413,6 +417,7 @@ config USB_NET_CDC_SUBSET + config USB_ALI_M5632 + bool "ALi M5632 based 'USB 2.0 Data Link' cables" + depends on USB_NET_CDC_SUBSET ++ select USB_NET_CDC_SUBSET_ENABLE + help + Choose this option if you're using a host-to-host cable + based on this design, which supports USB 2.0 high speed. +@@ -420,6 +425,7 @@ config USB_ALI_M5632 + config USB_AN2720 + bool "AnchorChips 2720 based cables (Xircom PGUNET, ...)" + depends on USB_NET_CDC_SUBSET ++ select USB_NET_CDC_SUBSET_ENABLE + help + Choose this option if you're using a host-to-host cable + based on this design. Note that AnchorChips is now a +@@ -428,6 +434,7 @@ config USB_AN2720 + config USB_BELKIN + bool "eTEK based host-to-host cables (Advance, Belkin, ...)" + depends on USB_NET_CDC_SUBSET ++ select USB_NET_CDC_SUBSET_ENABLE + default y + help + Choose this option if you're using a host-to-host cable +@@ -437,6 +444,7 @@ config USB_BELKIN + config USB_ARMLINUX + bool "Embedded ARM Linux links (iPaq, ...)" + depends on USB_NET_CDC_SUBSET ++ select USB_NET_CDC_SUBSET_ENABLE + default y + help + Choose this option to support the "usb-eth" networking driver +@@ -454,6 +462,7 @@ config USB_ARMLINUX + config USB_EPSON2888 + bool "Epson 2888 based firmware (DEVELOPMENT)" + depends on USB_NET_CDC_SUBSET ++ select USB_NET_CDC_SUBSET_ENABLE + help + Choose this option to support the usb networking links used + by some sample firmware from Epson. +@@ -461,6 +470,7 @@ config USB_EPSON2888 + config USB_KC2190 + bool "KT Technology KC2190 based cables (InstaNet)" + depends on USB_NET_CDC_SUBSET ++ select USB_NET_CDC_SUBSET_ENABLE + help + Choose this option if you're using a host-to-host cable + with one of these chips. +diff --git a/drivers/net/usb/Makefile b/drivers/net/usb/Makefile +index b5f04068dbe4..37fb46aee341 100644 +--- a/drivers/net/usb/Makefile ++++ b/drivers/net/usb/Makefile +@@ -23,7 +23,7 @@ obj-$(CONFIG_USB_NET_GL620A) += gl620a.o + obj-$(CONFIG_USB_NET_NET1080) += net1080.o + obj-$(CONFIG_USB_NET_PLUSB) += plusb.o + obj-$(CONFIG_USB_NET_RNDIS_HOST) += rndis_host.o +-obj-$(CONFIG_USB_NET_CDC_SUBSET) += cdc_subset.o ++obj-$(CONFIG_USB_NET_CDC_SUBSET_ENABLE) += cdc_subset.o + obj-$(CONFIG_USB_NET_ZAURUS) += zaurus.o + obj-$(CONFIG_USB_NET_MCS7830) += mcs7830.o + obj-$(CONFIG_USB_USBNET) += usbnet.o +diff --git a/drivers/net/wireless/cw1200/cw1200_spi.c b/drivers/net/wireless/cw1200/cw1200_spi.c +index a740083634d8..63f95e9c2992 100644 +--- a/drivers/net/wireless/cw1200/cw1200_spi.c ++++ b/drivers/net/wireless/cw1200/cw1200_spi.c +@@ -446,8 +446,7 @@ static int cw1200_spi_disconnect(struct spi_device *func) + return 0; + } + +-#ifdef CONFIG_PM +-static int cw1200_spi_suspend(struct device *dev) ++static int __maybe_unused cw1200_spi_suspend(struct device *dev) + { + struct hwbus_priv *self = spi_get_drvdata(to_spi_device(dev)); + +@@ -460,16 +459,12 @@ static int cw1200_spi_suspend(struct device *dev) + + static SIMPLE_DEV_PM_OPS(cw1200_pm_ops, cw1200_spi_suspend, NULL); + +-#endif +- + static struct spi_driver spi_driver = { + .probe = cw1200_spi_probe, + .remove = cw1200_spi_disconnect, + .driver = { + .name = "cw1200_wlan_spi", +-#ifdef CONFIG_PM +- .pm = &cw1200_pm_ops, +-#endif ++ .pm = IS_ENABLED(CONFIG_PM) ? &cw1200_pm_ops : NULL, + }, + }; + +diff --git a/drivers/net/wireless/cw1200/pm.h b/drivers/net/wireless/cw1200/pm.h +index 3ed90ff22bb8..534548470ebc 100644 +--- a/drivers/net/wireless/cw1200/pm.h ++++ b/drivers/net/wireless/cw1200/pm.h +@@ -31,13 +31,18 @@ int cw1200_pm_init(struct cw1200_pm_state *pm, + void cw1200_pm_deinit(struct cw1200_pm_state *pm); + int cw1200_wow_suspend(struct ieee80211_hw *hw, + struct cfg80211_wowlan *wowlan); +-int cw1200_wow_resume(struct ieee80211_hw *hw); + int cw1200_can_suspend(struct cw1200_common *priv); ++int cw1200_wow_resume(struct ieee80211_hw *hw); + void cw1200_pm_stay_awake(struct cw1200_pm_state *pm, + unsigned long tmo); + #else + static inline void cw1200_pm_stay_awake(struct cw1200_pm_state *pm, +- unsigned long tmo) { ++ unsigned long tmo) ++{ ++} ++static inline int cw1200_can_suspend(struct cw1200_common *priv) ++{ ++ return 0; + } + #endif + #endif +diff --git a/drivers/net/wireless/cw1200/wsm.c b/drivers/net/wireless/cw1200/wsm.c +index 9e0ca3048657..3dd46c78c1cc 100644 +--- a/drivers/net/wireless/cw1200/wsm.c ++++ b/drivers/net/wireless/cw1200/wsm.c +@@ -379,7 +379,6 @@ static int wsm_multi_tx_confirm(struct cw1200_common *priv, + { + int ret; + int count; +- int i; + + count = WSM_GET32(buf); + if (WARN_ON(count <= 0)) +@@ -395,11 +394,10 @@ static int wsm_multi_tx_confirm(struct cw1200_common *priv, + } + + cw1200_debug_txed_multi(priv, count); +- for (i = 0; i < count; ++i) { ++ do { + ret = wsm_tx_confirm(priv, buf, link_id); +- if (ret) +- return ret; +- } ++ } while (!ret && --count); ++ + return ret; + + underflow: +diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/dm.c b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/dm.c +index b57cfd965196..7b13962ec9da 100644 +--- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/dm.c ++++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/dm.c +@@ -2488,9 +2488,9 @@ void rtl8821ae_dm_txpower_tracking_callback_thermalmeter( + for (p = RF90_PATH_A; p < MAX_PATH_NUM_8821A; p++) + rtldm->swing_idx_ofdm_base[p] = rtldm->swing_idx_ofdm[p]; + +- RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, +- "pDM_Odm->RFCalibrateInfo.ThermalValue = %d ThermalValue= %d\n", +- rtldm->thermalvalue, thermal_value); ++ RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, ++ "pDM_Odm->RFCalibrateInfo.ThermalValue = %d ThermalValue= %d\n", ++ rtldm->thermalvalue, thermal_value); + /*Record last Power Tracking Thermal Value*/ + rtldm->thermalvalue = thermal_value; + } +diff --git a/drivers/pinctrl/sunxi/pinctrl-sun9i-a80.c b/drivers/pinctrl/sunxi/pinctrl-sun9i-a80.c +index 1b580ba76453..907d7db3fcee 100644 +--- a/drivers/pinctrl/sunxi/pinctrl-sun9i-a80.c ++++ b/drivers/pinctrl/sunxi/pinctrl-sun9i-a80.c +@@ -145,19 +145,19 @@ static const struct sunxi_desc_pin sun9i_a80_pins[] = { + SUNXI_FUNCTION(0x0, "gpio_in"), + SUNXI_FUNCTION(0x1, "gpio_out"), + SUNXI_FUNCTION(0x3, "mcsi"), /* MCLK */ +- SUNXI_FUNCTION_IRQ_BANK(0x6, 0, 14)), /* PB_EINT14 */ ++ SUNXI_FUNCTION_IRQ_BANK(0x6, 1, 14)), /* PB_EINT14 */ + SUNXI_PIN(SUNXI_PINCTRL_PIN(B, 15), + SUNXI_FUNCTION(0x0, "gpio_in"), + SUNXI_FUNCTION(0x1, "gpio_out"), + SUNXI_FUNCTION(0x3, "mcsi"), /* SCK */ + SUNXI_FUNCTION(0x4, "i2c4"), /* SCK */ +- SUNXI_FUNCTION_IRQ_BANK(0x6, 0, 15)), /* PB_EINT15 */ ++ SUNXI_FUNCTION_IRQ_BANK(0x6, 1, 15)), /* PB_EINT15 */ + SUNXI_PIN(SUNXI_PINCTRL_PIN(B, 16), + SUNXI_FUNCTION(0x0, "gpio_in"), + SUNXI_FUNCTION(0x1, "gpio_out"), + SUNXI_FUNCTION(0x3, "mcsi"), /* SDA */ + SUNXI_FUNCTION(0x4, "i2c4"), /* SDA */ +- SUNXI_FUNCTION_IRQ_BANK(0x6, 0, 16)), /* PB_EINT16 */ ++ SUNXI_FUNCTION_IRQ_BANK(0x6, 1, 16)), /* PB_EINT16 */ + + /* Hole */ + SUNXI_PIN(SUNXI_PINCTRL_PIN(C, 0), +diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig +index 1089eaa02b00..988ebe9a6b90 100644 +--- a/drivers/platform/x86/Kconfig ++++ b/drivers/platform/x86/Kconfig +@@ -95,6 +95,7 @@ config DELL_LAPTOP + tristate "Dell Laptop Extras" + depends on X86 + depends on DCDBAS ++ depends on DMI + depends on BACKLIGHT_CLASS_DEVICE + depends on ACPI_VIDEO || ACPI_VIDEO = n + depends on RFKILL || RFKILL = n +@@ -110,6 +111,7 @@ config DELL_LAPTOP + config DELL_WMI + tristate "Dell WMI extras" + depends on ACPI_WMI ++ depends on DMI + depends on INPUT + depends on ACPI_VIDEO || ACPI_VIDEO = n + select INPUT_SPARSEKMAP +diff --git a/drivers/platform/x86/intel_mid_thermal.c b/drivers/platform/x86/intel_mid_thermal.c +index 5c768c4627d3..78e1bfee698a 100644 +--- a/drivers/platform/x86/intel_mid_thermal.c ++++ b/drivers/platform/x86/intel_mid_thermal.c +@@ -415,6 +415,7 @@ static struct thermal_device_info *initialize_sensor(int index) + return td_info; + } + ++#ifdef CONFIG_PM_SLEEP + /** + * mid_thermal_resume - resume routine + * @dev: device structure +@@ -442,6 +443,7 @@ static int mid_thermal_suspend(struct device *dev) + */ + return configure_adc(0); + } ++#endif + + static SIMPLE_DEV_PM_OPS(mid_thermal_pm, + mid_thermal_suspend, mid_thermal_resume); +diff --git a/drivers/platform/x86/tc1100-wmi.c b/drivers/platform/x86/tc1100-wmi.c +index 89aa976f0ab2..65b0a4845ddd 100644 +--- a/drivers/platform/x86/tc1100-wmi.c ++++ b/drivers/platform/x86/tc1100-wmi.c +@@ -52,7 +52,9 @@ struct tc1100_data { + u32 jogdial; + }; + ++#ifdef CONFIG_PM + static struct tc1100_data suspend_data; ++#endif + + /* -------------------------------------------------------------------------- + Device Management +diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig +index 237d7aa73e8c..9f53fb74ae6f 100644 +--- a/drivers/power/Kconfig ++++ b/drivers/power/Kconfig +@@ -159,6 +159,7 @@ config BATTERY_SBS + + config BATTERY_BQ27XXX + tristate "BQ27xxx battery driver" ++ depends on I2C || I2C=n + help + Say Y here to enable support for batteries with BQ27xxx (I2C/HDQ) chips. + +diff --git a/drivers/power/bq27xxx_battery.c b/drivers/power/bq27xxx_battery.c +index 880233ce9343..6c3a447f378b 100644 +--- a/drivers/power/bq27xxx_battery.c ++++ b/drivers/power/bq27xxx_battery.c +@@ -285,7 +285,7 @@ static u8 bq27421_regs[] = { + 0x18, /* AP */ + }; + +-static u8 *bq27xxx_regs[] = { ++static u8 *bq27xxx_regs[] __maybe_unused = { + [BQ27000] = bq27000_regs, + [BQ27010] = bq27010_regs, + [BQ27500] = bq27500_regs, +@@ -991,7 +991,7 @@ static void bq27xxx_external_power_changed(struct power_supply *psy) + schedule_delayed_work(&di->work, 0); + } + +-static int bq27xxx_powersupply_init(struct bq27xxx_device_info *di, ++static int __maybe_unused bq27xxx_powersupply_init(struct bq27xxx_device_info *di, + const char *name) + { + int ret; +@@ -1026,7 +1026,7 @@ static int bq27xxx_powersupply_init(struct bq27xxx_device_info *di, + return 0; + } + +-static void bq27xxx_powersupply_unregister(struct bq27xxx_device_info *di) ++static void __maybe_unused bq27xxx_powersupply_unregister(struct bq27xxx_device_info *di) + { + /* + * power_supply_unregister call bq27xxx_battery_get_property which +diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c +index 9083247f55a8..21d174e9ebdb 100644 +--- a/drivers/s390/block/dasd_eckd.c ++++ b/drivers/s390/block/dasd_eckd.c +@@ -518,10 +518,12 @@ static int prefix_LRE(struct ccw1 *ccw, struct PFX_eckd_data *pfxdata, + pfxdata->validity.define_extent = 1; + + /* private uid is kept up to date, conf_data may be outdated */ +- if (startpriv->uid.type != UA_BASE_DEVICE) { ++ if (startpriv->uid.type == UA_BASE_PAV_ALIAS) + pfxdata->validity.verify_base = 1; +- if (startpriv->uid.type == UA_HYPER_PAV_ALIAS) +- pfxdata->validity.hyper_pav = 1; ++ ++ if (startpriv->uid.type == UA_HYPER_PAV_ALIAS) { ++ pfxdata->validity.verify_base = 1; ++ pfxdata->validity.hyper_pav = 1; + } + + /* define extend data (mostly)*/ +@@ -3002,10 +3004,12 @@ static int prepare_itcw(struct itcw *itcw, + pfxdata.validity.define_extent = 1; + + /* private uid is kept up to date, conf_data may be outdated */ +- if (startpriv->uid.type != UA_BASE_DEVICE) { ++ if (startpriv->uid.type == UA_BASE_PAV_ALIAS) ++ pfxdata.validity.verify_base = 1; ++ ++ if (startpriv->uid.type == UA_HYPER_PAV_ALIAS) { + pfxdata.validity.verify_base = 1; +- if (startpriv->uid.type == UA_HYPER_PAV_ALIAS) +- pfxdata.validity.hyper_pav = 1; ++ pfxdata.validity.hyper_pav = 1; + } + + switch (cmd) { +diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c +index febbd83e2ecd..24e57e770432 100644 +--- a/drivers/scsi/advansys.c ++++ b/drivers/scsi/advansys.c +@@ -6291,18 +6291,17 @@ static uchar AscGetSynPeriodIndex(ASC_DVC_VAR *asc_dvc, uchar syn_time) + static uchar + AscMsgOutSDTR(ASC_DVC_VAR *asc_dvc, uchar sdtr_period, uchar sdtr_offset) + { +- EXT_MSG sdtr_buf; +- uchar sdtr_period_index; +- PortAddr iop_base; +- +- iop_base = asc_dvc->iop_base; +- sdtr_buf.msg_type = EXTENDED_MESSAGE; +- sdtr_buf.msg_len = MS_SDTR_LEN; +- sdtr_buf.msg_req = EXTENDED_SDTR; +- sdtr_buf.xfer_period = sdtr_period; ++ PortAddr iop_base = asc_dvc->iop_base; ++ uchar sdtr_period_index = AscGetSynPeriodIndex(asc_dvc, sdtr_period); ++ EXT_MSG sdtr_buf = { ++ .msg_type = EXTENDED_MESSAGE, ++ .msg_len = MS_SDTR_LEN, ++ .msg_req = EXTENDED_SDTR, ++ .xfer_period = sdtr_period, ++ .req_ack_offset = sdtr_offset, ++ }; + sdtr_offset &= ASC_SYN_MAX_OFFSET; +- sdtr_buf.req_ack_offset = sdtr_offset; +- sdtr_period_index = AscGetSynPeriodIndex(asc_dvc, sdtr_period); ++ + if (sdtr_period_index <= asc_dvc->max_sdtr_index) { + AscMemWordCopyPtrToLram(iop_base, ASCV_MSGOUT_BEG, + (uchar *)&sdtr_buf, +@@ -11030,6 +11029,9 @@ static int advansys_board_found(struct Scsi_Host *shost, unsigned int iop, + ASC_DBG(2, "AdvInitGetConfig()\n"); + + ret = AdvInitGetConfig(pdev, shost) ? -ENODEV : 0; ++#else ++ share_irq = 0; ++ ret = -ENODEV; + #endif /* CONFIG_PCI */ + } + +diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c +index d4cda5e9600e..21c8d210c456 100644 +--- a/drivers/scsi/dpt_i2o.c ++++ b/drivers/scsi/dpt_i2o.c +@@ -180,11 +180,14 @@ static u8 adpt_read_blink_led(adpt_hba* host) + *============================================================================ + */ + ++#ifdef MODULE + static struct pci_device_id dptids[] = { + { PCI_DPT_VENDOR_ID, PCI_DPT_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, + { PCI_DPT_VENDOR_ID, PCI_DPT_RAPTOR_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, + { 0, } + }; ++#endif ++ + MODULE_DEVICE_TABLE(pci,dptids); + + static int adpt_detect(struct scsi_host_template* sht) +diff --git a/drivers/scsi/fdomain.c b/drivers/scsi/fdomain.c +index eefe14d453db..b87ab38a4530 100644 +--- a/drivers/scsi/fdomain.c ++++ b/drivers/scsi/fdomain.c +@@ -1768,7 +1768,7 @@ struct scsi_host_template fdomain_driver_template = { + }; + + #ifndef PCMCIA +-#ifdef CONFIG_PCI ++#if defined(CONFIG_PCI) && defined(MODULE) + + static struct pci_device_id fdomain_pci_tbl[] = { + { PCI_VENDOR_ID_FD, PCI_DEVICE_ID_FD_36C70, +diff --git a/drivers/scsi/g_NCR5380.c b/drivers/scsi/g_NCR5380.c +index f8d2478b11cc..87e081f8a386 100644 +--- a/drivers/scsi/g_NCR5380.c ++++ b/drivers/scsi/g_NCR5380.c +@@ -538,7 +538,10 @@ static inline int NCR5380_pread(struct Scsi_Host *instance, unsigned char *dst, + printk(KERN_ERR "53C400r: Got 53C80_IRQ start=%d, blocks=%d\n", start, blocks); + return -1; + } +- while (NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_HOST_BUF_NOT_RDY); ++ while (NCR5380_read(C400_CONTROL_STATUS_REG) & CSR_HOST_BUF_NOT_RDY) ++ { ++ // FIXME - no timeout ++ } + + #ifndef SCSI_G_NCR5380_MEM + { +diff --git a/drivers/scsi/initio.c b/drivers/scsi/initio.c +index 6a926bae76b2..7a91cf3ff173 100644 +--- a/drivers/scsi/initio.c ++++ b/drivers/scsi/initio.c +@@ -110,11 +110,6 @@ + #define i91u_MAXQUEUE 2 + #define i91u_REVID "Initio INI-9X00U/UW SCSI device driver; Revision: 1.04a" + +-#define I950_DEVICE_ID 0x9500 /* Initio's inic-950 product ID */ +-#define I940_DEVICE_ID 0x9400 /* Initio's inic-940 product ID */ +-#define I935_DEVICE_ID 0x9401 /* Initio's inic-935 product ID */ +-#define I920_DEVICE_ID 0x0002 /* Initio's other product ID */ +- + #ifdef DEBUG_i91u + static unsigned int i91u_debug = DEBUG_DEFAULT; + #endif +@@ -127,17 +122,6 @@ static int setup_debug = 0; + + static void i91uSCBPost(u8 * pHcb, u8 * pScb); + +-/* PCI Devices supported by this driver */ +-static struct pci_device_id i91u_pci_devices[] = { +- { PCI_VENDOR_ID_INIT, I950_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, +- { PCI_VENDOR_ID_INIT, I940_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, +- { PCI_VENDOR_ID_INIT, I935_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, +- { PCI_VENDOR_ID_INIT, I920_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, +- { PCI_VENDOR_ID_DOMEX, I920_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, +- { } +-}; +-MODULE_DEVICE_TABLE(pci, i91u_pci_devices); +- + #define DEBUG_INTERRUPT 0 + #define DEBUG_QUEUE 0 + #define DEBUG_STATE 0 +diff --git a/drivers/scsi/mvumi.c b/drivers/scsi/mvumi.c +index 02360de6b7e0..39285070f3b5 100644 +--- a/drivers/scsi/mvumi.c ++++ b/drivers/scsi/mvumi.c +@@ -2629,7 +2629,7 @@ static void mvumi_shutdown(struct pci_dev *pdev) + mvumi_flush_cache(mhba); + } + +-static int mvumi_suspend(struct pci_dev *pdev, pm_message_t state) ++static int __maybe_unused mvumi_suspend(struct pci_dev *pdev, pm_message_t state) + { + struct mvumi_hba *mhba = NULL; + +@@ -2648,7 +2648,7 @@ static int mvumi_suspend(struct pci_dev *pdev, pm_message_t state) + return 0; + } + +-static int mvumi_resume(struct pci_dev *pdev) ++static int __maybe_unused mvumi_resume(struct pci_dev *pdev) + { + int ret; + struct mvumi_hba *mhba = NULL; +diff --git a/drivers/scsi/sim710.c b/drivers/scsi/sim710.c +index 3b3b56f4a830..82ed99848378 100644 +--- a/drivers/scsi/sim710.c ++++ b/drivers/scsi/sim710.c +@@ -176,8 +176,7 @@ static struct eisa_device_id sim710_eisa_ids[] = { + }; + MODULE_DEVICE_TABLE(eisa, sim710_eisa_ids); + +-static __init int +-sim710_eisa_probe(struct device *dev) ++static int sim710_eisa_probe(struct device *dev) + { + struct eisa_device *edev = to_eisa_device(dev); + unsigned long io_addr = edev->base_addr; +diff --git a/drivers/spi/spi-sun4i.c b/drivers/spi/spi-sun4i.c +index 39d7c7c70112..2eea3de5a668 100644 +--- a/drivers/spi/spi-sun4i.c ++++ b/drivers/spi/spi-sun4i.c +@@ -458,7 +458,7 @@ err_free_master: + + static int sun4i_spi_remove(struct platform_device *pdev) + { +- pm_runtime_disable(&pdev->dev); ++ pm_runtime_force_suspend(&pdev->dev); + + return 0; + } +diff --git a/drivers/ssb/main.c b/drivers/ssb/main.c +index 5d1e9a0fc389..e2ff6b5b2094 100644 +--- a/drivers/ssb/main.c ++++ b/drivers/ssb/main.c +@@ -613,9 +613,10 @@ out: + return err; + } + +-static int ssb_bus_register(struct ssb_bus *bus, +- ssb_invariants_func_t get_invariants, +- unsigned long baseaddr) ++static int __maybe_unused ++ssb_bus_register(struct ssb_bus *bus, ++ ssb_invariants_func_t get_invariants, ++ unsigned long baseaddr) + { + int err; + +diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c +index b64327722660..ec31b53ae3a5 100644 +--- a/drivers/staging/android/ashmem.c ++++ b/drivers/staging/android/ashmem.c +@@ -704,30 +704,32 @@ static int ashmem_pin_unpin(struct ashmem_area *asma, unsigned long cmd, + size_t pgstart, pgend; + int ret = -EINVAL; + ++ mutex_lock(&ashmem_mutex); ++ + if (unlikely(!asma->file)) +- return -EINVAL; ++ goto out_unlock; + +- if (unlikely(copy_from_user(&pin, p, sizeof(pin)))) +- return -EFAULT; ++ if (unlikely(copy_from_user(&pin, p, sizeof(pin)))) { ++ ret = -EFAULT; ++ goto out_unlock; ++ } + + /* per custom, you can pass zero for len to mean "everything onward" */ + if (!pin.len) + pin.len = PAGE_ALIGN(asma->size) - pin.offset; + + if (unlikely((pin.offset | pin.len) & ~PAGE_MASK)) +- return -EINVAL; ++ goto out_unlock; + + if (unlikely(((__u32)-1) - pin.offset < pin.len)) +- return -EINVAL; ++ goto out_unlock; + + if (unlikely(PAGE_ALIGN(asma->size) < pin.offset + pin.len)) +- return -EINVAL; ++ goto out_unlock; + + pgstart = pin.offset / PAGE_SIZE; + pgend = pgstart + (pin.len / PAGE_SIZE) - 1; + +- mutex_lock(&ashmem_mutex); +- + switch (cmd) { + case ASHMEM_PIN: + ret = ashmem_pin(asma, pgstart, pgend); +@@ -740,6 +742,7 @@ static int ashmem_pin_unpin(struct ashmem_area *asma, unsigned long cmd, + break; + } + ++out_unlock: + mutex_unlock(&ashmem_mutex); + + return ret; +diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c +index abc66908681d..6f032009f93f 100644 +--- a/drivers/staging/iio/adc/ad7192.c ++++ b/drivers/staging/iio/adc/ad7192.c +@@ -124,6 +124,8 @@ + #define AD7192_GPOCON_P1DAT BIT(1) /* P1 state */ + #define AD7192_GPOCON_P0DAT BIT(0) /* P0 state */ + ++#define AD7192_EXT_FREQ_MHZ_MIN 2457600 ++#define AD7192_EXT_FREQ_MHZ_MAX 5120000 + #define AD7192_INT_FREQ_MHZ 4915200 + + /* NOTE: +@@ -199,6 +201,12 @@ static int ad7192_calibrate_all(struct ad7192_state *st) + ARRAY_SIZE(ad7192_calib_arr)); + } + ++static inline bool ad7192_valid_external_frequency(u32 freq) ++{ ++ return (freq >= AD7192_EXT_FREQ_MHZ_MIN && ++ freq <= AD7192_EXT_FREQ_MHZ_MAX); ++} ++ + static int ad7192_setup(struct ad7192_state *st, + const struct ad7192_platform_data *pdata) + { +@@ -224,17 +232,20 @@ static int ad7192_setup(struct ad7192_state *st, + id); + + switch (pdata->clock_source_sel) { +- case AD7192_CLK_EXT_MCLK1_2: +- case AD7192_CLK_EXT_MCLK2: +- st->mclk = AD7192_INT_FREQ_MHZ; +- break; + case AD7192_CLK_INT: + case AD7192_CLK_INT_CO: +- if (pdata->ext_clk_hz) +- st->mclk = pdata->ext_clk_hz; +- else +- st->mclk = AD7192_INT_FREQ_MHZ; ++ st->mclk = AD7192_INT_FREQ_MHZ; + break; ++ case AD7192_CLK_EXT_MCLK1_2: ++ case AD7192_CLK_EXT_MCLK2: ++ if (ad7192_valid_external_frequency(pdata->ext_clk_hz)) { ++ st->mclk = pdata->ext_clk_hz; ++ break; ++ } ++ dev_err(&st->sd.spi->dev, "Invalid frequency setting %u\n", ++ pdata->ext_clk_hz); ++ ret = -EINVAL; ++ goto out; + default: + ret = -EINVAL; + goto out; +diff --git a/drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c b/drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c +index 824d460911ec..58ccafb97344 100644 +--- a/drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c ++++ b/drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c +@@ -1039,7 +1039,6 @@ static int synaptics_rmi4_remove(struct i2c_client *client) + return 0; + } + +-#ifdef CONFIG_PM + /** + * synaptics_rmi4_suspend() - suspend the touch screen controller + * @dev: pointer to device structure +@@ -1047,7 +1046,7 @@ static int synaptics_rmi4_remove(struct i2c_client *client) + * This function is used to suspend the + * touch panel controller and returns integer + */ +-static int synaptics_rmi4_suspend(struct device *dev) ++static int __maybe_unused synaptics_rmi4_suspend(struct device *dev) + { + /* Touch sleep mode */ + int retval; +@@ -1081,7 +1080,7 @@ static int synaptics_rmi4_suspend(struct device *dev) + * This function is used to resume the touch panel + * controller and returns integer. + */ +-static int synaptics_rmi4_resume(struct device *dev) ++static int __maybe_unused synaptics_rmi4_resume(struct device *dev) + { + int retval; + unsigned char intr_status; +@@ -1112,8 +1111,6 @@ static int synaptics_rmi4_resume(struct device *dev) + return 0; + } + +-#endif +- + static SIMPLE_DEV_PM_OPS(synaptics_rmi4_dev_pm_ops, synaptics_rmi4_suspend, + synaptics_rmi4_resume); + +diff --git a/drivers/staging/unisys/visorinput/Kconfig b/drivers/staging/unisys/visorinput/Kconfig +index d83deb4137e8..6baba2795ce7 100644 +--- a/drivers/staging/unisys/visorinput/Kconfig ++++ b/drivers/staging/unisys/visorinput/Kconfig +@@ -4,7 +4,7 @@ + + config UNISYS_VISORINPUT + tristate "Unisys visorinput driver" +- depends on UNISYSSPAR && UNISYS_VISORBUS && FB ++ depends on UNISYSSPAR && UNISYS_VISORBUS && FB && INPUT + ---help--- + If you say Y here, you will enable the Unisys visorinput driver. + +diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h b/drivers/staging/wilc1000/wilc_wlan_if.h +index be972afe6e62..bfc3e96d8d25 100644 +--- a/drivers/staging/wilc1000/wilc_wlan_if.h ++++ b/drivers/staging/wilc1000/wilc_wlan_if.h +@@ -12,6 +12,7 @@ + + #include + #include "linux_wlan_common.h" ++#include + + /******************************************** + * +diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c +index a7d30e894cab..c43c942e1f87 100644 +--- a/drivers/target/target_core_user.c ++++ b/drivers/target/target_core_user.c +@@ -900,7 +900,7 @@ static int tcmu_configure_device(struct se_device *dev) + info->version = __stringify(TCMU_MAILBOX_VERSION); + + info->mem[0].name = "tcm-user command & data buffer"; +- info->mem[0].addr = (phys_addr_t) udev->mb_addr; ++ info->mem[0].addr = (phys_addr_t)(uintptr_t)udev->mb_addr; + info->mem[0].size = TCMU_RING_SIZE; + info->mem[0].memtype = UIO_MEM_VIRTUAL; + +diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig +index 8cc4ac64a91c..4b660b5beb98 100644 +--- a/drivers/thermal/Kconfig ++++ b/drivers/thermal/Kconfig +@@ -299,7 +299,7 @@ config X86_PKG_TEMP_THERMAL + + config INTEL_SOC_DTS_IOSF_CORE + tristate +- depends on X86 ++ depends on X86 && PCI + select IOSF_MBI + help + This is becoming a common feature for Intel SoCs to expose the additional +@@ -309,7 +309,7 @@ config INTEL_SOC_DTS_IOSF_CORE + + config INTEL_SOC_DTS_THERMAL + tristate "Intel SoCs DTS thermal driver" +- depends on X86 ++ depends on X86 && PCI + select INTEL_SOC_DTS_IOSF_CORE + select THERMAL_WRITABLE_TRIPS + help +diff --git a/drivers/thermal/spear_thermal.c b/drivers/thermal/spear_thermal.c +index 534dd9136662..81b35aace9de 100644 +--- a/drivers/thermal/spear_thermal.c ++++ b/drivers/thermal/spear_thermal.c +@@ -54,8 +54,7 @@ static struct thermal_zone_device_ops ops = { + .get_temp = thermal_get_temp, + }; + +-#ifdef CONFIG_PM +-static int spear_thermal_suspend(struct device *dev) ++static int __maybe_unused spear_thermal_suspend(struct device *dev) + { + struct platform_device *pdev = to_platform_device(dev); + struct thermal_zone_device *spear_thermal = platform_get_drvdata(pdev); +@@ -72,7 +71,7 @@ static int spear_thermal_suspend(struct device *dev) + return 0; + } + +-static int spear_thermal_resume(struct device *dev) ++static int __maybe_unused spear_thermal_resume(struct device *dev) + { + struct platform_device *pdev = to_platform_device(dev); + struct thermal_zone_device *spear_thermal = platform_get_drvdata(pdev); +@@ -94,7 +93,6 @@ static int spear_thermal_resume(struct device *dev) + + return 0; + } +-#endif + + static SIMPLE_DEV_PM_OPS(spear_thermal_pm_ops, spear_thermal_suspend, + spear_thermal_resume); +diff --git a/drivers/tty/Kconfig b/drivers/tty/Kconfig +index c01f45095877..82c4d2e45319 100644 +--- a/drivers/tty/Kconfig ++++ b/drivers/tty/Kconfig +@@ -226,7 +226,7 @@ config CYCLADES + + config CYZ_INTR + bool "Cyclades-Z interrupt mode operation" +- depends on CYCLADES ++ depends on CYCLADES && PCI + help + The Cyclades-Z family of multiport cards allows 2 (two) driver op + modes: polling and interrupt. In polling mode, the driver will check +diff --git a/drivers/tty/hvc/hvc_xen.c b/drivers/tty/hvc/hvc_xen.c +index fa816b7193b6..11725422dacb 100644 +--- a/drivers/tty/hvc/hvc_xen.c ++++ b/drivers/tty/hvc/hvc_xen.c +@@ -323,6 +323,7 @@ void xen_console_resume(void) + } + } + ++#ifdef CONFIG_HVC_XEN_FRONTEND + static void xencons_disconnect_backend(struct xencons_info *info) + { + if (info->irq > 0) +@@ -363,7 +364,6 @@ static int xen_console_remove(struct xencons_info *info) + return 0; + } + +-#ifdef CONFIG_HVC_XEN_FRONTEND + static int xencons_remove(struct xenbus_device *dev) + { + return xen_console_remove(dev_get_drvdata(&dev->dev)); +diff --git a/drivers/tty/serial/8250/Kconfig b/drivers/tty/serial/8250/Kconfig +index 6412f1455beb..6f4c180aadc1 100644 +--- a/drivers/tty/serial/8250/Kconfig ++++ b/drivers/tty/serial/8250/Kconfig +@@ -372,7 +372,7 @@ config SERIAL_8250_MID + tristate "Support for serial ports on Intel MID platforms" + depends on SERIAL_8250 && PCI + select HSU_DMA if SERIAL_8250_DMA +- select HSU_DMA_PCI if X86_INTEL_MID ++ select HSU_DMA_PCI if (HSU_DMA && X86_INTEL_MID) + select RATIONAL + help + Selecting this option will enable handling of the extra features +diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig +index 3bb08870148f..95e72d75e0a0 100644 +--- a/drivers/usb/host/Kconfig ++++ b/drivers/usb/host/Kconfig +@@ -220,6 +220,8 @@ config USB_EHCI_TEGRA + depends on ARCH_TEGRA + select USB_EHCI_ROOT_HUB_TT + select USB_PHY ++ select USB_ULPI ++ select USB_ULPI_VIEWPORT + help + This driver enables support for the internal USB Host Controllers + found in NVIDIA Tegra SoCs. The controllers are EHCI compliant. +diff --git a/drivers/usb/musb/ux500_dma.c b/drivers/usb/musb/ux500_dma.c +index d0b6a1cd7f62..c92a295049ad 100644 +--- a/drivers/usb/musb/ux500_dma.c ++++ b/drivers/usb/musb/ux500_dma.c +@@ -207,9 +207,6 @@ static int ux500_dma_channel_program(struct dma_channel *channel, + BUG_ON(channel->status == MUSB_DMA_STATUS_UNKNOWN || + channel->status == MUSB_DMA_STATUS_BUSY); + +- if (!ux500_dma_is_compatible(channel, packet_sz, (void *)dma_addr, len)) +- return false; +- + channel->status = MUSB_DMA_STATUS_BUSY; + channel->actual_len = 0; + ret = ux500_configure_channel(channel, packet_sz, mode, dma_addr, len); +diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig +index 22e8ecb6bfbd..7a72bef35acf 100644 +--- a/drivers/usb/phy/Kconfig ++++ b/drivers/usb/phy/Kconfig +@@ -140,6 +140,7 @@ config USB_MSM_OTG + tristate "Qualcomm on-chip USB OTG controller support" + depends on (USB || USB_GADGET) && (ARCH_QCOM || COMPILE_TEST) + depends on RESET_CONTROLLER ++ depends on REGULATOR + depends on EXTCON + select USB_PHY + help +diff --git a/drivers/usb/usbip/stub_dev.c b/drivers/usb/usbip/stub_dev.c +index ec38370ffcab..0931f3271119 100644 +--- a/drivers/usb/usbip/stub_dev.c ++++ b/drivers/usb/usbip/stub_dev.c +@@ -87,6 +87,7 @@ static ssize_t store_sockfd(struct device *dev, struct device_attribute *attr, + goto err; + + sdev->ud.tcp_socket = socket; ++ sdev->ud.sockfd = sockfd; + + spin_unlock_irq(&sdev->ud.lock); + +@@ -186,6 +187,7 @@ static void stub_shutdown_connection(struct usbip_device *ud) + if (ud->tcp_socket) { + sockfd_put(ud->tcp_socket); + ud->tcp_socket = NULL; ++ ud->sockfd = -1; + } + + /* 3. free used data */ +@@ -280,6 +282,7 @@ static struct stub_device *stub_device_alloc(struct usb_device *udev) + sdev->ud.status = SDEV_ST_AVAILABLE; + spin_lock_init(&sdev->ud.lock); + sdev->ud.tcp_socket = NULL; ++ sdev->ud.sockfd = -1; + + INIT_LIST_HEAD(&sdev->priv_init); + INIT_LIST_HEAD(&sdev->priv_tx); +diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c +index 2d96bfd34138..4d68a1e9e878 100644 +--- a/drivers/usb/usbip/vhci_hcd.c ++++ b/drivers/usb/usbip/vhci_hcd.c +@@ -797,6 +797,7 @@ static void vhci_shutdown_connection(struct usbip_device *ud) + if (vdev->ud.tcp_socket) { + sockfd_put(vdev->ud.tcp_socket); + vdev->ud.tcp_socket = NULL; ++ vdev->ud.sockfd = -1; + } + pr_info("release socket\n"); + +@@ -844,6 +845,7 @@ static void vhci_device_reset(struct usbip_device *ud) + if (ud->tcp_socket) { + sockfd_put(ud->tcp_socket); + ud->tcp_socket = NULL; ++ ud->sockfd = -1; + } + ud->status = VDEV_ST_NULL; + +diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig +index f07a0974fda2..3543e3e4cfb5 100644 +--- a/drivers/video/fbdev/Kconfig ++++ b/drivers/video/fbdev/Kconfig +@@ -1506,6 +1506,7 @@ config FB_SIS + select FB_CFB_COPYAREA + select FB_CFB_IMAGEBLIT + select FB_BOOT_VESA_SUPPORT if FB_SIS = y ++ select FB_SIS_300 if !FB_SIS_315 + help + This is the frame buffer device driver for the SiS 300, 315, 330 + and 340 series as well as XGI V3XT, V5, V8, Z7 graphics chipsets. +diff --git a/drivers/video/fbdev/auo_k190x.c b/drivers/video/fbdev/auo_k190x.c +index 8d2499d1cafb..9580374667ba 100644 +--- a/drivers/video/fbdev/auo_k190x.c ++++ b/drivers/video/fbdev/auo_k190x.c +@@ -773,9 +773,7 @@ static void auok190x_recover(struct auok190xfb_par *par) + /* + * Power-management + */ +- +-#ifdef CONFIG_PM +-static int auok190x_runtime_suspend(struct device *dev) ++static int __maybe_unused auok190x_runtime_suspend(struct device *dev) + { + struct platform_device *pdev = to_platform_device(dev); + struct fb_info *info = platform_get_drvdata(pdev); +@@ -822,7 +820,7 @@ finish: + return 0; + } + +-static int auok190x_runtime_resume(struct device *dev) ++static int __maybe_unused auok190x_runtime_resume(struct device *dev) + { + struct platform_device *pdev = to_platform_device(dev); + struct fb_info *info = platform_get_drvdata(pdev); +@@ -856,7 +854,7 @@ static int auok190x_runtime_resume(struct device *dev) + return 0; + } + +-static int auok190x_suspend(struct device *dev) ++static int __maybe_unused auok190x_suspend(struct device *dev) + { + struct platform_device *pdev = to_platform_device(dev); + struct fb_info *info = platform_get_drvdata(pdev); +@@ -896,7 +894,7 @@ static int auok190x_suspend(struct device *dev) + return 0; + } + +-static int auok190x_resume(struct device *dev) ++static int __maybe_unused auok190x_resume(struct device *dev) + { + struct platform_device *pdev = to_platform_device(dev); + struct fb_info *info = platform_get_drvdata(pdev); +@@ -933,7 +931,6 @@ static int auok190x_resume(struct device *dev) + + return 0; + } +-#endif + + const struct dev_pm_ops auok190x_pm = { + SET_RUNTIME_PM_OPS(auok190x_runtime_suspend, auok190x_runtime_resume, +diff --git a/drivers/video/fbdev/exynos/s6e8ax0.c b/drivers/video/fbdev/exynos/s6e8ax0.c +index 95873f26e39c..de2f3e793786 100644 +--- a/drivers/video/fbdev/exynos/s6e8ax0.c ++++ b/drivers/video/fbdev/exynos/s6e8ax0.c +@@ -829,8 +829,7 @@ static int s6e8ax0_probe(struct mipi_dsim_lcd_device *dsim_dev) + return 0; + } + +-#ifdef CONFIG_PM +-static int s6e8ax0_suspend(struct mipi_dsim_lcd_device *dsim_dev) ++static int __maybe_unused s6e8ax0_suspend(struct mipi_dsim_lcd_device *dsim_dev) + { + struct s6e8ax0 *lcd = dev_get_drvdata(&dsim_dev->dev); + +@@ -843,7 +842,7 @@ static int s6e8ax0_suspend(struct mipi_dsim_lcd_device *dsim_dev) + return 0; + } + +-static int s6e8ax0_resume(struct mipi_dsim_lcd_device *dsim_dev) ++static int __maybe_unused s6e8ax0_resume(struct mipi_dsim_lcd_device *dsim_dev) + { + struct s6e8ax0 *lcd = dev_get_drvdata(&dsim_dev->dev); + +@@ -855,10 +854,6 @@ static int s6e8ax0_resume(struct mipi_dsim_lcd_device *dsim_dev) + + return 0; + } +-#else +-#define s6e8ax0_suspend NULL +-#define s6e8ax0_resume NULL +-#endif + + static struct mipi_dsim_lcd_driver s6e8ax0_dsim_ddi_driver = { + .name = "s6e8ax0", +@@ -867,8 +862,8 @@ static struct mipi_dsim_lcd_driver s6e8ax0_dsim_ddi_driver = { + .power_on = s6e8ax0_power_on, + .set_sequence = s6e8ax0_set_sequence, + .probe = s6e8ax0_probe, +- .suspend = s6e8ax0_suspend, +- .resume = s6e8ax0_resume, ++ .suspend = IS_ENABLED(CONFIG_PM) ? s6e8ax0_suspend : NULL, ++ .resume = IS_ENABLED(CONFIG_PM) ? s6e8ax0_resume : NULL, + }; + + static int s6e8ax0_init(void) +diff --git a/drivers/video/fbdev/intelfb/intelfbdrv.c b/drivers/video/fbdev/intelfb/intelfbdrv.c +index bbec737eef30..bf207444ba0c 100644 +--- a/drivers/video/fbdev/intelfb/intelfbdrv.c ++++ b/drivers/video/fbdev/intelfb/intelfbdrv.c +@@ -302,7 +302,7 @@ static __inline__ int get_opt_int(const char *this_opt, const char *name, + } + + static __inline__ int get_opt_bool(const char *this_opt, const char *name, +- int *ret) ++ bool *ret) + { + if (!ret) + return 0; +diff --git a/drivers/video/fbdev/mmp/core.c b/drivers/video/fbdev/mmp/core.c +index a0f496049db7..3a6bb6561ba0 100644 +--- a/drivers/video/fbdev/mmp/core.c ++++ b/drivers/video/fbdev/mmp/core.c +@@ -23,6 +23,7 @@ + #include + #include + #include ++#include + #include