Merge branch 'linux-linaro-lsk-v4.4' into linux-linaro-lsk-v4.4-android
authorAlex Shi <alex.shi@linaro.org>
Tue, 11 Jul 2017 06:21:20 +0000 (14:21 +0800)
committerAlex Shi <alex.shi@linaro.org>
Tue, 11 Jul 2017 08:22:22 +0000 (16:22 +0800)
Conflicts:
arch/arm64/kernel/armv8_deprecated.c
arch/arm64/kernel/efi.c
arch/arm64/kernel/entry.S
arch/arm64/kernel/head.S
arch/arm64/kernel/hw_breakpoint.c
arch/arm64/mm/mmu.c
include/linux/memblock.h
mm/memblock.c

44 files changed:
1  2 
Documentation/kernel-parameters.txt
Makefile
arch/arm/mm/mmap.c
arch/arm64/Kconfig
arch/arm64/include/asm/barrier.h
arch/arm64/include/asm/uaccess.h
arch/arm64/include/asm/virt.h
arch/arm64/kernel/Makefile
arch/arm64/kernel/armv8_deprecated.c
arch/arm64/kernel/asm-offsets.c
arch/arm64/kernel/cpufeature.c
arch/arm64/kernel/efi.c
arch/arm64/kernel/entry.S
arch/arm64/kernel/head.S
arch/arm64/kernel/hibernate.c
arch/arm64/kernel/hw_breakpoint.c
arch/arm64/kernel/setup.c
arch/arm64/mm/init.c
arch/arm64/mm/mmu.c
arch/arm64/mm/pageattr.c
arch/mips/mm/mmap.c
arch/sparc/kernel/sys_sparc_64.c
drivers/cpufreq/cpufreq.c
drivers/of/fdt.c
fs/exec.c
fs/ext4/inode.c
fs/mpage.c
fs/proc/base.c
fs/proc/task_mmu.c
include/linux/fs.h
include/linux/mm.h
kernel/cpuset.c
kernel/events/core.c
kernel/fork.c
kernel/time/timekeeping.c
mm/mmap.c
mm/page_alloc.c
net/ipv4/af_inet.c
net/ipv6/addrconf.c
net/ipv6/datagram.c
net/ipv6/ping.c
net/ipv6/raw.c
net/ipv6/tcp_ipv6.c
net/ipv6/udp.c

Simple merge
diff --cc Makefile
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
index 884b317e56c35958f498e4d7dd2e0253afcde23f,d03e311b6f3caff37cfc759c37caa0163e4d6fe3..373a80e9ed67b6ff13ffb0ff7e718d52a5e91e36
@@@ -298,11 -299,12 +298,12 @@@ do {                                                            
        "       .popsection"                                    \
        _ASM_EXTABLE(0b, 4b)                                    \
        _ASM_EXTABLE(1b, 4b)                                    \
 -      ALTERNATIVE("nop", SET_PSTATE_PAN(1), ARM64_HAS_PAN,    \
 -              CONFIG_ARM64_PAN)                               \
        : "=&r" (res), "+r" (data), "=&r" (temp)                \
-       : "r" (addr), "i" (-EAGAIN), "i" (-EFAULT)              \
-       : "memory");                                            \
+       : "r" ((unsigned long)addr), "i" (-EAGAIN),             \
+         "i" (-EFAULT)                                         \
+       : "memory")
 +      uaccess_disable();                                      \
 +} while (0)
  
  #define __user_swp_asm(data, addr, res, temp) \
        __user_swpX_asm(data, addr, res, temp, "")
Simple merge
Simple merge
index b6abc852f2a142123150662bc6dd6bf5c3de62af,40270c1fa947376c955ae4f66f9b23e8aa98a999..b60da856fc196564778f3e001187f45bd3a2eaf6
   *
   */
  
 -#include <linux/atomic.h>
  #include <linux/dmi.h>
  #include <linux/efi.h>
 -#include <linux/export.h>
 -#include <linux/memblock.h>
 -#include <linux/mm_types.h>
 -#include <linux/bootmem.h>
 -#include <linux/of.h>
 -#include <linux/of_fdt.h>
 -#include <linux/preempt.h>
 -#include <linux/rbtree.h>
 -#include <linux/rwsem.h>
 -#include <linux/sched.h>
 -#include <linux/slab.h>
 -#include <linux/spinlock.h>
 +#include <linux/init.h>
  
 -#include <asm/cacheflush.h>
  #include <asm/efi.h>
 -#include <asm/tlbflush.h>
 -#include <asm/mmu_context.h>
 -#include <asm/mmu.h>
 -#include <asm/pgtable.h>
  
 -struct efi_memory_map memmap;
 -
 -static u64 efi_system_table;
 -
 -static pgd_t efi_pgd[PTRS_PER_PGD] __page_aligned_bss;
 -
 -static struct mm_struct efi_mm = {
 -      .mm_rb                  = RB_ROOT,
 -      .pgd                    = efi_pgd,
 -      .mm_users               = ATOMIC_INIT(2),
 -      .mm_count               = ATOMIC_INIT(1),
 -      .mmap_sem               = __RWSEM_INITIALIZER(efi_mm.mmap_sem),
 -      .page_table_lock        = __SPIN_LOCK_UNLOCKED(efi_mm.page_table_lock),
 -      .mmlist                 = LIST_HEAD_INIT(efi_mm.mmlist),
 -};
 -
 -static int __init is_normal_ram(efi_memory_desc_t *md)
 -{
 -      if (md->attribute & EFI_MEMORY_WB)
 -              return 1;
 -      return 0;
 -}
 -
 -/*
 - * Translate a EFI virtual address into a physical address: this is necessary,
 - * as some data members of the EFI system table are virtually remapped after
 - * SetVirtualAddressMap() has been called.
 - */
 -static phys_addr_t efi_to_phys(unsigned long addr)
 +int __init efi_create_mapping(struct mm_struct *mm, efi_memory_desc_t *md)
  {
 -      efi_memory_desc_t *md;
 -
 -      for_each_efi_memory_desc(&memmap, md) {
 -              if (!(md->attribute & EFI_MEMORY_RUNTIME))
 -                      continue;
 -              if (md->virt_addr == 0)
 -                      /* no virtual mapping has been installed by the stub */
 -                      break;
 -              if (md->virt_addr <= addr &&
 -                  (addr - md->virt_addr) < (md->num_pages << EFI_PAGE_SHIFT))
 -                      return md->phys_addr + addr - md->virt_addr;
 -      }
 -      return addr;
 -}
 -
 -static int __init uefi_init(void)
 -{
 -      efi_char16_t *c16;
 -      void *config_tables;
 -      u64 table_size;
 -      char vendor[100] = "unknown";
 -      int i, retval;
 -
 -      efi.systab = early_memremap(efi_system_table,
 -                                  sizeof(efi_system_table_t));
 -      if (efi.systab == NULL) {
 -              pr_warn("Unable to map EFI system table.\n");
 -              return -ENOMEM;
 -      }
 -
 -      set_bit(EFI_BOOT, &efi.flags);
 -      set_bit(EFI_64BIT, &efi.flags);
 +      pteval_t prot_val;
  
        /*
 -       * Verify the EFI Table
 +       * Only regions of type EFI_RUNTIME_SERVICES_CODE need to be
 +       * executable, everything else can be mapped with the XN bits
 +       * set.
         */
 -      if (efi.systab->hdr.signature != EFI_SYSTEM_TABLE_SIGNATURE) {
 -              pr_err("System table signature incorrect\n");
 -              retval = -EINVAL;
 -              goto out;
 -      }
 -      if ((efi.systab->hdr.revision >> 16) < 2)
 -              pr_warn("Warning: EFI system table version %d.%02d, expected 2.00 or greater\n",
 -                      efi.systab->hdr.revision >> 16,
 -                      efi.systab->hdr.revision & 0xffff);
 -
 -      /* Show what we know for posterity */
 -      c16 = early_memremap(efi_to_phys(efi.systab->fw_vendor),
 -                           sizeof(vendor) * sizeof(efi_char16_t));
 -      if (c16) {
 -              for (i = 0; i < (int) sizeof(vendor) - 1 && *c16; ++i)
 -                      vendor[i] = c16[i];
 -              vendor[i] = '\0';
 -              early_memunmap(c16, sizeof(vendor) * sizeof(efi_char16_t));
 -      }
 -
 -      pr_info("EFI v%u.%.02u by %s\n",
 -              efi.systab->hdr.revision >> 16,
 -              efi.systab->hdr.revision & 0xffff, vendor);
 -
 -      table_size = sizeof(efi_config_table_64_t) * efi.systab->nr_tables;
 -      config_tables = early_memremap(efi_to_phys(efi.systab->tables),
 -                                     table_size);
 -      if (config_tables == NULL) {
 -              pr_warn("Unable to map EFI config table array.\n");
 -              retval = -ENOMEM;
 -              goto out;
 -      }
 -      retval = efi_config_parse_tables(config_tables, efi.systab->nr_tables,
 -                                       sizeof(efi_config_table_64_t), NULL);
 -
 -      early_memunmap(config_tables, table_size);
 -out:
 -      early_memunmap(efi.systab,  sizeof(efi_system_table_t));
 -      return retval;
 -}
 -
 -/*
 - * Return true for RAM regions we want to permanently reserve.
 - */
 -static __init int is_reserve_region(efi_memory_desc_t *md)
 -{
 -      switch (md->type) {
 -      case EFI_LOADER_CODE:
 -      case EFI_LOADER_DATA:
 -      case EFI_BOOT_SERVICES_CODE:
 -      case EFI_BOOT_SERVICES_DATA:
 -      case EFI_CONVENTIONAL_MEMORY:
 -      case EFI_PERSISTENT_MEMORY:
 -              return 0;
 -      default:
 -              break;
 -      }
 -      return is_normal_ram(md);
 -}
 -
 -static __init void reserve_regions(void)
 -{
 -      efi_memory_desc_t *md;
 -      u64 paddr, npages, size;
 -
 -      if (efi_enabled(EFI_DBG))
 -              pr_info("Processing EFI memory map:\n");
 -
 -      for_each_efi_memory_desc(&memmap, md) {
 -              paddr = md->phys_addr;
 -              npages = md->num_pages;
 -
 -              if (efi_enabled(EFI_DBG)) {
 -                      char buf[64];
 -
 -                      pr_info("  0x%012llx-0x%012llx %s",
 -                              paddr, paddr + (npages << EFI_PAGE_SHIFT) - 1,
 -                              efi_md_typeattr_format(buf, sizeof(buf), md));
 -              }
 -
 -              memrange_efi_to_native(&paddr, &npages);
 -              size = npages << PAGE_SHIFT;
 -
 -              if (is_normal_ram(md))
 -                      early_init_dt_add_memory_arch(paddr, size);
 -
 -              if (is_reserve_region(md)) {
 -                      memblock_reserve(paddr, size);
 -                      if (efi_enabled(EFI_DBG))
 -                              pr_cont("*");
 -              }
 -
 -              if (efi_enabled(EFI_DBG))
 -                      pr_cont("\n");
 -      }
 -
 -      set_bit(EFI_MEMMAP, &efi.flags);
 -}
 -
 -void __init efi_init(void)
 -{
 -      struct efi_fdt_params params;
 -
 -      /* Grab UEFI information placed in FDT by stub */
 -      if (!efi_get_fdt_params(&params))
 -              return;
 -
 -      efi_system_table = params.system_table;
 -
 -      memblock_reserve(params.mmap & PAGE_MASK,
 -                       PAGE_ALIGN(params.mmap_size + (params.mmap & ~PAGE_MASK)));
 -      memmap.phys_map = params.mmap;
 -      memmap.map = early_memremap(params.mmap, params.mmap_size);
 -      if (memmap.map == NULL) {
 -              /*
 -              * If we are booting via UEFI, the UEFI memory map is the only
 -              * description of memory we have, so there is little point in
 -              * proceeding if we cannot access it.
 -              */
 -              panic("Unable to map EFI memory map.\n");
 -      }
 -      memmap.map_end = memmap.map + params.mmap_size;
 -      memmap.desc_size = params.desc_size;
 -      memmap.desc_version = params.desc_ver;
 -
 -      if (uefi_init() < 0)
 -              return;
 -
 -      reserve_regions();
 -      early_memunmap(memmap.map, params.mmap_size);
 -}
 -
 -static bool __init efi_virtmap_init(void)
 -{
 -      efi_memory_desc_t *md;
 -
 -      init_new_context(NULL, &efi_mm);
 -
 -      for_each_efi_memory_desc(&memmap, md) {
 -              pgprot_t prot;
 -
 -              if (!(md->attribute & EFI_MEMORY_RUNTIME))
 -                      continue;
 -              if (md->virt_addr == 0)
 -                      return false;
 -
 -              pr_info("  EFI remap 0x%016llx => %p\n",
 -                      md->phys_addr, (void *)md->virt_addr);
 -
 -              /*
 -               * Only regions of type EFI_RUNTIME_SERVICES_CODE need to be
 -               * executable, everything else can be mapped with the XN bits
 -               * set.
 -               */
 -              if (!is_normal_ram(md))
 -                      prot = __pgprot(PROT_DEVICE_nGnRE);
 -              else if (md->type == EFI_RUNTIME_SERVICES_CODE ||
 -                       !PAGE_ALIGNED(md->phys_addr))
 -                      prot = PAGE_KERNEL_EXEC;
 -              else
 -                      prot = PAGE_KERNEL;
 -
 -              create_pgd_mapping(&efi_mm, md->phys_addr, md->virt_addr,
 -                                 md->num_pages << EFI_PAGE_SHIFT, 
 -                                 __pgprot(pgprot_val(prot) | PTE_NG), true);
 -      }
 -      return true;
 -}
 -
 -/*
 - * Enable the UEFI Runtime Services if all prerequisites are in place, i.e.,
 - * non-early mapping of the UEFI system table and virtual mappings for all
 - * EFI_MEMORY_RUNTIME regions.
 - */
 -static int __init arm64_enable_runtime_services(void)
 -{
 -      u64 mapsize;
 -
 -      if (!efi_enabled(EFI_BOOT)) {
 -              pr_info("EFI services will not be available.\n");
 -              return 0;
 -      }
 -
 -      if (efi_runtime_disabled()) {
 -              pr_info("EFI runtime services will be disabled.\n");
 -              return 0;
 -      }
 -
 -      pr_info("Remapping and enabling EFI services.\n");
 -
 -      mapsize = memmap.map_end - memmap.map;
 -      memmap.map = (__force void *)ioremap_cache(memmap.phys_map,
 -                                                 mapsize);
 -      if (!memmap.map) {
 -              pr_err("Failed to remap EFI memory map\n");
 -              return -ENOMEM;
 -      }
 -      memmap.map_end = memmap.map + mapsize;
 -      efi.memmap = &memmap;
 -
 -      efi.systab = (__force void *)ioremap_cache(efi_system_table,
 -                                                 sizeof(efi_system_table_t));
 -      if (!efi.systab) {
 -              pr_err("Failed to remap EFI System Table\n");
 -              return -ENOMEM;
 -      }
 -      set_bit(EFI_SYSTEM_TABLES, &efi.flags);
 -
 -      if (!efi_virtmap_init()) {
 -              pr_err("No UEFI virtual mapping was installed -- runtime services will not be available\n");
 -              return -ENOMEM;
 -      }
 -
 -      /* Set up runtime services function pointers */
 -      efi_native_runtime_setup();
 -      set_bit(EFI_RUNTIME_SERVICES, &efi.flags);
 -
 -      efi.runtime_version = efi.systab->hdr.revision;
 -
 +      if ((md->attribute & EFI_MEMORY_WB) == 0)
 +              prot_val = PROT_DEVICE_nGnRE;
 +      else if (md->type == EFI_RUNTIME_SERVICES_CODE ||
 +               !PAGE_ALIGNED(md->phys_addr))
 +              prot_val = pgprot_val(PAGE_KERNEL_EXEC);
 +      else
 +              prot_val = pgprot_val(PAGE_KERNEL);
 +
 +      create_pgd_mapping(mm, md->phys_addr, md->virt_addr,
 +                         md->num_pages << EFI_PAGE_SHIFT,
-                          __pgprot(prot_val | PTE_NG));
++                         __pgprot(prot_val | PTE_NG), true);
        return 0;
  }
 -early_initcall(arm64_enable_runtime_services);
  
  static int __init arm64_dmi_init(void)
  {
index ccac06a9f20403b110e5d6d883759bd70243ada0,6f69650c8b7b6173cc92bbf4217de0cd43d7cbad..5472cedfe750ac4a5274191285ec7fe8a438e9a1
  #include <asm/esr.h>
  #include <asm/irq.h>
  #include <asm/memory.h>
 +#include <asm/ptrace.h>
  #include <asm/thread_info.h>
 +#include <asm/uaccess.h>
+ #include <asm/asm-uaccess.h>
  #include <asm/unistd.h>
  
  /*
index 6d9d36a42967435f32b47fccd63a37fc4ac3a75b,6c5595928169668aa47860cae3b854f82f64ed7f..bf6332d4b6d3c532c3a7e8e1a1f0b51ce70f9f57
@@@ -601,13 -595,8 +602,7 @@@ ENDPROC(set_cpu_boot_mode_flag
  ENTRY(__boot_cpu_mode)
        .long   BOOT_CPU_MODE_EL2
        .long   BOOT_CPU_MODE_EL1
- /*
-  * The booting CPU updates the failed status @__early_cpu_boot_status,
-  * with MMU turned off.
-  */
- ENTRY(__early_cpu_boot_status)
-       .long   0
 +
        .popsection
  
        /*
index 1edfeb9f001d7780f140abddf6294343a9edfb87,35a33d705536e9127cad03e0b4d8f3040883ded9..4284ced551fed903bcc16f988ab51e9d8fe175b6
@@@ -245,16 -252,17 +247,22 @@@ int swsusp_arch_suspend(void
        local_dbg_save(flags);
  
        if (__cpu_suspend_enter(&state)) {
+               /* make the crash dump kernel image visible/saveable */
+               crash_prepare_suspend();
                ret = swsusp_save();
        } else {
 -              /* Clean kernel to PoC for secondary core startup */
 -              __flush_dcache_area(LMADDR(KERNEL_START), KERNEL_END - KERNEL_START);
 +              /* Clean kernel core startup/idle code to PoC*/
 +              dcache_clean_range(__mmuoff_data_start, __mmuoff_data_end);
 +              dcache_clean_range(__idmap_text_start, __idmap_text_end);
 +
 +              /* Clean kvm setup code to PoC? */
 +              if (el2_reset_needed())
 +                      dcache_clean_range(__hyp_idmap_text_start, __hyp_idmap_text_end);
  
+               /* make the crash dump kernel image protected again */
+               crash_post_resume();
                /*
                 * Tell the hibernation core that we've just restored
                 * the memory
Simple merge
Simple merge
Simple merge
index 1cab2703f5a87e7074dbdbe8c932ff2317cf4bfe,d23342804230ac53ebc9eb9b030b5831bf6602ce..2d2b6643a31e32460c8d7548100db8e0ada85f21
@@@ -380,13 -367,22 +367,22 @@@ static void create_mapping_late(phys_ad
        }
  
        __create_pgd_mapping(init_mm.pgd, phys, virt, size, prot,
-                            late_pgtable_alloc);
+                            late_pgtable_alloc, !debug_pagealloc_enabled());
  }
  
- static void __init __map_memblock(pgd_t *pgd, phys_addr_t start, phys_addr_t end)
+ static void __init __map_memblock(pgd_t *pgd, phys_addr_t start,
+                                 phys_addr_t end, pgprot_t prot,
+                                 bool allow_block_mappings)
+ {
+       __create_pgd_mapping(pgd, start, __phys_to_virt(start), end - start,
+                            prot, early_pgtable_alloc, allow_block_mappings);
+ }
+ static void __init map_mem(pgd_t *pgd)
  {
        unsigned long kernel_start = __pa(_text);
 -      unsigned long kernel_end = __pa(_etext);
 +      unsigned long kernel_end = __pa(__init_begin);
+       struct memblock_region *reg;
  
        /*
         * Take care not to create a writable alias for the
                if (memblock_is_nomap(reg))
                        continue;
  
-               __map_memblock(pgd, start, end);
+               __map_memblock(pgd, start, end,
+                              PAGE_KERNEL, !debug_pagealloc_enabled());
        }
 -       * Map the linear alias of the [_text, _etext) interval as
+       /*
++       * Map the linear alias of the [_text, __init_begin) interval as
+        * read-only/non-executable. This makes the contents of the
+        * region accessible to subsystems such as hibernate, but
+        * protects it from inadvertent modification or execution.
+        */
+       __map_memblock(pgd, kernel_start, kernel_end,
+                      PAGE_KERNEL_RO, !debug_pagealloc_enabled());
+       memblock_clear_nomap(kernel_start, kernel_end - kernel_start);
+ #ifdef CONFIG_KEXEC_CORE
+       /*
+        * Use page-level mappings here so that we can shrink the region
+        * in page granularity and put back unused memory to buddy system
+        * through /sys/kernel/kexec_crash_size interface.
+        */
+       if (crashk_res.end) {
+               __map_memblock(pgd, crashk_res.start, crashk_res.end + 1,
+                              PAGE_KERNEL, false);
+               memblock_clear_nomap(crashk_res.start,
+                                    resource_size(&crashk_res));
+       }
+ #endif
  }
  
  void mark_rodata_ro(void)
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc fs/exec.c
Simple merge
diff --cc fs/ext4/inode.c
Simple merge
diff --cc fs/mpage.c
Simple merge
diff --cc fs/proc/base.c
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc kernel/cpuset.c
Simple merge
Simple merge
diff --cc kernel/fork.c
Simple merge
Simple merge
diff --cc mm/mmap.c
Simple merge
diff --cc mm/page_alloc.c
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc net/ipv6/ping.c
Simple merge
diff --cc net/ipv6/raw.c
Simple merge
Simple merge
diff --cc net/ipv6/udp.c
Simple merge