# Base git commit: 29b4817d4018
# (Linux 4.8-rc1)
# 
# Author:    Russell King (Mon 15 Aug 18:55:11 BST 2016)
# Committer: Russell King (Mon 15 Aug 18:55:11 BST 2016)
# 
#   Merge branches 'fixes' and 'misc' into for-next
# 
# Author:    Jisheng Zhang (Mon 15 Aug 09:20:21 BST 2016)
# Committer: Russell King (Mon 15 Aug 18:54:43 BST 2016)
# 
#   ARM: 8597/1: VDSO: put RO and RO after init objects into proper sections
# 
#   vdso_data_mapping is never modified, so mark it as const.
# 
#   vdso_total_pages, vdso_data_page, vdso_text_mapping and cntvct_ok are
#   initialized by vdso_init(), thereafter are read only.
# 
#   The fact that they are read only after init makes them candidates for
#   __ro_after_init declarations.
# 
#   Signed-off-by: Jisheng Zhang
#   Reviewed-by: Kees Cook
#   Acked-by: Nathan Lynch
#   Signed-off-by: Russell King
# 
#   92bb8d5d55f7fe1a7a1201c42120c1611840807c
#    arch/arm/kernel/vdso.c | 11 ++++++-----
#    1 file changed, 6 insertions(+), 5 deletions(-)
# 
# Author:    Stephen Boyd (Wed 10 Aug 20:17:34 BST 2016)
# Committer: Russell King (Fri 12 Aug 16:47:07 BST 2016)
# 
#   ARM: 8596/1: amba: Support clk parents and rates assigned in DT
# 
#   Add the call to of_clk_set_defaults() into the amba probe path so
#   that devices on the amba bus can use the assigned rates and
# 
#   Cc: Michael Turquette
#   Tested-by: Jorge Ramirez Ortiz
#   Signed-off-by: Stephen Boyd
#   Signed-off-by: Russell King
# 
#   bcd3006f07ef9c80ac225854c1518c22f2f56d71
#    drivers/amba/bus.c | 5 +++++
#    1 file changed, 5 insertions(+)
# 
# Author:    Kees Cook (Wed 10 Aug 22:46:49 BST 2016)
# Committer: Russell King (Fri 12 Aug 16:47:06 BST 2016)
# 
#   ARM: 8595/2: apply more __ro_after_init
# 
#   Guided by grsecurity's analogous __read_only markings in arch/arm,
#   this applies several uses of __ro_after_init to structures that are
#   only updated during __init.
# 
#   Signed-off-by: Kees Cook
#   Signed-off-by: Russell King
# 
#   7619751f8c900fa5fdd76db06f4caf095c56de8e
#    arch/arm/kernel/cpuidle.c |  2 +-
#    arch/arm/kernel/setup.c   | 10 +++++-----
#    arch/arm/kernel/smp.c     |  2 +-
#    arch/arm/lib/delay.c      |  2 +-
#    arch/arm/mm/mmu.c         |  2 +-
#    5 files changed, 9 insertions(+), 9 deletions(-)
# 
# Author:    Nicolas Pitre (Fri  5 Aug 06:03:41 BST 2016)
# Committer: Russell King (Fri 12 Aug 16:47:05 BST 2016)
# 
#   ARM: 8594/1: enable binfmt_flat on systems with an MMU
# 
#   Now that the generic changes are in place, this can be enabled on ARM
#   with the use of proper user space accessors in the flat_get_addr_from_rp()
#   and flat_put_addr_at_rp() handlers as rp actually holds a user space
#   address.
# 
#   Signed-off-by: Nicolas Pitre
#   Signed-off-by: Russell King
# 
#   d782e426b835bd2e79d868eb4af8510ed79e0aee
#    arch/arm/include/asm/flat.h | 5 +++--
#    fs/Kconfig.binfmt           | 2 +-
#    2 files changed, 4 insertions(+), 3 deletions(-)
# 
# Author:    Andrey Smirnov (Wed  3 Aug 20:33:34 BST 2016)
# Committer: Russell King (Fri 12 Aug 16:47:04 BST 2016)
# 
#   ARM: 8593/1: cache-l2x0.c: Do not clear bit 23 in prefetch control register
# 
#   As per L2C-310 TRM[1]:
# 
#   "... You can control this feature using bits 30,27 and 23 of the
#   Prefetch Control Register. Bit 23 and 27 are only used if you set bit 30
#   HIGH..."
# 
#   which means there is no need to clear bit 23 if bit 30 is being cleared.
# 
#   [1] http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0246e/CJAJACBJ.html
# 
#   Acked-by: Arnd Bergmann
#   Signed-off-by: Andrey Smirnov
#   Signed-off-by: Russell King
# 
#   55604b7ab1b5b8f560721e69b1ac059bd8d2078e
#    arch/arm/mm/cache-l2x0.c | 7 ++-----
#    1 file changed, 2 insertions(+), 5 deletions(-)
# 
# Author:    Andrey Smirnov (Wed  3 Aug 20:29:38 BST 2016)
# Committer: Russell King (Fri 12 Aug 16:47:03 BST 2016)
# 
#   ARM: 8592/1: cache-l2x0.c: Replace magic numbers
# 
#   Replace magic numbers used for L310 Prefetch Control Register
# 
#   Acked-by: Arnd Bergmann
#   Signed-off-by: Andrey Smirnov
#   Signed-off-by: Russell King
# 
#   fc1473103cfa0b785dd3ff8de2430fec42cfc8ad
#    arch/arm/mm/cache-l2x0.c | 6 ++++--
#    1 file changed, 4 insertions(+), 2 deletions(-)
# 
# Author:    Nicolas Pitre (Thu 28 Jul 19:37:21 BST 2016)
# Committer: Russell King (Fri 12 Aug 16:47:02 BST 2016)
# 
#   ARM: 8589/1: asm/memory.h: remove dead definitions
# 
#   The last ad-hoc __phys_to_virt definition was removed in commit fd0053c9
#   ("ARM: realview: remove sparsemem hack"). Therefore we can remove the
#   unneeded definitions and unduplicate the virt_to_pfn macro from
#   asm/memory.h.
# 
#   Signed-off-by: Nicolas Pitre
#   Signed-off-by: Russell King
# 
#   7d281b620d229486429d851b10a05da871d22e79
#    arch/arm/include/asm/memory.h | 15 +++------------
#    1 file changed, 3 insertions(+), 12 deletions(-)
# 
# Author:    Mark Rutland (Tue 19 Jul 11:23:37 BST 2016)
# Committer: Russell King (Fri 12 Aug 16:47:01 BST 2016)
# 
#   ARM: 8588/1: localise objcopy flags
# 
#   We currently define OBJCOPYFLAGS in the top-level arm Makefile, and thus
#   these flags will be passed to all uses of objcopy, kernel-wide, for
#   which they are not explicitly overridden. The flags we set are intended
#   for converting a few ELF files into raw binaries, and thus the flags
#   chosen are problematic for some other uses which do not expect a raw
#   binary result, e.g. the upcoming lkdtm rodata test:
# 
#     http://www.openwall.com/lists/kernel-hardening/2016/06/08/2
# 
#   This patch localises the objcopy flags such that they are only used for
#   the cases we require them for today.
# 
#   Signed-off-by: Mark Rutland
#   Acked-by: Kees Cook
#   Tested-by: Laura Abbott
#   Cc: Russell King
#   Signed-off-by: Russell King
# 
#   3cb59581a860f5f542b37aed214f74b3f2ccfa32
#    arch/arm/Makefile      | 1 -
#    arch/arm/boot/Makefile | 2 ++
#    2 files changed, 2 insertions(+), 1 deletion(-)
# 
# Author:    Fabio Estevam (Mon 18 Jul 13:09:36 BST 2016)
# Committer: Russell King (Fri 12 Aug 16:47:01 BST 2016)
# 
#   ARM: 8587/1: dma-mapping: Use %zu for printing a size_t variable
# 
#   According to Documentation/printk-formats.txt when printing
#   a size_t variable we should use %zu or %zx format specifiers.
# 
#   As we are printing a memory size value, we should better use %zu
#   in this case.
# 
#   Reported-by: Frank Mori Hess
#   Signed-off-by: Fabio Estevam
#   Signed-off-by: Russell King
# 
#   bf31c5e07db81073aa7fedc5401afa967b177fe2
#    arch/arm/mm/dma-mapping.c | 4 ++--
#    1 file changed, 2 insertions(+), 2 deletions(-)
# 
# Author:    Russell King (Wed  3 Aug 10:33:35 BST 2016)
# Committer: Russell King (Tue  9 Aug 22:57:59 BST 2016)
# 
#   ARM: fix address limit restoration for undefined instructions
# 
#   During boot, sometimes the kernel will test to see if an instruction
#   causes an undefined instruction exception.  Unfortunately, the exit
#   path for these exceptions did not restore the address limit, which
#   causes the rootfs mount code to fail.  Fix the missing address limit
#   restoration.
# 
#   Tested-by: Guenter Roeck
#   Signed-off-by: Russell King
# 
#   87eed3c74d7c65556f744230a90bf9556dd29146
#    arch/arm/kernel/entry-armv.S | 1 +
#    1 file changed, 1 insertion(+)
# 
# Author:    Ard Biesheuvel (Thu 28 Jul 19:48:44 BST 2016)
# Committer: Russell King (Tue  9 Aug 22:57:41 BST 2016)
# 
#   ARM: 8591/1: mm: use fully constructed struct pages for EFI pgd allocations
# 
#   The late_alloc() PTE allocation function used by create_mapping_late()
#   does not call pgtable_page_ctor() on PTE pages it allocates, leaving
#   the per-page spinlock uninitialized.
# 
#   Since generic page table manipulation code may assume that translation
#   table pages that are not owned by init_mm are covered by fully
#   constructed struct pages, the following crash may occur with the new
#   UEFI memory attributes table code.
# 
#     efi: memattr: Processing EFI Memory Attributes table:
#     efi: memattr:  0x0000ffa16000-0x0000ffa82fff [Runtime Code       |RUN|  |  |XP|  |  |  |   |  |  |  |  ]
#     Unable to handle kernel NULL pointer dereference at virtual address 00000010
#     pgd = c0204000
#     [00000010] *pgd=00000000
#     Internal error: Oops: 5 [#1] SMP ARM
#     Modules linked in:
#     CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.7.0-rc4-00063-g3882aa7b340b #361
#     Hardware name: Generic DT based system
#     task: ed858000 ti: ed842000 task.ti: ed842000
#     PC is at __lock_acquire+0xa0/0x19a8
#     ...
#     [<c038c830>] (__lock_acquire) from [<c038e4f8>] (lock_acquire+0x6c/0x88)
#     [<c038e4f8>] (lock_acquire) from [<c0c06134>] (_raw_spin_lock+0x2c/0x3c)
#     [<c0c06134>] (_raw_spin_lock) from [<c0410384>] (apply_to_page_range+0xe8/0x238)
#     [<c0410384>] (apply_to_page_range) from [<c1205f34>] (efi_set_mapping_permissions+0x54/0x5c)
#     [<c1205f34>] (efi_set_mapping_permissions) from [<c1247474>] (efi_memattr_apply_permissions+0x2b8/0x378)
#     [<c1247474>] (efi_memattr_apply_permissions) from [<c1248258>] (arm_enable_runtime_services+0x1f0/0x22c)
#     [<c1248258>] (arm_enable_runtime_services) from [<c0301f0c>] (do_one_initcall+0x44/0x174)
#     [<c0301f0c>] (do_one_initcall) from [<c1200d10>] (kernel_init_freeable+0x90/0x1e8)
#     [<c1200d10>] (kernel_init_freeable) from [<c0bff690>] (kernel_init+0x8/0x114)
#     [<c0bff690>] (kernel_init) from [<c0307ed0>] (ret_from_fork+0x14/0x24)
# 
#   The crash is due to the fact that the UEFI page tables are not owned by
#   init_mm, but are not covered by fully constructed struct pages.
# 
#   Given that the UEFI subsystem is currently the only user of
#   create_mapping_late(), add an unconditional call to pgtable_page_ctor() to
#   late_alloc().
# 
#   Fixes: 9fc68b717c24 ("ARM/efi: Apply strict permissions for UEFI Runtime Services regions")
#   Signed-off-by: Ard Biesheuvel
#   Signed-off-by: Russell King
# 
#   61444cde9170e256c238a02c9a4861930db04f5f
#    arch/arm/mm/mmu.c | 3 ++-
#    1 file changed, 2 insertions(+), 1 deletion(-)
# 
# Author:    Nicolas Pitre (Thu 28 Jul 19:38:07 BST 2016)
# Committer: Russell King (Tue  9 Aug 22:57:40 BST 2016)
# 
#   ARM: 8590/1: sanity_check_meminfo(): avoid overflow on vmalloc_limit
# 
#   To limit the amount of mapped low memory, we determine a physical address
#   boundary based on the start of the vmalloc area using __pa().
#   Strictly speaking, the vmalloc area location is arbitrary and does not
#   necessarily corresponds to a valid physical address. For example, if
# 
#   	PAGE_OFFSET = 0x80000000
#   	PHYS_OFFSET = 0x90000000
#   	vmalloc_min = 0xf0000000
# 
#   then __pa(vmalloc_min) overflows and returns a wrapped 0 when phys_addr_t
#   is a 32-bit type. Then the code that follows determines that the entire
#   physical memory is above that boundary and no low memory gets mapped at
#   all:
# 
#   |[...]
#   |Machine model: Freescale i.MX51 NA04 Board
#   |Ignoring RAM at 0x90000000-0xb0000000 (!CONFIG_HIGHMEM)
#   |Consider using a HIGHMEM enabled kernel.
# 
#   To avoid this problem let's make vmalloc_limit a 64-bit value all the
#   time and determine that boundary explicitly without using __pa().
# 
#   Reported-by: Emil Renner Berthing
#   Signed-off-by: Nicolas Pitre
#   Tested-by: Emil Renner Berthing
#   Signed-off-by: Russell King
# 
#   b9a019899f61acca18df5fb5e38a8fcdfea86fcd
#    arch/arm/mm/mmu.c | 18 ++++++++++++++----
#    1 file changed, 14 insertions(+), 4 deletions(-)
# 
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 56ea5c60b318..6e30b8bc21b9 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -23,7 +23,6 @@ ifeq ($(CONFIG_ARM_MODULE_PLTS),y)
 LDFLAGS_MODULE	+= -T $(srctree)/arch/arm/kernel/module.lds
 endif
 
-OBJCOPYFLAGS	:=-O binary -R .comment -S
 GZFLAGS		:=-9
 #KBUILD_CFLAGS	+=-pipe
 
diff --git a/arch/arm/boot/Makefile b/arch/arm/boot/Makefile
index bdc1d5af03d2..50f8d1be7fcb 100644
--- a/arch/arm/boot/Makefile
+++ b/arch/arm/boot/Makefile
@@ -11,6 +11,8 @@
 # Copyright (C) 1995-2002 Russell King
 #
 
+OBJCOPYFLAGS	:=-O binary -R .comment -S
+
 ifneq ($(MACHINE),)
 include $(MACHINE)/Makefile.boot
 endif
diff --git a/arch/arm/include/asm/flat.h b/arch/arm/include/asm/flat.h
index e847d23351ed..acf1d14b89a6 100644
--- a/arch/arm/include/asm/flat.h
+++ b/arch/arm/include/asm/flat.h
@@ -8,8 +8,9 @@
 #define	flat_argvp_envp_on_stack()		1
 #define	flat_old_ram_flag(flags)		(flags)
 #define	flat_reloc_valid(reloc, size)		((reloc) <= (size))
-#define	flat_get_addr_from_rp(rp, relval, flags, persistent) ((void)persistent,get_unaligned(rp))
-#define	flat_put_addr_at_rp(rp, val, relval)	put_unaligned(val,rp)
+#define	flat_get_addr_from_rp(rp, relval, flags, persistent) \
+	({ unsigned long __val; __get_user_unaligned(__val, rp); __val; })
+#define	flat_put_addr_at_rp(rp, val, relval)	__put_user_unaligned(val, rp)
 #define	flat_get_relocate_addr(rel)		(rel)
 #define	flat_set_persistent(relval, p)		0
 
diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
index 31c07a2cc100..76cbd9c674df 100644
--- a/arch/arm/include/asm/memory.h
+++ b/arch/arm/include/asm/memory.h
@@ -159,13 +159,8 @@
  * PFNs are used to describe any physical page; this means
  * PFN 0 == physical address 0.
  */
-#if defined(__virt_to_phys)
-#define PHYS_OFFSET	PLAT_PHYS_OFFSET
-#define PHYS_PFN_OFFSET	((unsigned long)(PHYS_OFFSET >> PAGE_SHIFT))
-
-#define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT)
 
-#elif defined(CONFIG_ARM_PATCH_PHYS_VIRT)
+#if defined(CONFIG_ARM_PATCH_PHYS_VIRT)
 
 /*
  * Constants used to force the right instruction encodings and shifts
@@ -182,10 +177,6 @@ extern const void *__pv_table_begin, *__pv_table_end;
 #define PHYS_OFFSET	((phys_addr_t)__pv_phys_pfn_offset << PAGE_SHIFT)
 #define PHYS_PFN_OFFSET	(__pv_phys_pfn_offset)
 
-#define virt_to_pfn(kaddr) \
-	((((unsigned long)(kaddr) - PAGE_OFFSET) >> PAGE_SHIFT) + \
-	 PHYS_PFN_OFFSET)
-
 #define __pv_stub(from,to,instr,type)			\
 	__asm__("@ __pv_stub\n"				\
 	"1:	" instr "	%0, %1, %2\n"		\
@@ -257,12 +248,12 @@ static inline unsigned long __phys_to_virt(phys_addr_t x)
 	return x - PHYS_OFFSET + PAGE_OFFSET;
 }
 
+#endif
+
 #define virt_to_pfn(kaddr) \
 	((((unsigned long)(kaddr) - PAGE_OFFSET) >> PAGE_SHIFT) + \
 	 PHYS_PFN_OFFSET)
 
-#endif
-
 /*
  * These are *only* valid on the kernel direct mapped RAM memory.
  * Note: Drivers should NOT use these.  They are the wrong
diff --git a/arch/arm/kernel/cpuidle.c b/arch/arm/kernel/cpuidle.c
index 7dccc964d75f..a3308ad1a024 100644
--- a/arch/arm/kernel/cpuidle.c
+++ b/arch/arm/kernel/cpuidle.c
@@ -19,7 +19,7 @@ extern struct of_cpuidle_method __cpuidle_method_of_table[];
 static const struct of_cpuidle_method __cpuidle_method_of_table_sentinel
 	__used __section(__cpuidle_method_of_table_end);
 
-static struct cpuidle_ops cpuidle_ops[NR_CPUS];
+static struct cpuidle_ops cpuidle_ops[NR_CPUS] __ro_after_init;
 
 /**
  * arm_cpuidle_simple_enter() - a wrapper to cpu_do_idle()
diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
index bc5f50799d75..9f157e7c51e7 100644
--- a/arch/arm/kernel/entry-armv.S
+++ b/arch/arm/kernel/entry-armv.S
@@ -295,6 +295,7 @@ __und_svc_fault:
 	bl	__und_fault
 
 __und_svc_finish:
+	get_thread_info tsk
 	ldr	r5, [sp, #S_PSR]		@ Get SVC cpsr
 	svc_exit r5				@ return from exception
  UNWIND(.fnend		)
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index df7f2a75e769..aca999e17184 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -114,19 +114,19 @@ EXPORT_SYMBOL(elf_hwcap2);
 
 
 #ifdef MULTI_CPU
-struct processor processor __read_mostly;
+struct processor processor __ro_after_init;
 #endif
 #ifdef MULTI_TLB
-struct cpu_tlb_fns cpu_tlb __read_mostly;
+struct cpu_tlb_fns cpu_tlb __ro_after_init;
 #endif
 #ifdef MULTI_USER
-struct cpu_user_fns cpu_user __read_mostly;
+struct cpu_user_fns cpu_user __ro_after_init;
 #endif
 #ifdef MULTI_CACHE
-struct cpu_cache_fns cpu_cache __read_mostly;
+struct cpu_cache_fns cpu_cache __ro_after_init;
 #endif
 #ifdef CONFIG_OUTER_CACHE
-struct outer_cache_fns outer_cache __read_mostly;
+struct outer_cache_fns outer_cache __ro_after_init;
 EXPORT_SYMBOL(outer_cache);
 #endif
 
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index 861521606c6d..937c8920d741 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -82,7 +82,7 @@ enum ipi_msg_type {
 
 static DECLARE_COMPLETION(cpu_running);
 
-static struct smp_operations smp_ops;
+static struct smp_operations smp_ops __ro_after_init;
 
 void __init smp_set_ops(const struct smp_operations *ops)
 {
diff --git a/arch/arm/kernel/vdso.c b/arch/arm/kernel/vdso.c
index 994e971a8538..bbbffe946122 100644
--- a/arch/arm/kernel/vdso.c
+++ b/arch/arm/kernel/vdso.c
@@ -17,6 +17,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <linux/cache.h>
 #include <linux/elf.h>
 #include <linux/err.h>
 #include <linux/kernel.h>
@@ -39,7 +40,7 @@
 static struct page **vdso_text_pagelist;
 
 /* Total number of pages needed for the data and text portions of the VDSO. */
-unsigned int vdso_total_pages __read_mostly;
+unsigned int vdso_total_pages __ro_after_init;
 
 /*
  * The VDSO data page.
@@ -47,13 +48,13 @@ unsigned int vdso_total_pages __read_mostly;
 static union vdso_data_store vdso_data_store __page_aligned_data;
 static struct vdso_data *vdso_data = &vdso_data_store.data;
 
-static struct page *vdso_data_page;
-static struct vm_special_mapping vdso_data_mapping = {
+static struct page *vdso_data_page __ro_after_init;
+static const struct vm_special_mapping vdso_data_mapping = {
 	.name = "[vvar]",
 	.pages = &vdso_data_page,
 };
 
-static struct vm_special_mapping vdso_text_mapping = {
+static struct vm_special_mapping vdso_text_mapping __ro_after_init = {
 	.name = "[vdso]",
 };
 
@@ -67,7 +68,7 @@ struct elfinfo {
 /* Cached result of boot-time check for whether the arch timer exists,
  * and if so, whether the virtual counter is useable.
  */
-static bool cntvct_ok __read_mostly;
+static bool cntvct_ok __ro_after_init;
 
 static bool __init cntvct_functional(void)
 {
diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
index 8044591dca72..2cef11884857 100644
--- a/arch/arm/lib/delay.c
+++ b/arch/arm/lib/delay.c
@@ -29,7 +29,7 @@
 /*
  * Default to the loop-based delay implementation.
  */
-struct arm_delay_ops arm_delay_ops = {
+struct arm_delay_ops arm_delay_ops __ro_after_init = {
 	.delay		= __loop_delay,
 	.const_udelay	= __loop_const_udelay,
 	.udelay		= __loop_udelay,
diff --git a/arch/arm/mm/cache-l2x0.c b/arch/arm/mm/cache-l2x0.c
index cc12905ae6f8..ca5595fa072a 100644
--- a/arch/arm/mm/cache-l2x0.c
+++ b/arch/arm/mm/cache-l2x0.c
@@ -709,9 +709,8 @@ static void __init l2c310_fixup(void __iomem *base, u32 cache_id,
 	if (revision >= L310_CACHE_ID_RTL_R3P0 &&
 	    revision < L310_CACHE_ID_RTL_R3P2) {
 		u32 val = l2x0_saved_regs.prefetch_ctrl;
-		/* I don't think bit23 is required here... but iMX6 does so */
-		if (val & (BIT(30) | BIT(23))) {
-			val &= ~(BIT(30) | BIT(23));
+		if (val & L310_PREFETCH_CTRL_DBL_LINEFILL) {
+			val &= ~L310_PREFETCH_CTRL_DBL_LINEFILL;
 			l2x0_saved_regs.prefetch_ctrl = val;
 			errata[n++] = "752271";
 		}
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index c6834c0cfd1c..a2302aba5df2 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -436,7 +436,7 @@ static int __init atomic_pool_init(void)
 		gen_pool_set_algo(atomic_pool,
 				gen_pool_first_fit_order_align,
 				(void *)PAGE_SHIFT);
-		pr_info("DMA: preallocated %zd KiB pool for atomic coherent allocations\n",
+		pr_info("DMA: preallocated %zu KiB pool for atomic coherent allocations\n",
 		       atomic_pool_size / 1024);
 		return 0;
 	}
@@ -445,7 +445,7 @@ static int __init atomic_pool_init(void)
 	gen_pool_destroy(atomic_pool);
 	atomic_pool = NULL;
 out:
-	pr_err("DMA: failed to allocate %zx KiB pool for atomic coherent allocation\n",
+	pr_err("DMA: failed to allocate %zu KiB pool for atomic coherent allocation\n",
 	       atomic_pool_size / 1024);
 	return -ENOMEM;
 }
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index 62f4d01941f7..724d6be4b832 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -243,7 +243,7 @@ __setup("noalign", noalign_setup);
 #define PROT_PTE_S2_DEVICE	PROT_PTE_DEVICE
 #define PROT_SECT_DEVICE	PMD_TYPE_SECT|PMD_SECT_AP_WRITE
 
-static struct mem_type mem_types[] = {
+static struct mem_type mem_types[] __ro_after_init = {
 	[MT_DEVICE] = {		  /* Strongly ordered / ARMv6 shared device */
 		.prot_pte	= PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
 				  L_PTE_SHARED,
@@ -728,7 +728,8 @@ static void *__init late_alloc(unsigned long sz)
 {
 	void *ptr = (void *)__get_free_pages(PGALLOC_GFP, get_order(sz));
 
-	BUG_ON(!ptr);
+	if (!ptr || !pgtable_page_ctor(virt_to_page(ptr)))
+		BUG();
 	return ptr;
 }
 
@@ -1155,10 +1156,19 @@ void __init sanity_check_meminfo(void)
 {
 	phys_addr_t memblock_limit = 0;
 	int highmem = 0;
-	phys_addr_t vmalloc_limit = __pa(vmalloc_min - 1) + 1;
+	u64 vmalloc_limit;
 	struct memblock_region *reg;
 	bool should_use_highmem = false;
 
+	/*
+	 * Let's use our own (unoptimized) equivalent of __pa() that is
+	 * not affected by wrap-arounds when sizeof(phys_addr_t) == 4.
+	 * The result is used as the upper bound on physical memory address
+	 * and may itself be outside the valid range for which phys_addr_t
+	 * and therefore __pa() is defined.
+	 */
+	vmalloc_limit = (u64)(uintptr_t)vmalloc_min - PAGE_OFFSET + PHYS_OFFSET;
+
 	for_each_memblock(memory, reg) {
 		phys_addr_t block_start = reg->base;
 		phys_addr_t block_end = reg->base + reg->size;
@@ -1183,10 +1193,11 @@ void __init sanity_check_meminfo(void)
 			if (reg->size > size_limit) {
 				phys_addr_t overlap_size = reg->size - size_limit;
 
-				pr_notice("Truncating RAM at %pa-%pa to -%pa",
-					  &block_start, &block_end, &vmalloc_limit);
-				memblock_remove(vmalloc_limit, overlap_size);
+				pr_notice("Truncating RAM at %pa-%pa",
+					  &block_start, &block_end);
 				block_end = vmalloc_limit;
+				pr_cont(" to -%pa", &block_end);
+				memblock_remove(vmalloc_limit, overlap_size);
 				should_use_highmem = true;
 			}
 		}
diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index a5b5c87e2114..a56fa2a1e9aa 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -19,6 +19,7 @@
 #include <linux/amba/bus.h>
 #include <linux/sizes.h>
 #include <linux/limits.h>
+#include <linux/clk/clk-conf.h>
 
 #include <asm/irq.h>
 
@@ -237,6 +238,10 @@ static int amba_probe(struct device *dev)
 	int ret;
 
 	do {
+		ret = of_clk_set_defaults(dev->of_node, false);
+		if (ret < 0)
+			break;
+
 		ret = dev_pm_domain_attach(dev, true);
 		if (ret == -EPROBE_DEFER)
 			break;
diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
index c7efddf6e038..4c09d93d9569 100644
--- a/fs/Kconfig.binfmt
+++ b/fs/Kconfig.binfmt
@@ -89,7 +89,7 @@ config BINFMT_SCRIPT
 
 config BINFMT_FLAT
 	bool "Kernel support for flat binaries"
-	depends on !MMU || M68K
+	depends on !MMU || ARM || M68K
 	depends on !FRV || BROKEN
 	help
 	  Support uClinux FLAT format binaries.
