Magellan Linux

Diff of /trunk/kernel-magellan/patches-3.15/0109-3.15.10-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2495 by niro, Thu Sep 4 19:55:35 2014 UTC revision 2496 by niro, Thu Sep 4 20:16:04 2014 UTC
# Line 1  Line 1 
 diff --git a/Documentation/x86/x86_64/mm.txt b/Documentation/x86/x86_64/mm.txt  
 index c584a51add15..afe68ddbe6a4 100644  
 --- a/Documentation/x86/x86_64/mm.txt  
 +++ b/Documentation/x86/x86_64/mm.txt  
 @@ -12,6 +12,8 @@ ffffc90000000000 - ffffe8ffffffffff (=45 bits) vmalloc/ioremap space  
  ffffe90000000000 - ffffe9ffffffffff (=40 bits) hole  
  ffffea0000000000 - ffffeaffffffffff (=40 bits) virtual memory map (1TB)  
  ... unused hole ...  
 +ffffff0000000000 - ffffff7fffffffff (=39 bits) %esp fixup stacks  
 +... unused hole ...  
  ffffffff80000000 - ffffffffa0000000 (=512 MB)  kernel text mapping, from phys 0  
  ffffffffa0000000 - ffffffffff5fffff (=1525 MB) module mapping space  
  ffffffffff600000 - ffffffffffdfffff (=8 MB) vsyscalls  
1  diff --git a/Makefile b/Makefile  diff --git a/Makefile b/Makefile
2  index d5d9a22a404a..25b85aba1e2e 100644  index 25b85aba1e2e..76b75f7b8485 100644
3  --- a/Makefile  --- a/Makefile
4  +++ b/Makefile  +++ b/Makefile
5  @@ -1,6 +1,6 @@  @@ -1,6 +1,6 @@
6   VERSION = 3   VERSION = 3
7   PATCHLEVEL = 15   PATCHLEVEL = 15
8  -SUBLEVEL = 8  -SUBLEVEL = 9
9  +SUBLEVEL = 9  +SUBLEVEL = 10
10   EXTRAVERSION =   EXTRAVERSION =
11   NAME = Double Funky Skunk   NAME = Double Funky Skunk
12    
13  diff --git a/arch/arm/boot/dts/dra7-evm.dts b/arch/arm/boot/dts/dra7-evm.dts  diff --git a/arch/sparc/include/asm/tlbflush_64.h b/arch/sparc/include/asm/tlbflush_64.h
14  index 5babba0a3a75..904dcf5973f3 100644  index 3c3c89f52643..7f9bab26a499 100644
15  --- a/arch/arm/boot/dts/dra7-evm.dts  --- a/arch/sparc/include/asm/tlbflush_64.h
16  +++ b/arch/arm/boot/dts/dra7-evm.dts  +++ b/arch/sparc/include/asm/tlbflush_64.h
17  @@ -182,6 +182,7 @@  @@ -34,6 +34,8 @@ static inline void flush_tlb_range(struct vm_area_struct *vma,
18   regulator-name = "ldo3";   {
  regulator-min-microvolt = <1800000>;  
  regulator-max-microvolt = <1800000>;  
 + regulator-always-on;  
  regulator-boot-on;  
  };  
   
 diff --git a/arch/arm/boot/dts/hi3620.dtsi b/arch/arm/boot/dts/hi3620.dtsi  
 index ab1116d086be..83a5b8685bd9 100644  
 --- a/arch/arm/boot/dts/hi3620.dtsi  
 +++ b/arch/arm/boot/dts/hi3620.dtsi  
 @@ -73,7 +73,7 @@  
   
  L2: l2-cache {  
  compatible = "arm,pl310-cache";  
 - reg = <0xfc10000 0x100000>;  
 + reg = <0x100000 0x100000>;  
  interrupts = <0 15 4>;  
  cache-unified;  
  cache-level = <2>;  
 diff --git a/arch/arm/crypto/aesbs-glue.c b/arch/arm/crypto/aesbs-glue.c  
 index 4522366da759..15468fbbdea3 100644  
 --- a/arch/arm/crypto/aesbs-glue.c  
 +++ b/arch/arm/crypto/aesbs-glue.c  
 @@ -137,7 +137,7 @@ static int aesbs_cbc_encrypt(struct blkcipher_desc *desc,  
  dst += AES_BLOCK_SIZE;  
  } while (--blocks);  
  }  
 - err = blkcipher_walk_done(desc, &walk, 0);  
 + err = blkcipher_walk_done(desc, &walk, walk.nbytes % AES_BLOCK_SIZE);  
  }  
  return err;  
  }  
 @@ -158,7 +158,7 @@ static int aesbs_cbc_decrypt(struct blkcipher_desc *desc,  
  bsaes_cbc_encrypt(walk.src.virt.addr, walk.dst.virt.addr,  
   walk.nbytes, &ctx->dec, walk.iv);  
  kernel_neon_end();  
 - err = blkcipher_walk_done(desc, &walk, 0);  
 + err = blkcipher_walk_done(desc, &walk, walk.nbytes % AES_BLOCK_SIZE);  
  }  
  while (walk.nbytes) {  
  u32 blocks = walk.nbytes / AES_BLOCK_SIZE;  
 @@ -182,7 +182,7 @@ static int aesbs_cbc_decrypt(struct blkcipher_desc *desc,  
  dst += AES_BLOCK_SIZE;  
  src += AES_BLOCK_SIZE;  
  } while (--blocks);  
 - err = blkcipher_walk_done(desc, &walk, 0);  
 + err = blkcipher_walk_done(desc, &walk, walk.nbytes % AES_BLOCK_SIZE);  
  }  
  return err;  
  }  
 @@ -268,7 +268,7 @@ static int aesbs_xts_encrypt(struct blkcipher_desc *desc,  
  bsaes_xts_encrypt(walk.src.virt.addr, walk.dst.virt.addr,  
   walk.nbytes, &ctx->enc, walk.iv);  
  kernel_neon_end();  
 - err = blkcipher_walk_done(desc, &walk, 0);  
 + err = blkcipher_walk_done(desc, &walk, walk.nbytes % AES_BLOCK_SIZE);  
  }  
  return err;  
  }  
 @@ -292,7 +292,7 @@ static int aesbs_xts_decrypt(struct blkcipher_desc *desc,  
  bsaes_xts_decrypt(walk.src.virt.addr, walk.dst.virt.addr,  
   walk.nbytes, &ctx->dec, walk.iv);  
  kernel_neon_end();  
 - err = blkcipher_walk_done(desc, &walk, 0);  
 + err = blkcipher_walk_done(desc, &walk, walk.nbytes % AES_BLOCK_SIZE);  
  }  
  return err;  
19   }   }
 diff --git a/arch/arm/mach-omap2/gpmc-nand.c b/arch/arm/mach-omap2/gpmc-nand.c  
 index 17cd39360afe..93914d220069 100644  
 --- a/arch/arm/mach-omap2/gpmc-nand.c  
 +++ b/arch/arm/mach-omap2/gpmc-nand.c  
 @@ -50,6 +50,16 @@ static bool gpmc_hwecc_bch_capable(enum omap_ecc ecc_opt)  
  soc_is_omap54xx() || soc_is_dra7xx())  
  return 1;  
   
 + if (ecc_opt == OMAP_ECC_BCH4_CODE_HW_DETECTION_SW ||  
 + ecc_opt == OMAP_ECC_BCH8_CODE_HW_DETECTION_SW) {  
 + if (cpu_is_omap24xx())  
 + return 0;  
 + else if (cpu_is_omap3630() && (GET_OMAP_REVISION() == 0))  
 + return 0;  
 + else  
 + return 1;  
 + }  
 +  
  /* OMAP3xxx do not have ELM engine, so cannot support ECC schemes  
  * which require H/W based ECC error detection */  
  if ((cpu_is_omap34xx() || cpu_is_omap3630()) &&  
 @@ -57,14 +67,6 @@ static bool gpmc_hwecc_bch_capable(enum omap_ecc ecc_opt)  
  (ecc_opt == OMAP_ECC_BCH8_CODE_HW)))  
  return 0;  
20    
21  - /*  +void flush_tlb_kernel_range(unsigned long start, unsigned long end);
22  - * For now, assume 4-bit mode is only supported on OMAP3630 ES1.x, x>=1  +
23  - * and AM33xx derivates. Other chips may be added if confirmed to work.   #define __HAVE_ARCH_ENTER_LAZY_MMU_MODE
 - */  
 - if ((ecc_opt == OMAP_ECC_BCH4_CODE_HW_DETECTION_SW) &&  
 -    (!cpu_is_omap3630() || (GET_OMAP_REVISION() == 0)))  
 - return 0;  
 -  
  /* legacy platforms support only HAM1 (1-bit Hamming) ECC scheme */  
  if (ecc_opt == OMAP_ECC_HAM1_CODE_HW)  
  return 1;  
 diff --git a/arch/arm/mm/idmap.c b/arch/arm/mm/idmap.c  
 index 8e0e52eb76b5..d7a0ee898d24 100644  
 --- a/arch/arm/mm/idmap.c  
 +++ b/arch/arm/mm/idmap.c  
 @@ -25,6 +25,13 @@ static void idmap_add_pmd(pud_t *pud, unsigned long addr, unsigned long end,  
  pr_warning("Failed to allocate identity pmd.\n");  
  return;  
  }  
 + /*  
 + * Copy the original PMD to ensure that the PMD entries for  
 + * the kernel image are preserved.  
 + */  
 + if (!pud_none(*pud))  
 + memcpy(pmd, pmd_offset(pud, 0),  
 +       PTRS_PER_PMD * sizeof(pmd_t));  
  pud_populate(&init_mm, pud, pmd);  
  pmd += pmd_index(addr);  
  } else  
 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c  
 index b68c6b22e1c8..f15c22e8bcd5 100644  
 --- a/arch/arm/mm/mmu.c  
 +++ b/arch/arm/mm/mmu.c  
 @@ -1436,8 +1436,8 @@ void __init early_paging_init(const struct machine_desc *mdesc,  
  return;  
   
  /* remap kernel code and data */  
 - map_start = init_mm.start_code;  
 - map_end   = init_mm.brk;  
 + map_start = init_mm.start_code & PMD_MASK;  
 + map_end   = ALIGN(init_mm.brk, PMD_SIZE);  
   
  /* get a handle on things... */  
  pgd0 = pgd_offset_k(0);  
 @@ -1472,7 +1472,7 @@ void __init early_paging_init(const struct machine_desc *mdesc,  
  }  
   
  /* remap pmds for kernel mapping */  
 - phys = __pa(map_start) & PMD_MASK;  
 + phys = __pa(map_start);  
  do {  
  *pmdk++ = __pmd(phys | pmdprot);  
  phys += PMD_SIZE;  
 diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c  
 index 6b0641c3f03f..fe52db2eea6a 100644  
 --- a/arch/powerpc/perf/core-book3s.c  
 +++ b/arch/powerpc/perf/core-book3s.c  
 @@ -1307,6 +1307,9 @@ static void power_pmu_enable(struct pmu *pmu)  
   out_enable:  
  pmao_restore_workaround(ebb);  
   
 + if (ppmu->flags & PPMU_ARCH_207S)  
 + mtspr(SPRN_MMCR2, 0);  
 +  
  mmcr0 = ebb_switch_in(ebb, cpuhw->mmcr[0]);  
24    
25   mb();   extern void flush_tlb_pending(void);
26  @@ -1315,9 +1318,6 @@ static void power_pmu_enable(struct pmu *pmu)  @@ -48,11 +50,6 @@ extern void __flush_tlb_kernel_range(unsigned long start, unsigned long end);
27    
28   write_mmcr0(cpuhw, mmcr0);   #ifndef CONFIG_SMP
29    
30  - if (ppmu->flags & PPMU_ARCH_207S)  -#define flush_tlb_kernel_range(start,end) \
31  - mtspr(SPRN_MMCR2, 0);  -do { flush_tsb_kernel_range(start,end); \
32    - __flush_tlb_kernel_range(start,end); \
33    -} while (0)
34  -  -
35   /*   static inline void global_flush_tlb_page(struct mm_struct *mm, unsigned long vaddr)
36   * Enable instruction sampling if necessary   {
37   */   __flush_tlb_page(CTX_HWBITS(mm->context), vaddr);
38  diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig  @@ -63,11 +60,6 @@ static inline void global_flush_tlb_page(struct mm_struct *mm, unsigned long vad
39  index 512e45f0c204..1dd140824b49 100644   extern void smp_flush_tlb_kernel_range(unsigned long start, unsigned long end);
40  --- a/arch/x86/Kconfig   extern void smp_flush_tlb_page(struct mm_struct *mm, unsigned long vaddr);
41  +++ b/arch/x86/Kconfig  
42  @@ -910,10 +910,27 @@ config VM86  -#define flush_tlb_kernel_range(start, end) \
43   default y  -do { flush_tsb_kernel_range(start,end); \
44   depends on X86_32  - smp_flush_tlb_kernel_range(start, end); \
45   ---help---  -} while (0)
46  -  This option is required by programs like DOSEMU to run 16-bit legacy  -
47  -  code on X86 processors. It also may be needed by software like   #define global_flush_tlb_page(mm, vaddr) \
48  -  XFree86 to initialize some video cards via BIOS. Disabling this   smp_flush_tlb_page(mm, vaddr)
 -  option saves about 6k.  
 +  This option is required by programs like DOSEMU to run  
 +  16-bit real mode legacy code on x86 processors. It also may  
 +  be needed by software like XFree86 to initialize some video  
 +  cards via BIOS. Disabling this option saves about 6K.  
 +  
 +config X86_16BIT  
 + bool "Enable support for 16-bit segments" if EXPERT  
 + default y  
 + ---help---  
 +  This option is required by programs like Wine to run 16-bit  
 +  protected mode legacy code on x86 processors.  Disabling  
 +  this option saves about 300 bytes on i386, or around 6K text  
 +  plus 16K runtime memory on x86-64,  
 +  
 +config X86_ESPFIX32  
 + def_bool y  
 + depends on X86_16BIT && X86_32  
 +  
 +config X86_ESPFIX64  
 + def_bool y  
 + depends on X86_16BIT && X86_64  
   
  config TOSHIBA  
  tristate "Toshiba Laptop support"  
 diff --git a/arch/x86/include/asm/espfix.h b/arch/x86/include/asm/espfix.h  
 new file mode 100644  
 index 000000000000..99efebb2f69d  
 --- /dev/null  
 +++ b/arch/x86/include/asm/espfix.h  
 @@ -0,0 +1,16 @@  
 +#ifndef _ASM_X86_ESPFIX_H  
 +#define _ASM_X86_ESPFIX_H  
 +  
 +#ifdef CONFIG_X86_64  
 +  
 +#include <asm/percpu.h>  
 +  
 +DECLARE_PER_CPU_READ_MOSTLY(unsigned long, espfix_stack);  
 +DECLARE_PER_CPU_READ_MOSTLY(unsigned long, espfix_waddr);  
 +  
 +extern void init_espfix_bsp(void);  
 +extern void init_espfix_ap(void);  
 +  
 +#endif /* CONFIG_X86_64 */  
 +  
 +#endif /* _ASM_X86_ESPFIX_H */  
 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h  
 index bba3cf88e624..0a8b519226b8 100644  
 --- a/arch/x86/include/asm/irqflags.h  
 +++ b/arch/x86/include/asm/irqflags.h  
 @@ -129,7 +129,7 @@ static inline notrace unsigned long arch_local_irq_save(void)  
   
  #define PARAVIRT_ADJUST_EXCEPTION_FRAME /*  */  
   
 -#define INTERRUPT_RETURN iretq  
 +#define INTERRUPT_RETURN jmp native_iret  
  #define USERGS_SYSRET64 \  
  swapgs; \  
  sysretq;  
 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h  
 index c883bf726398..7166e25ecb57 100644  
 --- a/arch/x86/include/asm/pgtable_64_types.h  
 +++ b/arch/x86/include/asm/pgtable_64_types.h  
 @@ -61,6 +61,8 @@ typedef struct { pteval_t pte; } pte_t;  
  #define MODULES_VADDR    (__START_KERNEL_map + KERNEL_IMAGE_SIZE)  
  #define MODULES_END      _AC(0xffffffffff000000, UL)  
  #define MODULES_LEN   (MODULES_END - MODULES_VADDR)  
 +#define ESPFIX_PGD_ENTRY _AC(-2, UL)  
 +#define ESPFIX_BASE_ADDR (ESPFIX_PGD_ENTRY << PGDIR_SHIFT)  
   
  #define EARLY_DYNAMIC_PAGE_TABLES 64  
   
 diff --git a/arch/x86/include/asm/setup.h b/arch/x86/include/asm/setup.h  
 index 9264f04a4c55..ff4e7b236e21 100644  
 --- a/arch/x86/include/asm/setup.h  
 +++ b/arch/x86/include/asm/setup.h  
 @@ -59,6 +59,8 @@ static inline void x86_ce4100_early_setup(void) { }  
   
  #ifndef _SETUP  
   
 +#include <asm/espfix.h>  
 +  
  /*  
   * This is set up by the setup-routine at boot-time  
   */  
 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile  
 index f4d96000d33a..491ef3e59850 100644  
 --- a/arch/x86/kernel/Makefile  
 +++ b/arch/x86/kernel/Makefile  
 @@ -29,6 +29,7 @@ obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o  
  obj-y += syscall_$(BITS).o vsyscall_gtod.o  
  obj-$(CONFIG_X86_64) += vsyscall_64.o  
  obj-$(CONFIG_X86_64) += vsyscall_emu_64.o  
 +obj-$(CONFIG_X86_ESPFIX64) += espfix_64.o  
  obj-$(CONFIG_SYSFS) += ksysfs.o  
  obj-y += bootflag.o e820.o  
  obj-y += pci-dma.o quirks.o topology.o kdebugfs.o  
 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S  
 index c87810b1b557..c5a9cb94dee6 100644  
 --- a/arch/x86/kernel/entry_32.S  
 +++ b/arch/x86/kernel/entry_32.S  
 @@ -529,6 +529,7 @@ syscall_exit:  
  restore_all:  
  TRACE_IRQS_IRET  
  restore_all_notrace:  
 +#ifdef CONFIG_X86_ESPFIX32  
  movl PT_EFLAGS(%esp), %eax # mix EFLAGS, SS and CS  
  # Warning: PT_OLDSS(%esp) contains the wrong/random values if we  
  # are returning to the kernel.  
 @@ -539,6 +540,7 @@ restore_all_notrace:  
  cmpl $((SEGMENT_LDT << 8) | USER_RPL), %eax  
  CFI_REMEMBER_STATE  
  je ldt_ss # returning to user-space with LDT SS  
 +#endif  
  restore_nocheck:  
  RESTORE_REGS 4 # skip orig_eax/error_code  
  irq_return:  
 @@ -551,6 +553,7 @@ ENTRY(iret_exc)  
  .previous  
  _ASM_EXTABLE(irq_return,iret_exc)  
   
 +#ifdef CONFIG_X86_ESPFIX32  
  CFI_RESTORE_STATE  
  ldt_ss:  
  #ifdef CONFIG_PARAVIRT  
 @@ -594,6 +597,7 @@ ldt_ss:  
  lss (%esp), %esp /* switch to espfix segment */  
  CFI_ADJUST_CFA_OFFSET -8  
  jmp restore_nocheck  
 +#endif  
  CFI_ENDPROC  
  ENDPROC(system_call)  
   
 @@ -706,6 +710,7 @@ END(syscall_badsys)  
   * the high word of the segment base from the GDT and swiches to the  
   * normal stack and adjusts ESP with the matching offset.  
   */  
 +#ifdef CONFIG_X86_ESPFIX32  
  /* fixup the stack */  
  mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */  
  mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */  
 @@ -715,8 +720,10 @@ END(syscall_badsys)  
  pushl_cfi %eax  
  lss (%esp), %esp /* switch to the normal stack segment */  
  CFI_ADJUST_CFA_OFFSET -8  
 +#endif  
  .endm  
  .macro UNWIND_ESPFIX_STACK  
 +#ifdef CONFIG_X86_ESPFIX32  
  movl %ss, %eax  
  /* see if on espfix stack */  
  cmpw $__ESPFIX_SS, %ax  
 @@ -727,6 +734,7 @@ END(syscall_badsys)  
  /* switch to normal stack */  
  FIXUP_ESPFIX_STACK  
  27:  
 +#endif  
  .endm  
49    
50   /*  diff --git a/arch/sparc/include/uapi/asm/unistd.h b/arch/sparc/include/uapi/asm/unistd.h
51  @@ -1357,11 +1365,13 @@ END(debug)  index b73274fb961a..42f2bca1d338 100644
52   ENTRY(nmi)  --- a/arch/sparc/include/uapi/asm/unistd.h
53   RING0_INT_FRAME  +++ b/arch/sparc/include/uapi/asm/unistd.h
54   ASM_CLAC  @@ -410,8 +410,9 @@
55  +#ifdef CONFIG_X86_ESPFIX32   #define __NR_finit_module 342
56   pushl_cfi %eax   #define __NR_sched_setattr 343
57   movl %ss, %eax   #define __NR_sched_getattr 344
58   cmpw $__ESPFIX_SS, %ax  +#define __NR_renameat2 345
59   popl_cfi %eax  
60   je nmi_espfix_stack  -#define NR_syscalls 345
61  +#endif  +#define NR_syscalls 346
62   cmpl $ia32_sysenter_target,(%esp)  
63   je nmi_stack_fixup   /* Bitmask values returned from kern_features system call.  */
64   pushl_cfi %eax   #define KERN_FEATURE_MIXED_MODE_STACK 0x00000001
65  @@ -1401,6 +1411,7 @@ nmi_debug_stack_check:  diff --git a/arch/sparc/kernel/ldc.c b/arch/sparc/kernel/ldc.c
66   FIX_STACK 24, nmi_stack_correct, 1  index e01d75d40329..66dacd56bb10 100644
67   jmp nmi_stack_correct  --- a/arch/sparc/kernel/ldc.c
68    +++ b/arch/sparc/kernel/ldc.c
69  +#ifdef CONFIG_X86_ESPFIX32  @@ -1336,7 +1336,7 @@ int ldc_connect(struct ldc_channel *lp)
70   nmi_espfix_stack:   if (!(lp->flags & LDC_FLAG_ALLOCED_QUEUES) ||
71   /* We have a RING0_INT_FRAME here.      !(lp->flags & LDC_FLAG_REGISTERED_QUEUES) ||
72   *      lp->hs_state != LDC_HS_OPEN)
73  @@ -1422,6 +1433,7 @@ nmi_espfix_stack:  - err = -EINVAL;
74   lss 12+4(%esp), %esp # back to espfix stack  + err = ((lp->hs_state > LDC_HS_OPEN) ? 0 : -EINVAL);
75   CFI_ADJUST_CFA_OFFSET -24   else
76   jmp irq_return   err = start_handshake(lp);
 +#endif  
  CFI_ENDPROC  
  END(nmi)  
77    
78  diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S  diff --git a/arch/sparc/kernel/sys32.S b/arch/sparc/kernel/sys32.S
79  index 1e96c3628bf2..03cd2a8f6009 100644  index d066eb18650c..f834224208ed 100644
80  --- a/arch/x86/kernel/entry_64.S  --- a/arch/sparc/kernel/sys32.S
81  +++ b/arch/x86/kernel/entry_64.S  +++ b/arch/sparc/kernel/sys32.S
82  @@ -58,6 +58,7 @@  @@ -48,6 +48,7 @@ SIGN1(sys32_futex, compat_sys_futex, %o1)
83   #include <asm/asm.h>   SIGN1(sys32_recvfrom, compat_sys_recvfrom, %o0)
84   #include <asm/context_tracking.h>   SIGN1(sys32_recvmsg, compat_sys_recvmsg, %o0)
85   #include <asm/smap.h>   SIGN1(sys32_sendmsg, compat_sys_sendmsg, %o0)
86  +#include <asm/pgtable_types.h>  +SIGN2(sys32_renameat2, sys_renameat2, %o0, %o2)
87   #include <linux/err.h>  
88     .globl sys32_mmap2
89   /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this.  */   sys32_mmap2:
90  @@ -1041,12 +1042,45 @@ restore_args:  diff --git a/arch/sparc/kernel/systbls_32.S b/arch/sparc/kernel/systbls_32.S
91    index 151ace8766cc..85fe9b1087cd 100644
92   irq_return:  --- a/arch/sparc/kernel/systbls_32.S
93   INTERRUPT_RETURN  +++ b/arch/sparc/kernel/systbls_32.S
94  - _ASM_EXTABLE(irq_return, bad_iret)  @@ -86,3 +86,4 @@ sys_call_table:
95     /*330*/ .long sys_fanotify_mark, sys_prlimit64, sys_name_to_handle_at, sys_open_by_handle_at, sys_clock_adjtime
96  -#ifdef CONFIG_PARAVIRT   /*335*/ .long sys_syncfs, sys_sendmmsg, sys_setns, sys_process_vm_readv, sys_process_vm_writev
97   ENTRY(native_iret)   /*340*/ .long sys_ni_syscall, sys_kcmp, sys_finit_module, sys_sched_setattr, sys_sched_getattr
98  + /*  +/*345*/ .long sys_renameat2
99  + * Are we returning to a stack segment from the LDT?  Note: in  diff --git a/arch/sparc/kernel/systbls_64.S b/arch/sparc/kernel/systbls_64.S
100  + * 64-bit mode SS:RSP on the exception stack is always valid.  index 4bd4e2bb26cf..33ecba2826ea 100644
101  + */  --- a/arch/sparc/kernel/systbls_64.S
102  +#ifdef CONFIG_X86_ESPFIX64  +++ b/arch/sparc/kernel/systbls_64.S
103  + testb $4,(SS-RIP)(%rsp)  @@ -87,6 +87,7 @@ sys_call_table32:
104  + jnz native_irq_return_ldt   /*330*/ .word compat_sys_fanotify_mark, sys_prlimit64, sys_name_to_handle_at, compat_sys_open_by_handle_at, compat_sys_clock_adjtime
105  +#endif   .word sys_syncfs, compat_sys_sendmmsg, sys_setns, compat_sys_process_vm_readv, compat_sys_process_vm_writev
106     /*340*/ .word sys_kern_features, sys_kcmp, sys_finit_module, sys_sched_setattr, sys_sched_getattr
107    + .word sys32_renameat2
108    
109     #endif /* CONFIG_COMPAT */
110    
111    @@ -165,3 +166,4 @@ sys_call_table:
112     /*330*/ .word sys_fanotify_mark, sys_prlimit64, sys_name_to_handle_at, sys_open_by_handle_at, sys_clock_adjtime
113     .word sys_syncfs, sys_sendmmsg, sys_setns, sys_process_vm_readv, sys_process_vm_writev
114     /*340*/ .word sys_kern_features, sys_kcmp, sys_finit_module, sys_sched_setattr, sys_sched_getattr
115    + .word sys_renameat2
116    diff --git a/arch/sparc/math-emu/math_32.c b/arch/sparc/math-emu/math_32.c
117    index aa4d55b0bdf0..5ce8f2f64604 100644
118    --- a/arch/sparc/math-emu/math_32.c
119    +++ b/arch/sparc/math-emu/math_32.c
120    @@ -499,7 +499,7 @@ static int do_one_mathemu(u32 insn, unsigned long *pfsr, unsigned long *fregs)
121     case 0: fsr = *pfsr;
122     if (IR == -1) IR = 2;
123     /* fcc is always fcc0 */
124    - fsr &= ~0xc00; fsr |= (IR << 10); break;
125    + fsr &= ~0xc00; fsr |= (IR << 10);
126     *pfsr = fsr;
127     break;
128     case 1: rd->s = IR; break;
129    diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
130    index ed3c969a5f4c..96862241b342 100644
131    --- a/arch/sparc/mm/init_64.c
132    +++ b/arch/sparc/mm/init_64.c
133    @@ -350,6 +350,10 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long address, pte_t *
134    
135     mm = vma->vm_mm;
136    
137    + /* Don't insert a non-valid PTE into the TSB, we'll deadlock.  */
138    + if (!pte_accessible(mm, pte))
139    + return;
140    +
141     spin_lock_irqsave(&mm->context.lock, flags);
142    
143     #if defined(CONFIG_HUGETLB_PAGE) || defined(CONFIG_TRANSPARENT_HUGEPAGE)
144    @@ -2614,6 +2618,10 @@ void update_mmu_cache_pmd(struct vm_area_struct *vma, unsigned long addr,
145    
146     pte = pmd_val(entry);
147    
148    + /* Don't insert a non-valid PMD into the TSB, we'll deadlock.  */
149    + if (!(pte & _PAGE_VALID))
150    + return;
151  +  +
152  +native_irq_return_iret:   /* We are fabricating 8MB pages using 4MB real hw pages.  */
153   iretq   pte |= (addr & (1UL << REAL_HPAGE_SHIFT));
 - _ASM_EXTABLE(native_iret, bad_iret)  
 + _ASM_EXTABLE(native_irq_return_iret, bad_iret)  
 +  
 +#ifdef CONFIG_X86_ESPFIX64  
 +native_irq_return_ldt:  
 + pushq_cfi %rax  
 + pushq_cfi %rdi  
 + SWAPGS  
 + movq PER_CPU_VAR(espfix_waddr),%rdi  
 + movq %rax,(0*8)(%rdi) /* RAX */  
 + movq (2*8)(%rsp),%rax /* RIP */  
 + movq %rax,(1*8)(%rdi)  
 + movq (3*8)(%rsp),%rax /* CS */  
 + movq %rax,(2*8)(%rdi)  
 + movq (4*8)(%rsp),%rax /* RFLAGS */  
 + movq %rax,(3*8)(%rdi)  
 + movq (6*8)(%rsp),%rax /* SS */  
 + movq %rax,(5*8)(%rdi)  
 + movq (5*8)(%rsp),%rax /* RSP */  
 + movq %rax,(4*8)(%rdi)  
 + andl $0xffff0000,%eax  
 + popq_cfi %rdi  
 + orq PER_CPU_VAR(espfix_stack),%rax  
 + SWAPGS  
 + movq %rax,%rsp  
 + popq_cfi %rax  
 + jmp native_irq_return_iret  
  #endif  
154    
155   .section .fixup,"ax"  @@ -2694,3 +2702,26 @@ void hugetlb_setup(struct pt_regs *regs)
156  @@ -1110,9 +1144,40 @@ ENTRY(retint_kernel)   }
157   call preempt_schedule_irq   }
  jmp exit_intr  
158   #endif   #endif
 -  
  CFI_ENDPROC  
  END(common_interrupt)  
159  +  +
160  + /*  +#ifdef CONFIG_SMP
161  + * If IRET takes a fault on the espfix stack, then we  +#define do_flush_tlb_kernel_range smp_flush_tlb_kernel_range
 + * end up promoting it to a doublefault.  In that case,  
 + * modify the stack to make it look like we just entered  
 + * the #GP handler from user space, similar to bad_iret.  
 + */  
 +#ifdef CONFIG_X86_ESPFIX64  
 + ALIGN  
 +__do_double_fault:  
 + XCPT_FRAME 1 RDI+8  
 + movq RSP(%rdi),%rax /* Trap on the espfix stack? */  
 + sarq $PGDIR_SHIFT,%rax  
 + cmpl $ESPFIX_PGD_ENTRY,%eax  
 + jne do_double_fault /* No, just deliver the fault */  
 + cmpl $__KERNEL_CS,CS(%rdi)  
 + jne do_double_fault  
 + movq RIP(%rdi),%rax  
 + cmpq $native_irq_return_iret,%rax  
 + jne do_double_fault /* This shouldn't happen... */  
 + movq PER_CPU_VAR(kernel_stack),%rax  
 + subq $(6*8-KERNEL_STACK_OFFSET),%rax /* Reset to original stack */  
 + movq %rax,RSP(%rdi)  
 + movq $0,(%rax) /* Missing (lost) #GP error code */  
 + movq $general_protection,RIP(%rdi)  
 + retq  
 + CFI_ENDPROC  
 +END(__do_double_fault)  
162  +#else  +#else
163  +# define __do_double_fault do_double_fault  +#define do_flush_tlb_kernel_range __flush_tlb_kernel_range
164  +#endif  +#endif
165  +  +
166   /*  +void flush_tlb_kernel_range(unsigned long start, unsigned long end)
   * End of kprobes section  
   */  
 @@ -1314,7 +1379,7 @@ zeroentry overflow do_overflow  
  zeroentry bounds do_bounds  
  zeroentry invalid_op do_invalid_op  
  zeroentry device_not_available do_device_not_available  
 -paranoiderrorentry double_fault do_double_fault  
 +paranoiderrorentry double_fault __do_double_fault  
  zeroentry coprocessor_segment_overrun do_coprocessor_segment_overrun  
  errorentry invalid_TSS do_invalid_TSS  
  errorentry segment_not_present do_segment_not_present  
 @@ -1601,7 +1666,7 @@ error_sti:  
   */  
  error_kernelspace:  
  incl %ebx  
 - leaq irq_return(%rip),%rcx  
 + leaq native_irq_return_iret(%rip),%rcx  
  cmpq %rcx,RIP+8(%rsp)  
  je error_swapgs  
  movl %ecx,%eax /* zero extend */  
 diff --git a/arch/x86/kernel/espfix_64.c b/arch/x86/kernel/espfix_64.c  
 new file mode 100644  
 index 000000000000..94d857fb1033  
 --- /dev/null  
 +++ b/arch/x86/kernel/espfix_64.c  
 @@ -0,0 +1,208 @@  
 +/* ----------------------------------------------------------------------- *  
 + *  
 + *   Copyright 2014 Intel Corporation; author: H. Peter Anvin  
 + *  
 + *   This program is free software; you can redistribute it and/or modify it  
 + *   under the terms and conditions of the GNU General Public License,  
 + *   version 2, as published by the Free Software Foundation.  
 + *  
 + *   This program is distributed in the hope it will be useful, but WITHOUT  
 + *   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or  
 + *   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for  
 + *   more details.  
 + *  
 + * ----------------------------------------------------------------------- */  
 +  
 +/*  
 + * The IRET instruction, when returning to a 16-bit segment, only  
 + * restores the bottom 16 bits of the user space stack pointer.  This  
 + * causes some 16-bit software to break, but it also leaks kernel state  
 + * to user space.  
 + *  
 + * This works around this by creating percpu "ministacks", each of which  
 + * is mapped 2^16 times 64K apart.  When we detect that the return SS is  
 + * on the LDT, we copy the IRET frame to the ministack and use the  
 + * relevant alias to return to userspace.  The ministacks are mapped  
 + * readonly, so if the IRET fault we promote #GP to #DF which is an IST  
 + * vector and thus has its own stack; we then do the fixup in the #DF  
 + * handler.  
 + *  
 + * This file sets up the ministacks and the related page tables.  The  
 + * actual ministack invocation is in entry_64.S.  
 + */  
 +  
 +#include <linux/init.h>  
 +#include <linux/init_task.h>  
 +#include <linux/kernel.h>  
 +#include <linux/percpu.h>  
 +#include <linux/gfp.h>  
 +#include <linux/random.h>  
 +#include <asm/pgtable.h>  
 +#include <asm/pgalloc.h>  
 +#include <asm/setup.h>  
 +#include <asm/espfix.h>  
 +  
 +/*  
 + * Note: we only need 6*8 = 48 bytes for the espfix stack, but round  
 + * it up to a cache line to avoid unnecessary sharing.  
 + */  
 +#define ESPFIX_STACK_SIZE (8*8UL)  
 +#define ESPFIX_STACKS_PER_PAGE (PAGE_SIZE/ESPFIX_STACK_SIZE)  
 +  
 +/* There is address space for how many espfix pages? */  
 +#define ESPFIX_PAGE_SPACE (1UL << (PGDIR_SHIFT-PAGE_SHIFT-16))  
 +  
 +#define ESPFIX_MAX_CPUS (ESPFIX_STACKS_PER_PAGE * ESPFIX_PAGE_SPACE)  
 +#if CONFIG_NR_CPUS > ESPFIX_MAX_CPUS  
 +# error "Need more than one PGD for the ESPFIX hack"  
 +#endif  
 +  
 +#define PGALLOC_GFP (GFP_KERNEL | __GFP_NOTRACK | __GFP_REPEAT | __GFP_ZERO)  
 +  
 +/* This contains the *bottom* address of the espfix stack */  
 +DEFINE_PER_CPU_READ_MOSTLY(unsigned long, espfix_stack);  
 +DEFINE_PER_CPU_READ_MOSTLY(unsigned long, espfix_waddr);  
 +  
 +/* Initialization mutex - should this be a spinlock? */  
 +static DEFINE_MUTEX(espfix_init_mutex);  
 +  
 +/* Page allocation bitmap - each page serves ESPFIX_STACKS_PER_PAGE CPUs */  
 +#define ESPFIX_MAX_PAGES  DIV_ROUND_UP(CONFIG_NR_CPUS, ESPFIX_STACKS_PER_PAGE)  
 +static void *espfix_pages[ESPFIX_MAX_PAGES];  
 +  
 +static __page_aligned_bss pud_t espfix_pud_page[PTRS_PER_PUD]  
 + __aligned(PAGE_SIZE);  
 +  
 +static unsigned int page_random, slot_random;  
 +  
 +/*  
 + * This returns the bottom address of the espfix stack for a specific CPU.  
 + * The math allows for a non-power-of-two ESPFIX_STACK_SIZE, in which case  
 + * we have to account for some amount of padding at the end of each page.  
 + */  
 +static inline unsigned long espfix_base_addr(unsigned int cpu)  
 +{  
 + unsigned long page, slot;  
 + unsigned long addr;  
 +  
 + page = (cpu / ESPFIX_STACKS_PER_PAGE) ^ page_random;  
 + slot = (cpu + slot_random) % ESPFIX_STACKS_PER_PAGE;  
 + addr = (page << PAGE_SHIFT) + (slot * ESPFIX_STACK_SIZE);  
 + addr = (addr & 0xffffUL) | ((addr & ~0xffffUL) << 16);  
 + addr += ESPFIX_BASE_ADDR;  
 + return addr;  
 +}  
 +  
 +#define PTE_STRIDE        (65536/PAGE_SIZE)  
 +#define ESPFIX_PTE_CLONES (PTRS_PER_PTE/PTE_STRIDE)  
 +#define ESPFIX_PMD_CLONES PTRS_PER_PMD  
 +#define ESPFIX_PUD_CLONES (65536/(ESPFIX_PTE_CLONES*ESPFIX_PMD_CLONES))  
 +  
 +#define PGTABLE_PROT  ((_KERNPG_TABLE & ~_PAGE_RW) | _PAGE_NX)  
 +  
 +static void init_espfix_random(void)  
167  +{  +{
168  + unsigned long rand;  + if (start < HI_OBP_ADDRESS && end > LOW_OBP_ADDRESS) {
169  +  + if (start < LOW_OBP_ADDRESS) {
170  + /*  + flush_tsb_kernel_range(start, LOW_OBP_ADDRESS);
171  + * This is run before the entropy pools are initialized,  + do_flush_tlb_kernel_range(start, LOW_OBP_ADDRESS);
172  + * but this is hopefully better than nothing.  + }
173  + */  + if (end > HI_OBP_ADDRESS) {
174  + if (!arch_get_random_long(&rand)) {  + flush_tsb_kernel_range(end, HI_OBP_ADDRESS);
175  + /* The constant is an arbitrary large prime */  + do_flush_tlb_kernel_range(end, HI_OBP_ADDRESS);
176  + rdtscll(rand);  + }
177  + rand *= 0xc345c6b72fd16123UL;  + } else {
178    + flush_tsb_kernel_range(start, end);
179    + do_flush_tlb_kernel_range(start, end);
180  + }  + }
 +  
 + slot_random = rand % ESPFIX_STACKS_PER_PAGE;  
 + page_random = (rand / ESPFIX_STACKS_PER_PAGE)  
 + & (ESPFIX_PAGE_SPACE - 1);  
181  +}  +}
182    diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
183    index 4d8f8aba0ea5..b87434c99f4d 100644
184    --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
185    +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
186    @@ -346,6 +346,7 @@ struct sw_tx_bd {
187     u8 flags;
188     /* Set on the first BD descriptor when there is a split BD */
189     #define BNX2X_TSO_SPLIT_BD (1<<0)
190    +#define BNX2X_HAS_SECOND_PBD (1<<1)
191     };
192    
193     struct sw_rx_page {
194    diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
195    index 0979967577a1..b2b0d2e684ef 100644
196    --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
197    +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
198    @@ -227,6 +227,12 @@ static u16 bnx2x_free_tx_pkt(struct bnx2x *bp, struct bnx2x_fp_txdata *txdata,
199     --nbd;
200     bd_idx = TX_BD(NEXT_TX_IDX(bd_idx));
201    
202    + if (tx_buf->flags & BNX2X_HAS_SECOND_PBD) {
203    + /* Skip second parse bd... */
204    + --nbd;
205    + bd_idx = TX_BD(NEXT_TX_IDX(bd_idx));
206    + }
207  +  +
208  +void __init init_espfix_bsp(void)   /* TSO headers+data bds share a common mapping. See bnx2x_tx_split() */
209  +{   if (tx_buf->flags & BNX2X_TSO_SPLIT_BD) {
210  + pgd_t *pgd_p;   tx_data_bd = &txdata->tx_desc_ring[bd_idx].reg_bd;
211  + pteval_t ptemask;  @@ -3877,6 +3883,9 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev)
212  +   /* set encapsulation flag in start BD */
213  + ptemask = __supported_pte_mask;   SET_FLAG(tx_start_bd->general_data,
214  +   ETH_TX_START_BD_TUNNEL_EXIST, 1);
215  + /* Install the espfix pud into the kernel page directory */  +
216  + pgd_p = &init_level4_pgt[pgd_index(ESPFIX_BASE_ADDR)];  + tx_buf->flags |= BNX2X_HAS_SECOND_PBD;
217  + pgd_populate(&init_mm, pgd_p, (pud_t *)espfix_pud_page);  +
218     nbd++;
219     } else if (xmit_type & XMIT_CSUM) {
220     /* Set PBD in checksum offload case w/o encapsulation */
221    diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
222    index 0966bd04375f..837224639148 100644
223    --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
224    +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
225    @@ -1149,6 +1149,11 @@ static netdev_tx_t bcmgenet_xmit(struct sk_buff *skb, struct net_device *dev)
226     goto out;
227     }
228    
229    + if (skb_padto(skb, ETH_ZLEN)) {
230    + ret = NETDEV_TX_OK;
231    + goto out;
232    + }
233  +  +
234  + /* Randomize the locations */   /* set the SKB transmit checksum */
235  + init_espfix_random();   if (priv->desc_64b_en) {
236     ret = bcmgenet_put_tx_csum(dev, skb);
237    diff --git a/drivers/net/ethernet/brocade/bna/bnad.c b/drivers/net/ethernet/brocade/bna/bnad.c
238    index 675550fe8ee9..ac1ebe0374be 100644
239    --- a/drivers/net/ethernet/brocade/bna/bnad.c
240    +++ b/drivers/net/ethernet/brocade/bna/bnad.c
241    @@ -600,9 +600,9 @@ bnad_cq_process(struct bnad *bnad, struct bna_ccb *ccb, int budget)
242     prefetch(bnad->netdev);
243    
244     cq = ccb->sw_q;
245    - cmpl = &cq[ccb->producer_index];
246    
247     while (packets < budget) {
248    + cmpl = &cq[ccb->producer_index];
249     if (!cmpl->valid)
250     break;
251     /* The 'valid' field is set by the adapter, only after writing
252    diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
253    index 7eec598c5cb6..d650b911dae4 100644
254    --- a/drivers/net/macvlan.c
255    +++ b/drivers/net/macvlan.c
256    @@ -547,6 +547,7 @@ static int macvlan_init(struct net_device *dev)
257      (lowerdev->state & MACVLAN_STATE_MASK);
258     dev->features = lowerdev->features & MACVLAN_FEATURES;
259     dev->features |= ALWAYS_ON_FEATURES;
260    + dev->vlan_features = lowerdev->vlan_features & MACVLAN_FEATURES;
261     dev->gso_max_size = lowerdev->gso_max_size;
262     dev->iflink = lowerdev->ifindex;
263     dev->hard_header_len = lowerdev->hard_header_len;
264    diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
265    index 4987a1c6dc52..b96c4a226624 100644
266    --- a/drivers/net/phy/phy_device.c
267    +++ b/drivers/net/phy/phy_device.c
268    @@ -354,7 +354,7 @@ int phy_device_register(struct phy_device *phydev)
269     phydev->bus->phy_map[phydev->addr] = phydev;
270    
271     /* Run all of the fixups for this PHY */
272    - err = phy_init_hw(phydev);
273    + err = phy_scan_fixups(phydev);
274     if (err) {
275     pr_err("PHY %d failed to initialize\n", phydev->addr);
276     goto out;
277    diff --git a/drivers/net/ppp/pptp.c b/drivers/net/ppp/pptp.c
278    index 01805319e1e0..1aff970be33e 100644
279    --- a/drivers/net/ppp/pptp.c
280    +++ b/drivers/net/ppp/pptp.c
281    @@ -281,7 +281,7 @@ static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb)
282     nf_reset(skb);
283    
284     skb->ip_summed = CHECKSUM_NONE;
285    - ip_select_ident(skb, &rt->dst, NULL);
286    + ip_select_ident(skb, NULL);
287     ip_send_check(iph);
288    
289     ip_local_out(skb);
290    diff --git a/drivers/sbus/char/bbc_envctrl.c b/drivers/sbus/char/bbc_envctrl.c
291    index 160e7510aca6..0787b9756165 100644
292    --- a/drivers/sbus/char/bbc_envctrl.c
293    +++ b/drivers/sbus/char/bbc_envctrl.c
294    @@ -452,6 +452,9 @@ static void attach_one_temp(struct bbc_i2c_bus *bp, struct platform_device *op,
295     if (!tp)
296     return;
297    
298    + INIT_LIST_HEAD(&tp->bp_list);
299    + INIT_LIST_HEAD(&tp->glob_list);
300  +  +
301  + /* The rest is the same as for any other processor */   tp->client = bbc_i2c_attach(bp, op);
302  + init_espfix_ap();   if (!tp->client) {
303  +}   kfree(tp);
304    @@ -497,6 +500,9 @@ static void attach_one_fan(struct bbc_i2c_bus *bp, struct platform_device *op,
305     if (!fp)
306     return;
307    
308    + INIT_LIST_HEAD(&fp->bp_list);
309    + INIT_LIST_HEAD(&fp->glob_list);
310  +  +
311  +void init_espfix_ap(void)   fp->client = bbc_i2c_attach(bp, op);
312  +{   if (!fp->client) {
313  + unsigned int cpu, page;   kfree(fp);
314  + unsigned long addr;  diff --git a/drivers/sbus/char/bbc_i2c.c b/drivers/sbus/char/bbc_i2c.c
315  + pud_t pud, *pud_p;  index c7763e482eb2..812b5f0361b6 100644
316  + pmd_t pmd, *pmd_p;  --- a/drivers/sbus/char/bbc_i2c.c
317  + pte_t pte, *pte_p;  +++ b/drivers/sbus/char/bbc_i2c.c
318  + int n;  @@ -300,13 +300,18 @@ static struct bbc_i2c_bus * attach_one_i2c(struct platform_device *op, int index
319  + void *stack_page;   if (!bp)
320  + pteval_t ptemask;   return NULL;
321  +  
322  + /* We only have to do this once... */  + INIT_LIST_HEAD(&bp->temps);
323  + if (likely(this_cpu_read(espfix_stack)))  + INIT_LIST_HEAD(&bp->fans);
324  + return; /* Already initialized */  +
325  +   bp->i2c_control_regs = of_ioremap(&op->resource[0], 0, 0x2, "bbc_i2c_regs");
326  + cpu = smp_processor_id();   if (!bp->i2c_control_regs)
327  + addr = espfix_base_addr(cpu);   goto fail;
328  + page = cpu/ESPFIX_STACKS_PER_PAGE;  
329  +  - bp->i2c_bussel_reg = of_ioremap(&op->resource[1], 0, 0x1, "bbc_i2c_bussel");
330  + /* Did another CPU already set this up? */  - if (!bp->i2c_bussel_reg)
331  + stack_page = ACCESS_ONCE(espfix_pages[page]);  - goto fail;
332  + if (likely(stack_page))  + if (op->num_resources == 2) {
333  + goto done;  + bp->i2c_bussel_reg = of_ioremap(&op->resource[1], 0, 0x1, "bbc_i2c_bussel");
334  +  + if (!bp->i2c_bussel_reg)
335  + mutex_lock(&espfix_init_mutex);  + goto fail;
 +  
 + /* Did we race on the lock? */  
 + stack_page = ACCESS_ONCE(espfix_pages[page]);  
 + if (stack_page)  
 + goto unlock_done;  
 +  
 + ptemask = __supported_pte_mask;  
 +  
 + pud_p = &espfix_pud_page[pud_index(addr)];  
 + pud = *pud_p;  
 + if (!pud_present(pud)) {  
 + pmd_p = (pmd_t *)__get_free_page(PGALLOC_GFP);  
 + pud = __pud(__pa(pmd_p) | (PGTABLE_PROT & ptemask));  
 + paravirt_alloc_pmd(&init_mm, __pa(pmd_p) >> PAGE_SHIFT);  
 + for (n = 0; n < ESPFIX_PUD_CLONES; n++)  
 + set_pud(&pud_p[n], pud);  
336  + }  + }
337  +  
338  + pmd_p = pmd_offset(&pud, addr);   bp->waiting = 0;
339  + pmd = *pmd_p;   init_waitqueue_head(&bp->wq);
340  + if (!pmd_present(pmd)) {  diff --git a/drivers/tty/serial/sunsab.c b/drivers/tty/serial/sunsab.c
341  + pte_p = (pte_t *)__get_free_page(PGALLOC_GFP);  index 2f57df9a71d9..a1e09c0d46f2 100644
342  + pmd = __pmd(__pa(pte_p) | (PGTABLE_PROT & ptemask));  --- a/drivers/tty/serial/sunsab.c
343  + paravirt_alloc_pte(&init_mm, __pa(pte_p) >> PAGE_SHIFT);  +++ b/drivers/tty/serial/sunsab.c
344  + for (n = 0; n < ESPFIX_PMD_CLONES; n++)  @@ -157,6 +157,15 @@ receive_chars(struct uart_sunsab_port *up,
345  + set_pmd(&pmd_p[n], pmd);      (up->port.line == up->port.cons->index))
346     saw_console_brk = 1;
347    
348    + if (count == 0) {
349    + if (unlikely(stat->sreg.isr1 & SAB82532_ISR1_BRK)) {
350    + stat->sreg.isr0 &= ~(SAB82532_ISR0_PERR |
351    +     SAB82532_ISR0_FERR);
352    + up->port.icount.brk++;
353    + uart_handle_break(&up->port);
354    + }
355  + }  + }
356  +  +
357  + pte_p = pte_offset_kernel(&pmd, addr);   for (i = 0; i < count; i++) {
358  + stack_page = (void *)__get_free_page(GFP_KERNEL);   unsigned char ch = buf[i], flag;
 + pte = __pte(__pa(stack_page) | (__PAGE_KERNEL_RO & ptemask));  
 + for (n = 0; n < ESPFIX_PTE_CLONES; n++)  
 + set_pte(&pte_p[n*PTE_STRIDE], pte);  
 +  
 + /* Job is done for this CPU and any CPU which shares this page */  
 + ACCESS_ONCE(espfix_pages[page]) = stack_page;  
 +  
 +unlock_done:  
 + mutex_unlock(&espfix_init_mutex);  
 +done:  
 + this_cpu_write(espfix_stack, addr);  
 + this_cpu_write(espfix_waddr, (unsigned long)stack_page  
 +       + (addr & ~PAGE_MASK));  
 +}  
 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c  
 index dcbbaa165bde..c37886d759cc 100644  
 --- a/arch/x86/kernel/ldt.c  
 +++ b/arch/x86/kernel/ldt.c  
 @@ -20,8 +20,6 @@  
  #include <asm/mmu_context.h>  
  #include <asm/syscalls.h>  
359    
360  -int sysctl_ldt16 = 0;  diff --git a/fs/xfs/xfs_log.h b/fs/xfs/xfs_log.h
361  -  index 2c4004475e71..84e0deb95abd 100644
362   #ifdef CONFIG_SMP  --- a/fs/xfs/xfs_log.h
363   static void flush_ldt(void *current_mm)  +++ b/fs/xfs/xfs_log.h
364   {  @@ -24,7 +24,8 @@ struct xfs_log_vec {
365  @@ -231,16 +229,10 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)   struct xfs_log_iovec *lv_iovecp; /* iovec array */
366   }   struct xfs_log_item *lv_item; /* owner */
367   }   char *lv_buf; /* formatted buffer */
368    - int lv_buf_len; /* size of formatted buffer */
369    + int lv_bytes; /* accounted space in buffer */
370    + int lv_buf_len; /* aligned size of buffer */
371     int lv_size; /* size of allocated lv */
372     };
373    
374    @@ -52,15 +53,21 @@ xlog_prepare_iovec(struct xfs_log_vec *lv, struct xfs_log_iovec **vecp,
375     return vec->i_addr;
376     }
377    
378    +/*
379    + * We need to make sure the next buffer is naturally aligned for the biggest
380    + * basic data type we put into it.  We already accounted for this padding when
381    + * sizing the buffer.
382    + *
383    + * However, this padding does not get written into the log, and hence we have to
384    + * track the space used by the log vectors separately to prevent log space hangs
385    + * due to inaccurate accounting (i.e. a leak) of the used log space through the
386    + * CIL context ticket.
387    + */
388     static inline void
389     xlog_finish_iovec(struct xfs_log_vec *lv, struct xfs_log_iovec *vec, int len)
390     {
391  - /*  - /*
392  - * On x86-64 we do not support 16-bit segments due to  - * We need to make sure the next buffer is naturally aligned for the
393  - * IRET leaking the high bits of the kernel stack address.  - * biggest basic data type we put into it.  We already accounted for
394    - * this when sizing the buffer.
395  - */  - */
396  -#ifdef CONFIG_X86_64   lv->lv_buf_len += round_up(len, sizeof(uint64_t));
397  - if (!ldt_info.seg_32bit && !sysctl_ldt16) {  + lv->lv_bytes += len;
398  + if (!IS_ENABLED(CONFIG_X86_16BIT) && !ldt_info.seg_32bit) {   vec->i_len = len;
399   error = -EINVAL;   }
  goto out_unlock;  
  }  
 -#endif  
400    
401   fill_ldt(&ldt, &ldt_info);  diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
402   if (oldmode)  index 7e5455391176..de835da6764d 100644
403  diff --git a/arch/x86/kernel/paravirt_patch_64.c b/arch/x86/kernel/paravirt_patch_64.c  --- a/fs/xfs/xfs_log_cil.c
404  index 3f08f34f93eb..a1da6737ba5b 100644  +++ b/fs/xfs/xfs_log_cil.c
405  --- a/arch/x86/kernel/paravirt_patch_64.c  @@ -97,7 +97,7 @@ xfs_cil_prepare_item(
406  +++ b/arch/x86/kernel/paravirt_patch_64.c   {
407  @@ -6,7 +6,6 @@ DEF_NATIVE(pv_irq_ops, irq_disable, "cli");   /* Account for the new LV being passed in */
408   DEF_NATIVE(pv_irq_ops, irq_enable, "sti");   if (lv->lv_buf_len != XFS_LOG_VEC_ORDERED) {
409   DEF_NATIVE(pv_irq_ops, restore_fl, "pushq %rdi; popfq");  - *diff_len += lv->lv_buf_len;
410   DEF_NATIVE(pv_irq_ops, save_fl, "pushfq; popq %rax");  + *diff_len += lv->lv_bytes;
411  -DEF_NATIVE(pv_cpu_ops, iret, "iretq");   *diff_iovecs += lv->lv_niovecs;
412   DEF_NATIVE(pv_mmu_ops, read_cr2, "movq %cr2, %rax");   }
  DEF_NATIVE(pv_mmu_ops, read_cr3, "movq %cr3, %rax");  
  DEF_NATIVE(pv_mmu_ops, write_cr3, "movq %rdi, %cr3");  
 @@ -50,7 +49,6 @@ unsigned native_patch(u8 type, u16 clobbers, void *ibuf,  
  PATCH_SITE(pv_irq_ops, save_fl);  
  PATCH_SITE(pv_irq_ops, irq_enable);  
  PATCH_SITE(pv_irq_ops, irq_disable);  
 - PATCH_SITE(pv_cpu_ops, iret);  
  PATCH_SITE(pv_cpu_ops, irq_enable_sysexit);  
  PATCH_SITE(pv_cpu_ops, usergs_sysret32);  
  PATCH_SITE(pv_cpu_ops, usergs_sysret64);  
 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c  
 index ae2fd975b782..5492798930ef 100644  
 --- a/arch/x86/kernel/smpboot.c  
 +++ b/arch/x86/kernel/smpboot.c  
 @@ -244,6 +244,13 @@ static void notrace start_secondary(void *unused)  
  check_tsc_sync_target();  
413    
414    @@ -111,7 +111,7 @@ xfs_cil_prepare_item(
415     else if (old_lv != lv) {
416     ASSERT(lv->lv_buf_len != XFS_LOG_VEC_ORDERED);
417    
418    - *diff_len -= old_lv->lv_buf_len;
419    + *diff_len -= old_lv->lv_bytes;
420     *diff_iovecs -= old_lv->lv_niovecs;
421     kmem_free(old_lv);
422     }
423    @@ -239,7 +239,7 @@ xlog_cil_insert_format_items(
424     * that the space reservation accounting is correct.
425     */
426     *diff_iovecs -= lv->lv_niovecs;
427    - *diff_len -= lv->lv_buf_len;
428    + *diff_len -= lv->lv_bytes;
429     } else {
430     /* allocate new data chunk */
431     lv = kmem_zalloc(buf_size, KM_SLEEP|KM_NOFS);
432    @@ -259,6 +259,7 @@ xlog_cil_insert_format_items(
433    
434     /* The allocated data region lies beyond the iovec region */
435     lv->lv_buf_len = 0;
436    + lv->lv_bytes = 0;
437     lv->lv_buf = (char *)lv + buf_size - nbytes;
438     ASSERT(IS_ALIGNED((unsigned long)lv->lv_buf, sizeof(uint64_t)));
439    
440    diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
441    index 058271bde27a..823ec7bb9c67 100644
442    --- a/include/net/inetpeer.h
443    +++ b/include/net/inetpeer.h
444    @@ -41,14 +41,13 @@ struct inet_peer {
445     struct rcu_head     gc_rcu;
446     };
447   /*   /*
448  + * Enable the espfix hack for this CPU  - * Once inet_peer is queued for deletion (refcnt == -1), following fields
449  + */  - * are not available: rid, ip_id_count
450  +#ifdef CONFIG_X86_ESPFIX64  + * Once inet_peer is queued for deletion (refcnt == -1), following field
451  + init_espfix_ap();  + * is not available: rid
452  +#endif   * We can share memory with rcu_head to help keep inet_peer small.
453  +   */
454  + /*   union {
455   * We need to hold vector_lock so there the set of online cpus   struct {
456   * does not change while we are assigning vectors to cpus.  Holding   atomic_t rid; /* Frag reception counter */
457   * this lock ensures we don't half assign or remove an irq from a cpu.  - atomic_t ip_id_count; /* IP ID for the next packet */
458  diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c   };
459  index 20621d753d5f..167ffcac16ed 100644   struct rcu_head         rcu;
460  --- a/arch/x86/mm/dump_pagetables.c   struct inet_peer *gc_next;
461  +++ b/arch/x86/mm/dump_pagetables.c  @@ -165,7 +164,7 @@ bool inet_peer_xrlim_allow(struct inet_peer *peer, int timeout);
462  @@ -30,12 +30,14 @@ struct pg_state {   void inetpeer_invalidate_tree(struct inet_peer_base *);
  unsigned long start_address;  
  unsigned long current_address;  
  const struct addr_marker *marker;  
 + unsigned long lines;  
  bool to_dmesg;  
  };  
463    
464   struct addr_marker {   /*
465   unsigned long start_address;  - * temporary check to make sure we dont access rid, ip_id_count, tcp_ts,
466   const char *name;  + * temporary check to make sure we dont access rid, tcp_ts,
467  + unsigned long max_lines;    * tcp_ts_stamp if no refcount is taken on inet_peer
468   };    */
469     static inline void inet_peer_refcheck(const struct inet_peer *p)
470    @@ -173,13 +172,4 @@ static inline void inet_peer_refcheck(const struct inet_peer *p)
471     WARN_ON_ONCE(atomic_read(&p->refcnt) <= 0);
472     }
473    
474    -
475    -/* can be called with or without local BH being disabled */
476    -static inline int inet_getid(struct inet_peer *p, int more)
477    -{
478    - more++;
479    - inet_peer_refcheck(p);
480    - return atomic_add_return(more, &p->ip_id_count) - more;
481    -}
482    -
483     #endif /* _NET_INETPEER_H */
484    diff --git a/include/net/ip.h b/include/net/ip.h
485    index 3ec2b0fb9d83..54de0292ac53 100644
486    --- a/include/net/ip.h
487    +++ b/include/net/ip.h
488    @@ -310,9 +310,10 @@ static inline unsigned int ip_skb_dst_mtu(const struct sk_buff *skb)
489     }
490     }
491    
492    -void __ip_select_ident(struct iphdr *iph, struct dst_entry *dst, int more);
493    +u32 ip_idents_reserve(u32 hash, int segs);
494    +void __ip_select_ident(struct iphdr *iph, int segs);
495    
496   /* indices for address_markers; keep sync'd w/ address_markers below */  -static inline void ip_select_ident(struct sk_buff *skb, struct dst_entry *dst, struct sock *sk)
497  @@ -46,6 +48,7 @@ enum address_markers_idx {  +static inline void ip_select_ident_segs(struct sk_buff *skb, struct sock *sk, int segs)
  LOW_KERNEL_NR,  
  VMALLOC_START_NR,  
  VMEMMAP_START_NR,  
 + ESPFIX_START_NR,  
  HIGH_KERNEL_NR,  
  MODULES_VADDR_NR,  
  MODULES_END_NR,  
 @@ -68,6 +71,7 @@ static struct addr_marker address_markers[] = {  
  { PAGE_OFFSET, "Low Kernel Mapping" },  
  { VMALLOC_START,        "vmalloc() Area" },  
  { VMEMMAP_START,        "Vmemmap" },  
 + { ESPFIX_BASE_ADDR, "ESPfix Area", 16 },  
  { __START_KERNEL_map,   "High Kernel Mapping" },  
  { MODULES_VADDR,        "Modules" },  
  { MODULES_END,          "End Modules" },  
 @@ -182,7 +186,7 @@ static void note_page(struct seq_file *m, struct pg_state *st,  
       pgprot_t new_prot, int level)  
498   {   {
499   pgprotval_t prot, cur;   struct iphdr *iph = ip_hdr(skb);
 - static const char units[] = "KMGTPE";  
 + static const char units[] = "BKMGTPE";  
500    
501   /*  @@ -322,24 +323,20 @@ static inline void ip_select_ident(struct sk_buff *skb, struct dst_entry *dst, s
502   * If we have a "break" in the series, we need to flush the state that   * does not change, they drop every other packet in
503  @@ -197,6 +201,7 @@ static void note_page(struct seq_file *m, struct pg_state *st,   * a TCP stream using header compression.
  st->current_prot = new_prot;  
  st->level = level;  
  st->marker = address_markers;  
 + st->lines = 0;  
  pt_dump_seq_printf(m, st->to_dmesg, "---[ %s ]---\n",  
    st->marker->name);  
  } else if (prot != cur || level != st->level ||  
 @@ -208,17 +213,24 @@ static void note_page(struct seq_file *m, struct pg_state *st,  
  /*  
  * Now print the actual finished series  
504   */   */
505  - pt_dump_seq_printf(m, st->to_dmesg,  "0x%0*lx-0x%0*lx   ",  - iph->id = (sk && inet_sk(sk)->inet_daddr) ?
506  -   width, st->start_address,  - htons(inet_sk(sk)->inet_id++) : 0;
507  -   width, st->current_address);  - } else
508    - __ip_select_ident(iph, dst, 0);
509    -}
510  -  -
511  - delta = (st->current_address - st->start_address) >> 10;  -static inline void ip_select_ident_more(struct sk_buff *skb, struct dst_entry *dst, struct sock *sk, int more)
512  - while (!(delta & 1023) && unit[1]) {  -{
513  - delta >>= 10;  - struct iphdr *iph = ip_hdr(skb);
514  - unit++;  -
515  + if (!st->marker->max_lines ||  - if ((iph->frag_off & htons(IP_DF)) && !skb->local_df) {
516  +    st->lines < st->marker->max_lines) {   if (sk && inet_sk(sk)->inet_daddr) {
517  + pt_dump_seq_printf(m, st->to_dmesg,   iph->id = htons(inet_sk(sk)->inet_id);
518  +   "0x%0*lx-0x%0*lx   ",  - inet_sk(sk)->inet_id += 1 + more;
519  +   width, st->start_address,  - } else
520  +   width, st->current_address);  + inet_sk(sk)->inet_id += segs;
521  +  + } else {
522  + delta = st->current_address - st->start_address;   iph->id = 0;
523  + while (!(delta & 1023) && unit[1]) {  - } else
524  + delta >>= 10;  - __ip_select_ident(iph, dst, more);
525  + unit++;  + }
526  + }  + } else {
527  + pt_dump_cont_printf(m, st->to_dmesg, "%9lu%c ",  + __ip_select_ident(iph, segs);
528  +    delta, *unit);  + }
529  + printk_prot(m, st->current_prot, st->level,  +}
530  +    st->to_dmesg);  +
531   }  +static inline void ip_select_ident(struct sk_buff *skb, struct sock *sk)
532  - pt_dump_cont_printf(m, st->to_dmesg, "%9lu%c ", delta, *unit);  +{
533  - printk_prot(m, st->current_prot, st->level, st->to_dmesg);  + ip_select_ident_segs(skb, sk, 1);
534  + st->lines++;   }
   
  /*  
  * We print markers for special areas of address space,  
 @@ -226,7 +238,17 @@ static void note_page(struct seq_file *m, struct pg_state *st,  
  * This helps in the interpretation.  
  */  
  if (st->current_address >= st->marker[1].start_address) {  
 + if (st->marker->max_lines &&  
 +    st->lines > st->marker->max_lines) {  
 + unsigned long nskip =  
 + st->lines - st->marker->max_lines;  
 + pt_dump_seq_printf(m, st->to_dmesg,  
 +   "... %lu entr%s skipped ... \n",  
 +   nskip,  
 +   nskip == 1 ? "y" : "ies");  
 + }  
  st->marker++;  
 + st->lines = 0;  
  pt_dump_seq_printf(m, st->to_dmesg, "---[ %s ]---\n",  
    st->marker->name);  
  }  
 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c  
 index 310c5f0dbef1..3adf2e6ad7d6 100644  
 --- a/arch/x86/vdso/vdso32-setup.c  
 +++ b/arch/x86/vdso/vdso32-setup.c  
 @@ -39,7 +39,6 @@  
  #ifdef CONFIG_X86_64  
  #define vdso_enabled sysctl_vsyscall32  
  #define arch_setup_additional_pages syscall32_setup_pages  
 -extern int sysctl_ldt16;  
  #endif  
535    
536   /*   /*
537  @@ -251,13 +250,6 @@ static struct ctl_table abi_table2[] = {  diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h
538   .mode = 0644,  index a4daf9eb8562..8dd8cab88b87 100644
539   .proc_handler = proc_dointvec  --- a/include/net/ip_tunnels.h
540   },  +++ b/include/net/ip_tunnels.h
541  - {  @@ -40,6 +40,7 @@ struct ip_tunnel_prl_entry {
542  - .procname = "ldt16",  
543  - .data = &sysctl_ldt16,   struct ip_tunnel_dst {
544  - .maxlen = sizeof(int),   struct dst_entry __rcu *dst;
545  - .mode = 0644,  + __be32 saddr;
 - .proc_handler = proc_dointvec  
 - },  
  {}  
546   };   };
547    
548  diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c   struct ip_tunnel {
549  index 0982233b9b84..a6a72ce8630f 100644  diff --git a/include/net/ipv6.h b/include/net/ipv6.h
550  --- a/arch/x86/xen/setup.c  index d640925bc454..d6815688ad9e 100644
551  +++ b/arch/x86/xen/setup.c  --- a/include/net/ipv6.h
552  @@ -574,13 +574,7 @@ void xen_enable_syscall(void)  +++ b/include/net/ipv6.h
553   }  @@ -660,8 +660,6 @@ static inline int ipv6_addr_diff(const struct in6_addr *a1, const struct in6_add
554   #endif /* CONFIG_X86_64 */   return __ipv6_addr_diff(a1, a2, sizeof(struct in6_addr));
555   }   }
 -void xen_enable_nmi(void)  
 -{  
 -#ifdef CONFIG_X86_64  
 - if (register_callback(CALLBACKTYPE_nmi, (char *)nmi))  
 - BUG();  
 -#endif  
 -}  
 +  
  void __init xen_pvmmu_arch_setup(void)  
  {  
  HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_4gb_segments);  
 @@ -595,7 +589,6 @@ void __init xen_pvmmu_arch_setup(void)  
556    
557   xen_enable_sysenter();  -void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt);
558   xen_enable_syscall();  -
559  - xen_enable_nmi();   int ip6_dst_hoplimit(struct dst_entry *dst);
  }  
560    
561   /* This function is not called for HVM domains */   /*
562  diff --git a/arch/xtensa/kernel/vectors.S b/arch/xtensa/kernel/vectors.S  diff --git a/include/net/secure_seq.h b/include/net/secure_seq.h
563  index f9e1ec346e35..8453e6e39895 100644  index f257486f17be..3f36d45b714a 100644
564  --- a/arch/xtensa/kernel/vectors.S  --- a/include/net/secure_seq.h
565  +++ b/arch/xtensa/kernel/vectors.S  +++ b/include/net/secure_seq.h
566  @@ -376,38 +376,42 @@ _DoubleExceptionVector_WindowOverflow:  @@ -3,8 +3,6 @@
567   beqz a2, 1f # if at start of vector, don't restore  
568     #include <linux/types.h>
569   addi a0, a0, -128  
570  - bbsi a0, 8, 1f # don't restore except for overflow 8 and 12  -__u32 secure_ip_id(__be32 daddr);
571  - bbsi a0, 7, 2f  -__u32 secure_ipv6_id(const __be32 daddr[4]);
572  + bbsi.l a0, 8, 1f # don't restore except for overflow 8 and 12   u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport);
573  +   u32 secure_ipv6_port_ephemeral(const __be32 *saddr, const __be32 *daddr,
574  + /*         __be16 dport);
575  + * This fixup handler is for the extremely unlikely case where the  diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c
576  + * overflow handler's reference thru a0 gets a hardware TLB refill  index f14e54a05691..022d18ab27a6 100644
577  + * that bumps out the (distinct, aliasing) TLB entry that mapped its  --- a/net/batman-adv/fragmentation.c
578  + * prior references thru a9/a13, and where our reference now thru  +++ b/net/batman-adv/fragmentation.c
579  + * a9/a13 gets a 2nd-level miss exception (not hardware TLB refill).  @@ -128,6 +128,7 @@ static bool batadv_frag_insert_packet(struct batadv_orig_node *orig_node,
580  + */   {
581  + movi a2, window_overflow_restore_a0_fixup   struct batadv_frag_table_entry *chain;
582  + s32i a2, a3, EXC_TABLE_FIXUP   struct batadv_frag_list_entry *frag_entry_new = NULL, *frag_entry_curr;
583  + l32i a2, a3, EXC_TABLE_DOUBLE_SAVE  + struct batadv_frag_list_entry *frag_entry_last = NULL;
584  + xsr a3, excsave1   struct batadv_frag_packet *frag_packet;
585     uint8_t bucket;
586     uint16_t seqno, hdr_size = sizeof(struct batadv_frag_packet);
587    @@ -180,11 +181,14 @@ static bool batadv_frag_insert_packet(struct batadv_orig_node *orig_node,
588     ret = true;
589     goto out;
590     }
591  +  +
592  + bbsi.l a0, 7, 2f  + /* store current entry because it could be the last in list */
593    + frag_entry_last = frag_entry_curr;
594   /*   }
  * Restore a0 as saved by _WindowOverflow8().  
 - *  
 - * FIXME:  we really need a fixup handler for this L32E,  
 - * for the extremely unlikely case where the overflow handler's  
 - * reference thru a0 gets a hardware TLB refill that bumps out  
 - * the (distinct, aliasing) TLB entry that mapped its prior  
 - * references thru a9, and where our reference now thru a9  
 - * gets a 2nd-level miss exception (not hardware TLB refill).  
  */  
   
 - l32e a2, a9, -16  
 - wsr a2, depc # replace the saved a0  
 - j 1f  
 + l32e a0, a9, -16  
 + wsr a0, depc # replace the saved a0  
 + j 3f  
595    
596   2:  - /* Reached the end of the list, so insert after 'frag_entry_curr'. */
597   /*  - if (likely(frag_entry_curr)) {
598   * Restore a0 as saved by _WindowOverflow12().  - hlist_add_after(&frag_entry_curr->list, &frag_entry_new->list);
599  - *  + /* Reached the end of the list, so insert after 'frag_entry_last'. */
600  - * FIXME:  we really need a fixup handler for this L32E,  + if (likely(frag_entry_last)) {
601  - * for the extremely unlikely case where the overflow handler's  + hlist_add_after(&frag_entry_last->list, &frag_entry_new->list);
602  - * reference thru a0 gets a hardware TLB refill that bumps out   chain->size += skb->len - hdr_size;
603  - * the (distinct, aliasing) TLB entry that mapped its prior   chain->timestamp = jiffies;
604  - * references thru a13, and where our reference now thru a13   ret = true;
605  - * gets a 2nd-level miss exception (not hardware TLB refill).  diff --git a/net/compat.c b/net/compat.c
606   */  index 9a76eaf63184..bc8aeefddf3f 100644
607    --- a/net/compat.c
608    +++ b/net/compat.c
609    @@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
610     {
611     int tot_len;
612    
613  - l32e a2, a13, -16  - if (kern_msg->msg_namelen) {
614  - wsr a2, depc # replace the saved a0  + if (kern_msg->msg_name && kern_msg->msg_namelen) {
615  + l32e a0, a13, -16   if (mode == VERIFY_READ) {
616  + wsr a0, depc # replace the saved a0   int err = move_addr_to_kernel(kern_msg->msg_name,
617  +3:        kern_msg->msg_namelen,
618  + xsr a3, excsave1  @@ -93,10 +93,11 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
619  + movi a0, 0   if (err < 0)
620  + s32i a0, a3, EXC_TABLE_FIXUP   return err;
621  + s32i a2, a3, EXC_TABLE_DOUBLE_SAVE   }
622   1:  - if (kern_msg->msg_name)
623   /*  - kern_msg->msg_name = kern_address;
624   * Restore WindowBase while leaving all address registers restored.  - } else
625  @@ -449,6 +453,7 @@ _DoubleExceptionVector_WindowOverflow:  + kern_msg->msg_name = kern_address;
626    + } else {
627     kern_msg->msg_name = NULL;
628    + kern_msg->msg_namelen = 0;
629    + }
630    
631   s32i a0, a2, PT_DEPC   tot_len = iov_from_user_compat_to_kern(kern_iov,
632      (struct compat_iovec __user *)kern_msg->msg_iov,
633    diff --git a/net/core/iovec.c b/net/core/iovec.c
634    index b61869429f4c..26dc0062652f 100644
635    --- a/net/core/iovec.c
636    +++ b/net/core/iovec.c
637    @@ -39,7 +39,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
638     {
639     int size, ct, err;
640    
641  +_DoubleExceptionVector_handle_exception:  - if (m->msg_namelen) {
642   addx4 a0, a0, a3  + if (m->msg_name && m->msg_namelen) {
643   l32i a0, a0, EXC_TABLE_FAST_USER   if (mode == VERIFY_READ) {
644   xsr a3, excsave1   void __user *namep;
645  @@ -464,11 +469,120 @@ _DoubleExceptionVector_WindowOverflow:   namep = (void __user __force *) m->msg_name;
646   rotw -3  @@ -48,10 +48,10 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
647   j 1b   if (err < 0)
648     return err;
649     }
650    - if (m->msg_name)
651    - m->msg_name = address;
652    + m->msg_name = address;
653     } else {
654     m->msg_name = NULL;
655    + m->msg_namelen = 0;
656     }
657    
658  - .end literal_prefix   size = m->msg_iovlen * sizeof(struct iovec);
659    @@ -107,6 +107,10 @@ EXPORT_SYMBOL(memcpy_toiovecend);
660     int memcpy_fromiovecend(unsigned char *kdata, const struct iovec *iov,
661     int offset, int len)
662     {
663    + /* No data? Done! */
664    + if (len == 0)
665    + return 0;
666    +
667     /* Skip over the finished iovecs */
668     while (offset >= iov->iov_len) {
669     offset -= iov->iov_len;
670    diff --git a/net/core/secure_seq.c b/net/core/secure_seq.c
671    index 897da56f3aff..ba71212f0251 100644
672    --- a/net/core/secure_seq.c
673    +++ b/net/core/secure_seq.c
674    @@ -85,31 +85,6 @@ EXPORT_SYMBOL(secure_ipv6_port_ephemeral);
675     #endif
676    
677   ENDPROC(_DoubleExceptionVector)   #ifdef CONFIG_INET
678    -__u32 secure_ip_id(__be32 daddr)
679    -{
680    - u32 hash[MD5_DIGEST_WORDS];
681    -
682    - net_secret_init();
683    - hash[0] = (__force __u32) daddr;
684    - hash[1] = net_secret[13];
685    - hash[2] = net_secret[14];
686    - hash[3] = net_secret[15];
687    -
688    - md5_transform(hash, net_secret);
689    -
690    - return hash[0];
691    -}
692    -
693    -__u32 secure_ipv6_id(const __be32 daddr[4])
694    -{
695    - __u32 hash[4];
696    -
697    - net_secret_init();
698    - memcpy(hash, daddr, 16);
699    - md5_transform(hash, net_secret);
700    -
701    - return hash[0];
702    -}
703    
704   /*   __u32 secure_tcp_sequence_number(__be32 saddr, __be32 daddr,
705  + * Fixup handler for TLB miss in double exception handler for window owerflow.   __be16 sport, __be16 dport)
706  + * We get here with windowbase set to the window that was being spilled and  diff --git a/net/core/skbuff.c b/net/core/skbuff.c
707  + * a0 trashed. a0 bit 7 determines if this is a call8 (bit clear) or call12  index 9433047b2453..6ab5f7721cdb 100644
708  + * (bit set) window.  --- a/net/core/skbuff.c
709  + *  +++ b/net/core/skbuff.c
710  + * We do the following here:  @@ -2968,9 +2968,9 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb,
711  + * - go to the original window retaining a0 value;   tail = nskb;
712  + * - set up exception stack to return back to appropriate a0 restore code  
713  + *   (we'll need to rotate window back and there's no place to save this   __copy_skb_header(nskb, head_skb);
714  + *    information, use different return address for that);  - nskb->mac_len = head_skb->mac_len;
715  + * - handle the exception;  
716  + * - go to the window that was being spilled;   skb_headers_offset_update(nskb, skb_headroom(nskb) - headroom);
717  + * - set up window_overflow_restore_a0_fixup as a fixup routine;  + skb_reset_mac_len(nskb);
718  + * - reload a0;  
719  + * - restore the original window;   skb_copy_from_linear_data_offset(head_skb, -tnl_hlen,
720  + * - reset the default fixup routine;   nskb->data - tnl_hlen,
721  + * - return to user. By the time we get to this fixup handler all information  diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
722  + *   about the conditions of the original double exception that happened in  index 9db3b877fcaf..0ffcd4d64e0a 100644
723  + *   the window overflow handler is lost, so we just return to userspace to  --- a/net/ipv4/igmp.c
724  + *   retry overflow from start.  +++ b/net/ipv4/igmp.c
725  + *  @@ -369,7 +369,7 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, int size)
726  + * a0: value of depc, original value in depc   pip->saddr    = fl4.saddr;
727  + * a2: trashed, original value in EXC_TABLE_DOUBLE_SAVE   pip->protocol = IPPROTO_IGMP;
728  + * a3: exctable, original value in excsave1   pip->tot_len  = 0; /* filled in later */
729  + */  - ip_select_ident(skb, &rt->dst, NULL);
730  +  + ip_select_ident(skb, NULL);
731  +ENTRY(window_overflow_restore_a0_fixup)   ((u8 *)&pip[1])[0] = IPOPT_RA;
732  +   ((u8 *)&pip[1])[1] = 4;
733  + rsr a0, ps   ((u8 *)&pip[1])[2] = 0;
734  + extui a0, a0, PS_OWB_SHIFT, PS_OWB_WIDTH  @@ -714,7 +714,7 @@ static int igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc,
735  + rsr a2, windowbase   iph->daddr    = dst;
736  + sub a0, a2, a0   iph->saddr    = fl4.saddr;
737  + extui a0, a0, 0, 3   iph->protocol = IPPROTO_IGMP;
738  + l32i a2, a3, EXC_TABLE_DOUBLE_SAVE  - ip_select_ident(skb, &rt->dst, NULL);
739  + xsr a3, excsave1  + ip_select_ident(skb, NULL);
740  +   ((u8 *)&iph[1])[0] = IPOPT_RA;
741  + _beqi a0, 1, .Lhandle_1   ((u8 *)&iph[1])[1] = 4;
742  + _beqi a0, 3, .Lhandle_3   ((u8 *)&iph[1])[2] = 0;
743  +  diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
744  + .macro overflow_fixup_handle_exception_pane n  index 48f424465112..bf2cb4a4714b 100644
745  +  --- a/net/ipv4/inetpeer.c
746  + rsr a0, depc  +++ b/net/ipv4/inetpeer.c
747  + rotw -\n  @@ -26,20 +26,7 @@
748  +    *  Theory of operations.
749  + xsr a3, excsave1    *  We keep one entry for each peer IP address.  The nodes contains long-living
750  + wsr a2, depc    *  information about the peer which doesn't depend on routes.
751  + l32i a2, a3, EXC_TABLE_KSTK  - *  At this moment this information consists only of ID field for the next
752  + s32i a0, a2, PT_AREG0  - *  outgoing IP packet.  This field is incremented with each packet as encoded
753  +  - *  in inet_getid() function (include/net/inetpeer.h).
754  + movi a0, .Lrestore_\n  - *  At the moment of writing this notes identifier of IP packets is generated
755  + s32i a0, a2, PT_DEPC  - *  to be unpredictable using this code only for packets subjected
756  + rsr a0, exccause  - *  (actually or potentially) to defragmentation.  I.e. DF packets less than
757  + j _DoubleExceptionVector_handle_exception  - *  PMTU in size when local fragmentation is disabled use a constant ID and do
758  +  - *  not use this code (see ip_select_ident() in include/net/ip.h).
 + .endm  
 +  
 + overflow_fixup_handle_exception_pane 2  
 +.Lhandle_1:  
 + overflow_fixup_handle_exception_pane 1  
 +.Lhandle_3:  
 + overflow_fixup_handle_exception_pane 3  
 +  
 + .macro overflow_fixup_restore_a0_pane n  
 +  
 + rotw \n  
 + /* Need to preserve a0 value here to be able to handle exception  
 + * that may occur on a0 reload from stack. It may occur because  
 + * TLB miss handler may not be atomic and pointer to page table  
 + * may be lost before we get here. There are no free registers,  
 + * so we need to use EXC_TABLE_DOUBLE_SAVE area.  
 + */  
 + xsr a3, excsave1  
 + s32i a2, a3, EXC_TABLE_DOUBLE_SAVE  
 + movi a2, window_overflow_restore_a0_fixup  
 + s32i a2, a3, EXC_TABLE_FIXUP  
 + l32i a2, a3, EXC_TABLE_DOUBLE_SAVE  
 + xsr a3, excsave1  
 + bbsi.l a0, 7, 1f  
 + l32e a0, a9, -16  
 + j 2f  
 +1:  
 + l32e a0, a13, -16  
 +2:  
 + rotw -\n  
 +  
 + .endm  
 +  
 +.Lrestore_2:  
 + overflow_fixup_restore_a0_pane 2  
 +  
 +.Lset_default_fixup:  
 + xsr a3, excsave1  
 + s32i a2, a3, EXC_TABLE_DOUBLE_SAVE  
 + movi a2, 0  
 + s32i a2, a3, EXC_TABLE_FIXUP  
 + l32i a2, a3, EXC_TABLE_DOUBLE_SAVE  
 + xsr a3, excsave1  
 + rfe  
 +  
 +.Lrestore_1:  
 + overflow_fixup_restore_a0_pane 1  
 + j .Lset_default_fixup  
 +.Lrestore_3:  
 + overflow_fixup_restore_a0_pane 3  
 + j .Lset_default_fixup  
 +  
 +ENDPROC(window_overflow_restore_a0_fixup)  
 +  
 + .end literal_prefix  
 +/*  
   * Debug interrupt vector  
759    *    *
760    * There is not much space here, so simply jump to another handler.  - *  Route cache entries hold references to our nodes.
761  diff --git a/arch/xtensa/kernel/vmlinux.lds.S b/arch/xtensa/kernel/vmlinux.lds.S  - *  New cache entries get references via lookup by destination IP address in
762  index ee32c0085dff..d16db6df86f8 100644  - *  the avl tree.  The reference is grabbed only when it's needed i.e. only
763  --- a/arch/xtensa/kernel/vmlinux.lds.S  - *  when we try to output IP packet which needs an unpredictable ID (see
764  +++ b/arch/xtensa/kernel/vmlinux.lds.S  - *  __ip_select_ident() in net/ipv4/route.c).
765  @@ -269,13 +269,13 @@ SECTIONS    *  Nodes are removed only when reference counter goes to 0.
766    .UserExceptionVector.literal)    *  When it's happened the node may be removed when a sufficient amount of
767     SECTION_VECTOR (_DoubleExceptionVector_literal,    *  time has been passed since its last use.  The less-recently-used entry can
768    .DoubleExceptionVector.literal,  @@ -62,7 +49,6 @@
769  -  DOUBLEEXC_VECTOR_VADDR - 16,    * refcnt: atomically against modifications on other CPU;
770  +  DOUBLEEXC_VECTOR_VADDR - 40,    *   usually under some other lock to prevent node disappearing
771    SIZEOF(.UserExceptionVector.text),    * daddr: unchangeable
772    .UserExceptionVector.text)  - * ip_id_count: atomic value (no lock needed)
773     SECTION_VECTOR (_DoubleExceptionVector_text,    */
   .DoubleExceptionVector.text,  
   DOUBLEEXC_VECTOR_VADDR,  
 -  32,  
 +  40,  
   .DoubleExceptionVector.literal)  
   
    . = (LOADADDR( .DoubleExceptionVector.text ) + SIZEOF( .DoubleExceptionVector.text ) + 3) & ~ 3;  
 diff --git a/crypto/af_alg.c b/crypto/af_alg.c  
 index 966f893711b3..6a3ad8011585 100644  
 --- a/crypto/af_alg.c  
 +++ b/crypto/af_alg.c  
 @@ -21,6 +21,7 @@  
  #include <linux/module.h>  
  #include <linux/net.h>  
  #include <linux/rwsem.h>  
 +#include <linux/security.h>  
   
  struct alg_type_list {  
  const struct af_alg_type *type;  
 @@ -243,6 +244,7 @@ int af_alg_accept(struct sock *sk, struct socket *newsock)  
   
  sock_init_data(newsock, sk2);  
  sock_graft(sk2, newsock);  
 + security_sk_clone(sk, sk2);  
   
  err = type->accept(ask->private, sk2);  
  if (err) {  
 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c  
 index b91dfbe9fe8e..c83eb75c7cfc 100644  
 --- a/drivers/gpu/drm/i915/intel_display.c  
 +++ b/drivers/gpu/drm/i915/intel_display.c  
 @@ -11251,6 +11251,9 @@ static struct intel_quirk intel_quirks[] = {  
   
  /* Toshiba CB35 Chromebook (Celeron 2955U) */  
  { 0x0a06, 0x1179, 0x0a88, quirk_backlight_present },  
 +  
 + /* HP Chromebook 14 (Celeron 2955U) */  
 + { 0x0a06, 0x103c, 0x21ed, quirk_backlight_present },  
  };  
774    
775   static void intel_init_quirks(struct drm_device *dev)   static struct kmem_cache *peer_cachep __read_mostly;
776  diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c  @@ -497,10 +483,6 @@ relookup:
777  index a7e68c81f89d..a077cc86421b 100644   p->daddr = *daddr;
778  --- a/drivers/iio/accel/bma180.c   atomic_set(&p->refcnt, 1);
779  +++ b/drivers/iio/accel/bma180.c   atomic_set(&p->rid, 0);
780  @@ -68,13 +68,13 @@  - atomic_set(&p->ip_id_count,
781   /* Defaults values */  - (daddr->family == AF_INET) ?
782   #define BMA180_DEF_PMODE 0  - secure_ip_id(daddr->addr.a4) :
783   #define BMA180_DEF_BW 20  - secure_ipv6_id(daddr->addr.a6));
784  -#define BMA180_DEF_SCALE 250   p->metrics[RTAX_LOCK-1] = INETPEER_METRICS_NEW;
785  +#define BMA180_DEF_SCALE 2452   p->rate_tokens = 0;
786     /* 60*HZ is arbitrary, but chosen enough high so that the first
787   /* Available values for sysfs */  diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
788   #define BMA180_FLP_FREQ_AVAILABLE \  index a52f50187b54..4ecc1600f84d 100644
789   "10 20 40 75 150 300"  --- a/net/ipv4/ip_output.c
790   #define BMA180_SCALE_AVAILABLE \  +++ b/net/ipv4/ip_output.c
791  - "0.000130 0.000190 0.000250 0.000380 0.000500 0.000990 0.001980"  @@ -148,7 +148,7 @@ int ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk,
792  + "0.001275 0.001863 0.002452 0.003727 0.004903 0.009709 0.019417"   iph->daddr    = (opt && opt->opt.srr ? opt->opt.faddr : daddr);
793     iph->saddr    = saddr;
794   struct bma180_data {   iph->protocol = sk->sk_protocol;
795   struct i2c_client *client;  - ip_select_ident(skb, &rt->dst, sk);
796  @@ -94,7 +94,7 @@ enum bma180_axis {  + ip_select_ident(skb, sk);
797   };  
798     if (opt && opt->opt.optlen) {
799     iph->ihl += opt->opt.optlen>>2;
800    @@ -430,8 +430,7 @@ packet_routed:
801     ip_options_build(skb, &inet_opt->opt, inet->inet_daddr, rt, 0);
802     }
803    
804   static int bw_table[] = { 10, 20, 40, 75, 150, 300 }; /* Hz */  - ip_select_ident_more(skb, &rt->dst, sk,
805  -static int scale_table[] = { 130, 190, 250, 380, 500, 990, 1980 };  -     (skb_shinfo(skb)->gso_segs ?: 1) - 1);
806  +static int scale_table[] = { 1275, 1863, 2452, 3727, 4903, 9709, 19417 };  + ip_select_ident_segs(skb, sk, skb_shinfo(skb)->gso_segs ?: 1);
807    
808     /* TODO : should we use skb->sk here instead of sk ? */
809     skb->priority = sk->sk_priority;
810    @@ -1379,7 +1378,7 @@ struct sk_buff *__ip_make_skb(struct sock *sk,
811     iph->ttl = ttl;
812     iph->protocol = sk->sk_protocol;
813     ip_copy_addrs(iph, fl4);
814    - ip_select_ident(skb, &rt->dst, sk);
815    + ip_select_ident(skb, sk);
816    
817     if (opt) {
818     iph->ihl += opt->optlen>>2;
819    diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
820    index b77b6a55b05e..e3e3a91f249e 100644
821    --- a/net/ipv4/ip_tunnel.c
822    +++ b/net/ipv4/ip_tunnel.c
823    @@ -69,23 +69,25 @@ static unsigned int ip_tunnel_hash(__be32 key, __be32 remote)
824     }
825    
826   static int bma180_get_acc_reg(struct bma180_data *data, enum bma180_axis axis)   static void __tunnel_dst_set(struct ip_tunnel_dst *idst,
827    -     struct dst_entry *dst)
828    +     struct dst_entry *dst, __be32 saddr)
829   {   {
830  @@ -376,6 +376,8 @@ static int bma180_write_raw(struct iio_dev *indio_dev,   struct dst_entry *old_dst;
  mutex_unlock(&data->mutex);  
  return ret;  
  case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:  
 + if (val2)  
 + return -EINVAL;  
  mutex_lock(&data->mutex);  
  ret = bma180_set_bw(data, val);  
  mutex_unlock(&data->mutex);  
 diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c  
 index e472cff6eeae..476b5a333066 100644  
 --- a/drivers/iio/industrialio-buffer.c  
 +++ b/drivers/iio/industrialio-buffer.c  
 @@ -949,7 +949,7 @@ static int iio_buffer_update_demux(struct iio_dev *indio_dev,  
   
  /* Now we have the two masks, work from least sig and build up sizes */  
  for_each_set_bit(out_ind,  
 - indio_dev->active_scan_mask,  
 + buffer->scan_mask,  
  indio_dev->masklength) {  
  in_ind = find_next_bit(indio_dev->active_scan_mask,  
        indio_dev->masklength,  
 diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c  
 index 66c5d130c8c2..0e722c103562 100644  
 --- a/drivers/md/dm-bufio.c  
 +++ b/drivers/md/dm-bufio.c  
 @@ -1541,7 +1541,7 @@ struct dm_bufio_client *dm_bufio_client_create(struct block_device *bdev, unsign  
  BUG_ON(block_size < 1 << SECTOR_SHIFT ||  
        (block_size & (block_size - 1)));  
   
 - c = kmalloc(sizeof(*c), GFP_KERNEL);  
 + c = kzalloc(sizeof(*c), GFP_KERNEL);  
  if (!c) {  
  r = -ENOMEM;  
  goto bad_client;  
 diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c  
 index 5f054c44b485..2c63326638b6 100644  
 --- a/drivers/md/dm-cache-target.c  
 +++ b/drivers/md/dm-cache-target.c  
 @@ -231,7 +231,7 @@ struct cache {  
  /*  
  * cache_size entries, dirty if set  
  */  
 - dm_cblock_t nr_dirty;  
 + atomic_t nr_dirty;  
  unsigned long *dirty_bitset;  
831    
832   /*   dst_clone(dst);
833  @@ -492,7 +492,7 @@ static bool is_dirty(struct cache *cache, dm_cblock_t b)   old_dst = xchg((__force struct dst_entry **)&idst->dst, dst);
834   static void set_dirty(struct cache *cache, dm_oblock_t oblock, dm_cblock_t cblock)   dst_release(old_dst);
835   {  + idst->saddr = saddr;
  if (!test_and_set_bit(from_cblock(cblock), cache->dirty_bitset)) {  
 - cache->nr_dirty = to_cblock(from_cblock(cache->nr_dirty) + 1);  
 + atomic_inc(&cache->nr_dirty);  
  policy_set_dirty(cache->policy, oblock);  
  }  
836   }   }
837  @@ -501,8 +501,7 @@ static void clear_dirty(struct cache *cache, dm_oblock_t oblock, dm_cblock_t cbl  
838    -static void tunnel_dst_set(struct ip_tunnel *t, struct dst_entry *dst)
839    +static void tunnel_dst_set(struct ip_tunnel *t,
840    +   struct dst_entry *dst, __be32 saddr)
841   {   {
842   if (test_and_clear_bit(from_cblock(cblock), cache->dirty_bitset)) {  - __tunnel_dst_set(this_cpu_ptr(t->dst_cache), dst);
843   policy_clear_dirty(cache->policy, oblock);  + __tunnel_dst_set(this_cpu_ptr(t->dst_cache), dst, saddr);
 - cache->nr_dirty = to_cblock(from_cblock(cache->nr_dirty) - 1);  
 - if (!from_cblock(cache->nr_dirty))  
 + if (atomic_dec_return(&cache->nr_dirty) == 0)  
  dm_table_event(cache->ti->table);  
  }  
844   }   }
 @@ -2269,7 +2268,7 @@ static int cache_create(struct cache_args *ca, struct cache **result)  
  atomic_set(&cache->quiescing_ack, 0);  
845    
846   r = -ENOMEM;   static void tunnel_dst_reset(struct ip_tunnel *t)
847  - cache->nr_dirty = 0;   {
848  + atomic_set(&cache->nr_dirty, 0);  - tunnel_dst_set(t, NULL);
849   cache->dirty_bitset = alloc_bitset(from_cblock(cache->cache_size));  + tunnel_dst_set(t, NULL, 0);
  if (!cache->dirty_bitset) {  
  *error = "could not allocate dirty bitset";  
 @@ -2808,7 +2807,7 @@ static void cache_status(struct dm_target *ti, status_type_t type,  
   
  residency = policy_residency(cache->policy);  
   
 - DMEMIT("%u %llu/%llu %u %llu/%llu %u %u %u %u %u %u %llu ",  
 + DMEMIT("%u %llu/%llu %u %llu/%llu %u %u %u %u %u %u %lu ",  
        (unsigned)(DM_CACHE_METADATA_BLOCK_SIZE >> SECTOR_SHIFT),  
        (unsigned long long)(nr_blocks_metadata - nr_free_blocks_metadata),  
        (unsigned long long)nr_blocks_metadata,  
 @@ -2821,7 +2820,7 @@ static void cache_status(struct dm_target *ti, status_type_t type,  
        (unsigned) atomic_read(&cache->stats.write_miss),  
        (unsigned) atomic_read(&cache->stats.demotion),  
        (unsigned) atomic_read(&cache->stats.promotion),  
 -       (unsigned long long) from_cblock(cache->nr_dirty));  
 +       (unsigned long) atomic_read(&cache->nr_dirty));  
   
  if (writethrough_mode(&cache->features))  
  DMEMIT("1 writethrough ");  
 diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c  
 index 66acb2cbd9df..7c28cb55610b 100644  
 --- a/drivers/net/wireless/ath/ath9k/xmit.c  
 +++ b/drivers/net/wireless/ath/ath9k/xmit.c  
 @@ -887,6 +887,15 @@ ath_tx_get_tid_subframe(struct ath_softc *sc, struct ath_txq *txq,  
   
  tx_info = IEEE80211_SKB_CB(skb);  
  tx_info->flags &= ~IEEE80211_TX_CTL_CLEAR_PS_FILT;  
 +  
 + /*  
 + * No aggregation session is running, but there may be frames  
 + * from a previous session or a failed attempt in the queue.  
 + * Send them out as normal data frames  
 + */  
 + if (!tid->active)  
 + tx_info->flags &= ~IEEE80211_TX_CTL_AMPDU;  
 +  
  if (!(tx_info->flags & IEEE80211_TX_CTL_AMPDU)) {  
  bf->bf_state.bf_type = 0;  
  return bf;  
 diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c  
 index c31aa07b3ba5..da1c6cb1a41e 100644  
 --- a/drivers/pnp/pnpacpi/core.c  
 +++ b/drivers/pnp/pnpacpi/core.c  
 @@ -339,8 +339,7 @@ static int __init acpi_pnp_match(struct device *dev, void *_pnp)  
  struct pnp_dev *pnp = _pnp;  
   
  /* true means it matched */  
 - return !acpi->physical_node_count  
 -    && compare_pnp_id(pnp->id, acpi_device_hid(acpi));  
 + return pnp->data == acpi;  
850   }   }
851    
852   static struct acpi_device * __init acpi_pnp_find_companion(struct device *dev)   void ip_tunnel_dst_reset_all(struct ip_tunnel *t)
853  diff --git a/drivers/rapidio/devices/tsi721_dma.c b/drivers/rapidio/devices/tsi721_dma.c  @@ -93,20 +95,25 @@ void ip_tunnel_dst_reset_all(struct ip_tunnel *t)
854  index 9b60b1f3261c..44341dc5b148 100644   int i;
855  --- a/drivers/rapidio/devices/tsi721_dma.c  
856  +++ b/drivers/rapidio/devices/tsi721_dma.c   for_each_possible_cpu(i)
857  @@ -287,6 +287,12 @@ struct tsi721_tx_desc *tsi721_desc_get(struct tsi721_bdma_chan *bdma_chan)  - __tunnel_dst_set(per_cpu_ptr(t->dst_cache, i), NULL);
858   "desc %p not ACKed\n", tx_desc);  + __tunnel_dst_set(per_cpu_ptr(t->dst_cache, i), NULL, 0);
859   }   }
860     EXPORT_SYMBOL(ip_tunnel_dst_reset_all);
861    
862  + if (ret == NULL) {  -static struct rtable *tunnel_rtable_get(struct ip_tunnel *t, u32 cookie)
863  + dev_dbg(bdma_chan->dchan.device->dev,  +static struct rtable *tunnel_rtable_get(struct ip_tunnel *t,
864  + "%s: unable to obtain tx descriptor\n", __func__);  + u32 cookie, __be32 *saddr)
865  + goto err_out;   {
866  + }  + struct ip_tunnel_dst *idst;
867  +   struct dst_entry *dst;
  i = bdma_chan->wr_count_next % bdma_chan->bd_num;  
  if (i == bdma_chan->bd_num - 1) {  
  i = 0;  
 @@ -297,7 +303,7 @@ struct tsi721_tx_desc *tsi721_desc_get(struct tsi721_bdma_chan *bdma_chan)  
  tx_desc->txd.phys = bdma_chan->bd_phys +  
  i * sizeof(struct tsi721_dma_desc);  
  tx_desc->hw_desc = &((struct tsi721_dma_desc *)bdma_chan->bd_base)[i];  
 -  
 +err_out:  
  spin_unlock_bh(&bdma_chan->lock);  
868    
869   return ret;   rcu_read_lock();
870  diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c  - dst = rcu_dereference(this_cpu_ptr(t->dst_cache)->dst);
871  index 9db097a28a74..d99ab3bfaaee 100644  + idst = this_cpu_ptr(t->dst_cache);
872  --- a/drivers/scsi/scsi_lib.c  + dst = rcu_dereference(idst->dst);
873  +++ b/drivers/scsi/scsi_lib.c   if (dst && !atomic_inc_not_zero(&dst->__refcnt))
874  @@ -806,6 +806,14 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)   dst = NULL;
875   scsi_next_command(cmd);   if (dst) {
876   return;  - if (dst->obsolete && dst->ops->check(dst, cookie) == NULL) {
877    + if (!dst->obsolete || dst->ops->check(dst, cookie)) {
878    + *saddr = idst->saddr;
879    + } else {
880     tunnel_dst_reset(t);
881     dst_release(dst);
882     dst = NULL;
883    @@ -366,7 +373,7 @@ static int ip_tunnel_bind_dev(struct net_device *dev)
884    
885     if (!IS_ERR(rt)) {
886     tdev = rt->dst.dev;
887    - tunnel_dst_set(tunnel, &rt->dst);
888    + tunnel_dst_set(tunnel, &rt->dst, fl4.saddr);
889     ip_rt_put(rt);
890     }
891     if (dev->type != ARPHRD_ETHER)
892    @@ -610,7 +617,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
893     init_tunnel_flow(&fl4, protocol, dst, tnl_params->saddr,
894     tunnel->parms.o_key, RT_TOS(tos), tunnel->parms.link);
895    
896    - rt = connected ? tunnel_rtable_get(tunnel, 0) : NULL;
897    + rt = connected ? tunnel_rtable_get(tunnel, 0, &fl4.saddr) : NULL;
898    
899     if (!rt) {
900     rt = ip_route_output_key(tunnel->net, &fl4);
901    @@ -620,7 +627,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
902     goto tx_error;
903   }   }
904  + } else if (blk_rq_bytes(req) == 0 && result && !sense_deferred) {   if (connected)
905  + /*  - tunnel_dst_set(tunnel, &rt->dst);
906  + * Certain non BLOCK_PC requests are commands that don't  + tunnel_dst_set(tunnel, &rt->dst, fl4.saddr);
 + * actually transfer anything (FLUSH), so cannot use  
 + * good_bytes != blk_rq_bytes(req) as the signal for an error.  
 + * This sets the error explicitly for the problem case.  
 + */  
 + error = __scsi_error_from_host_byte(cmd, result);  
907   }   }
908    
909   /* no bidi support for !REQ_TYPE_BLOCK_PC yet */   if (rt->dst.dev == dev) {
910  diff --git a/drivers/staging/vt6655/bssdb.c b/drivers/staging/vt6655/bssdb.c  diff --git a/net/ipv4/ip_tunnel_core.c b/net/ipv4/ip_tunnel_core.c
911  index d7efd0173a9a..7d7578872a84 100644  index bcf206c79005..847e69cbff7e 100644
912  --- a/drivers/staging/vt6655/bssdb.c  --- a/net/ipv4/ip_tunnel_core.c
913  +++ b/drivers/staging/vt6655/bssdb.c  +++ b/net/ipv4/ip_tunnel_core.c
914  @@ -983,7 +983,7 @@ start:  @@ -74,7 +74,7 @@ int iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb,
915   pDevice->byERPFlag &= ~(WLAN_SET_ERP_USE_PROTECTION(1));   iph->daddr = dst;
916   }   iph->saddr = src;
917     iph->ttl = ttl;
918    - __ip_select_ident(iph, &rt->dst, (skb_shinfo(skb)->gso_segs ?: 1) - 1);
919    + __ip_select_ident(iph, skb_shinfo(skb)->gso_segs ?: 1);
920    
921     err = ip_local_out_sk(sk, skb);
922     if (unlikely(net_xmit_eval(err)))
923    diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
924    index d84dc8d4c916..d11a50d24295 100644
925    --- a/net/ipv4/ipmr.c
926    +++ b/net/ipv4/ipmr.c
927    @@ -1663,7 +1663,7 @@ static void ip_encap(struct sk_buff *skb, __be32 saddr, __be32 daddr)
928     iph->protocol = IPPROTO_IPIP;
929     iph->ihl = 5;
930     iph->tot_len = htons(skb->len);
931    - ip_select_ident(skb, skb_dst(skb), NULL);
932    + ip_select_ident(skb, NULL);
933     ip_send_check(iph);
934    
935     memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
936    diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
937    index a9dbe58bdfe7..2c65160565e1 100644
938    --- a/net/ipv4/raw.c
939    +++ b/net/ipv4/raw.c
940    @@ -389,7 +389,7 @@ static int raw_send_hdrinc(struct sock *sk, struct flowi4 *fl4,
941     iph->check   = 0;
942     iph->tot_len = htons(length);
943     if (!iph->id)
944    - ip_select_ident(skb, &rt->dst, NULL);
945    + ip_select_ident(skb, NULL);
946    
947  - {   iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl);
 + if (pDevice->eCommandState == WLAN_ASSOCIATE_WAIT) {  
  pDevice->byReAssocCount++;  
  /* 10 sec timeout */  
  if ((pDevice->byReAssocCount > 10) && (!pDevice->bLinkPass)) {  
 diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c  
 index a952df1bf9d6..6f13f0e597f8 100644  
 --- a/drivers/staging/vt6655/device_main.c  
 +++ b/drivers/staging/vt6655/device_main.c  
 @@ -2430,6 +2430,7 @@ static  irqreturn_t  device_intr(int irq,  void *dev_instance) {  
  int             handled = 0;  
  unsigned char byData = 0;  
  int             ii = 0;  
 + unsigned long flags;  
  //    unsigned char byRSSI;  
   
  MACvReadISR(pDevice->PortOffset, &pDevice->dwIsr);  
 @@ -2455,7 +2456,8 @@ static  irqreturn_t  device_intr(int irq,  void *dev_instance) {  
   
  handled = 1;  
  MACvIntDisable(pDevice->PortOffset);  
 - spin_lock_irq(&pDevice->lock);  
 +  
 + spin_lock_irqsave(&pDevice->lock, flags);  
   
  //Make sure current page is 0  
  VNSvInPortB(pDevice->PortOffset + MAC_REG_PAGE1SEL, &byOrgPageSel);  
 @@ -2696,7 +2698,8 @@ static  irqreturn_t  device_intr(int irq,  void *dev_instance) {  
  MACvSelectPage1(pDevice->PortOffset);  
948   }   }
949    diff --git a/net/ipv4/route.c b/net/ipv4/route.c
950    index be9f2b1ac3ab..fd618d48f4ce 100644
951    --- a/net/ipv4/route.c
952    +++ b/net/ipv4/route.c
953    @@ -89,6 +89,7 @@
954     #include <linux/rcupdate.h>
955     #include <linux/times.h>
956     #include <linux/slab.h>
957    +#include <linux/jhash.h>
958     #include <net/dst.h>
959     #include <net/net_namespace.h>
960     #include <net/protocol.h>
961    @@ -456,39 +457,45 @@ static struct neighbour *ipv4_neigh_lookup(const struct dst_entry *dst,
962     return neigh_create(&arp_tbl, pkey, dev);
963     }
964    
965  - spin_unlock_irq(&pDevice->lock);  -/*
966  + spin_unlock_irqrestore(&pDevice->lock, flags);  - * Peer allocation may fail only in serious out-of-memory conditions.  However
967  +  - * we still can generate some output.
968   MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);  - * Random ID selection looks a bit dangerous because we have no chances to
969    - * select ID being unique in a reasonable period of time.
970   return IRQ_RETVAL(handled);  - * But broken packet identifier may be better than no packet at all.
971  diff --git a/fs/open.c b/fs/open.c  +#define IP_IDENTS_SZ 2048u
972  index 9d64679cec73..dd24f21d31f7 100644  +struct ip_ident_bucket {
973  --- a/fs/open.c  + atomic_t id;
974  +++ b/fs/open.c  + u32 stamp32;
975  @@ -263,11 +263,10 @@ int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len)  +};
976   return -EPERM;  +
977    +static struct ip_ident_bucket *ip_idents __read_mostly;
978   /*  +
979  - * We can not allow to do any fallocate operation on an active  +/* In order to protect privacy, we add a perturbation to identifiers
980  - * swapfile  + * if one generator is seldom used. This makes hard for an attacker
981  + * We cannot allow any fallocate operation on an active swapfile  + * to infer how many packets were sent between two points in time.
  */  
  if (IS_SWAPFILE(inode))  
 - ret = -ETXTBSY;  
 + return -ETXTBSY;  
   
  /*  
  * Revalidate the write permissions, in case security policy has  
 diff --git a/include/dt-bindings/pinctrl/dra.h b/include/dt-bindings/pinctrl/dra.h  
 index 002a2855c046..3d33794e4f3e 100644  
 --- a/include/dt-bindings/pinctrl/dra.h  
 +++ b/include/dt-bindings/pinctrl/dra.h  
 @@ -30,7 +30,8 @@  
  #define MUX_MODE14 0xe  
  #define MUX_MODE15 0xf  
   
 -#define PULL_ENA (1 << 16)  
 +#define PULL_ENA (0 << 16)  
 +#define PULL_DIS (1 << 16)  
  #define PULL_UP (1 << 17)  
  #define INPUT_EN (1 << 18)  
  #define SLEWCONTROL (1 << 19)  
 @@ -38,10 +39,10 @@  
  #define WAKEUP_EVENT (1 << 25)  
   
  /* Active pin states */  
 -#define PIN_OUTPUT 0  
 +#define PIN_OUTPUT (0 | PULL_DIS)  
  #define PIN_OUTPUT_PULLUP (PIN_OUTPUT | PULL_ENA | PULL_UP)  
  #define PIN_OUTPUT_PULLDOWN (PIN_OUTPUT | PULL_ENA)  
 -#define PIN_INPUT INPUT_EN  
 +#define PIN_INPUT (INPUT_EN | PULL_DIS)  
  #define PIN_INPUT_SLEW (INPUT_EN | SLEWCONTROL)  
  #define PIN_INPUT_PULLUP (PULL_ENA | INPUT_EN | PULL_UP)  
  #define PIN_INPUT_PULLDOWN (PULL_ENA | INPUT_EN)  
 diff --git a/include/linux/printk.h b/include/linux/printk.h  
 index 8752f7595b27..7847301e2837 100644  
 --- a/include/linux/printk.h  
 +++ b/include/linux/printk.h  
 @@ -128,9 +128,9 @@ asmlinkage __printf(1, 2) __cold  
  int printk(const char *fmt, ...);  
   
  /*  
 - * Special printk facility for scheduler use only, _DO_NOT_USE_ !  
 + * Special printk facility for scheduler/timekeeping use only, _DO_NOT_USE_ !  
982    */    */
983  -__printf(1, 2) __cold int printk_sched(const char *fmt, ...);  -static void ip_select_fb_ident(struct iphdr *iph)
984  +__printf(1, 2) __cold int printk_deferred(const char *fmt, ...);  +u32 ip_idents_reserve(u32 hash, int segs)
   
  /*  
   * Please don't use printk_ratelimit(), because it shares ratelimiting state  
 @@ -165,7 +165,7 @@ int printk(const char *s, ...)  
  return 0;  
  }  
  static inline __printf(1, 2) __cold  
 -int printk_sched(const char *s, ...)  
 +int printk_deferred(const char *s, ...)  
985   {   {
986   return 0;  - static DEFINE_SPINLOCK(ip_fb_id_lock);
987   }  - static u32 ip_fallback_id;
988  diff --git a/init/main.c b/init/main.c  - u32 salt;
989  index 48655ceb66f4..eb0ea86aefde 100644  + struct ip_ident_bucket *bucket = ip_idents + hash % IP_IDENTS_SZ;
990  --- a/init/main.c  + u32 old = ACCESS_ONCE(bucket->stamp32);
991  +++ b/init/main.c  + u32 now = (u32)jiffies;
992  @@ -617,6 +617,10 @@ asmlinkage __visible void __init start_kernel(void)  + u32 delta = 0;
993   if (efi_enabled(EFI_RUNTIME_SERVICES))  +
994   efi_enter_virtual_mode();  + if (old != now && cmpxchg(&bucket->stamp32, old, now) == old)
995   #endif  + delta = prandom_u32_max(now - old);
996  +#ifdef CONFIG_X86_ESPFIX64  
997  + /* Should be run before the first non-init thread is created */  - spin_lock_bh(&ip_fb_id_lock);
998  + init_espfix_bsp();  - salt = secure_ip_id((__force __be32)ip_fallback_id ^ iph->daddr);
999  +#endif  - iph->id = htons(salt & 0xFFFF);
1000   thread_info_cache_init();  - ip_fallback_id = salt;
1001   cred_init();  - spin_unlock_bh(&ip_fb_id_lock);
1002   fork_init(totalram_pages);  + return atomic_add_return(segs + delta, &bucket->id) - segs;
 diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c  
 index 221229cf0190..63594befdd58 100644  
 --- a/kernel/printk/printk.c  
 +++ b/kernel/printk/printk.c  
 @@ -2474,7 +2474,7 @@ void wake_up_klogd(void)  
  preempt_enable();  
1003   }   }
1004    +EXPORT_SYMBOL(ip_idents_reserve);
1005    
1006  -int printk_sched(const char *fmt, ...)  -void __ip_select_ident(struct iphdr *iph, struct dst_entry *dst, int more)
1007  +int printk_deferred(const char *fmt, ...)  +void __ip_select_ident(struct iphdr *iph, int segs)
  {  
  unsigned long flags;  
  va_list args;  
 diff --git a/kernel/sched/core.c b/kernel/sched/core.c  
 index 084d17f89139..8da7e4990427 100644  
 --- a/kernel/sched/core.c  
 +++ b/kernel/sched/core.c  
 @@ -1320,7 +1320,7 @@ out:  
  * leave kernel.  
  */  
  if (p->mm && printk_ratelimit()) {  
 - printk_sched("process %d (%s) no longer affine to cpu%d\n",  
 + printk_deferred("process %d (%s) no longer affine to cpu%d\n",  
  task_pid_nr(p), p->comm, cpu);  
  }  
  }  
 diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c  
 index 14bc348ba3b4..34e054ddf50a 100644  
 --- a/kernel/sched/deadline.c  
 +++ b/kernel/sched/deadline.c  
 @@ -352,7 +352,7 @@ static void replenish_dl_entity(struct sched_dl_entity *dl_se,  
   
  if (!lag_once) {  
  lag_once = true;  
 - printk_sched("sched: DL replenish lagged to much\n");  
 + printk_deferred("sched: DL replenish lagged to much\n");  
  }  
  dl_se->deadline = rq_clock(rq) + pi_se->dl_deadline;  
  dl_se->runtime = pi_se->dl_runtime;  
 diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c  
 index bd2267ad404f..c19b3cc53b00 100644  
 --- a/kernel/sched/rt.c  
 +++ b/kernel/sched/rt.c  
 @@ -857,7 +857,7 @@ static int sched_rt_runtime_exceeded(struct rt_rq *rt_rq)  
   
  if (!once) {  
  once = true;  
 - printk_sched("sched: RT throttling activated\n");  
 + printk_deferred("sched: RT throttling activated\n");  
  }  
  } else {  
  /*  
 diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c  
 index ad362c260ef4..9c94c19f1305 100644  
 --- a/kernel/time/clockevents.c  
 +++ b/kernel/time/clockevents.c  
 @@ -146,7 +146,8 @@ static int clockevents_increase_min_delta(struct clock_event_device *dev)  
1008   {   {
1009   /* Nothing to do if we already reached the limit */  - struct net *net = dev_net(dst->dev);
1010   if (dev->min_delta_ns >= MIN_DELTA_LIMIT) {  - struct inet_peer *peer;
1011  - printk(KERN_WARNING "CE: Reprogramming failure. Giving up\n");  + static u32 ip_idents_hashrnd __read_mostly;
1012  + printk_deferred(KERN_WARNING  + u32 hash, id;
1013  + "CE: Reprogramming failure. Giving up\n");  
1014   dev->next_event.tv64 = KTIME_MAX;  - peer = inet_getpeer_v4(net->ipv4.peers, iph->daddr, 1);
1015   return -ETIME;  - if (peer) {
1016   }  - iph->id = htons(inet_getid(peer, more));
1017  @@ -159,9 +160,10 @@ static int clockevents_increase_min_delta(struct clock_event_device *dev)  - inet_putpeer(peer);
1018   if (dev->min_delta_ns > MIN_DELTA_LIMIT)  - return;
1019   dev->min_delta_ns = MIN_DELTA_LIMIT;  - }
1020    + net_get_random_once(&ip_idents_hashrnd, sizeof(ip_idents_hashrnd));
 - printk(KERN_WARNING "CE: %s increased min_delta_ns to %llu nsec\n",  
 -       dev->name ? dev->name : "?",  
 -       (unsigned long long) dev->min_delta_ns);  
 + printk_deferred(KERN_WARNING  
 + "CE: %s increased min_delta_ns to %llu nsec\n",  
 + dev->name ? dev->name : "?",  
 + (unsigned long long) dev->min_delta_ns);  
  return 0;  
  }  
   
 diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c  
 index 4d23dc4d8139..313a662911b1 100644  
 --- a/kernel/time/sched_clock.c  
 +++ b/kernel/time/sched_clock.c  
 @@ -204,7 +204,8 @@ void __init sched_clock_postinit(void)  
1021    
1022   static int sched_clock_suspend(void)  - ip_select_fb_ident(iph);
1023   {  + hash = jhash_3words((__force u32)iph->daddr,
1024  - sched_clock_poll(&sched_clock_timer);  +    (__force u32)iph->saddr,
1025  + update_sched_clock();  +    iph->protocol,
1026  + hrtimer_cancel(&sched_clock_timer);  +    ip_idents_hashrnd);
1027   cd.suspended = true;  + id = ip_idents_reserve(hash, segs);
1028   return 0;  + iph->id = htons(id);
1029   }   }
1030  @@ -212,6 +213,7 @@ static int sched_clock_suspend(void)   EXPORT_SYMBOL(__ip_select_ident);
1031   static void sched_clock_resume(void)  
1032    @@ -2705,6 +2712,12 @@ int __init ip_rt_init(void)
1033   {   {
1034   cd.epoch_cyc = read_sched_clock();   int rc = 0;
 + hrtimer_start(&sched_clock_timer, cd.wrap_kt, HRTIMER_MODE_REL);  
  cd.suspended = false;  
  }  
1035    
1036  diff --git a/lib/btree.c b/lib/btree.c  + ip_idents = kmalloc(IP_IDENTS_SZ * sizeof(*ip_idents), GFP_KERNEL);
1037  index f9a484676cb6..4264871ea1a0 100644  + if (!ip_idents)
1038  --- a/lib/btree.c  + panic("IP: failed to allocate ip_idents\n");
1039  +++ b/lib/btree.c  +
1040  @@ -198,6 +198,7 @@ EXPORT_SYMBOL_GPL(btree_init);  + prandom_bytes(ip_idents, IP_IDENTS_SZ * sizeof(*ip_idents));
1041    +
1042     #ifdef CONFIG_IP_ROUTE_CLASSID
1043     ip_rt_acct = __alloc_percpu(256 * sizeof(struct ip_rt_acct), __alignof__(struct ip_rt_acct));
1044     if (!ip_rt_acct)
1045    diff --git a/net/ipv4/tcp_vegas.c b/net/ipv4/tcp_vegas.c
1046    index 48539fff6357..08c8ab490fe5 100644
1047    --- a/net/ipv4/tcp_vegas.c
1048    +++ b/net/ipv4/tcp_vegas.c
1049    @@ -219,7 +219,8 @@ static void tcp_vegas_cong_avoid(struct sock *sk, u32 ack, u32 acked,
1050     * This is:
1051     *     (actual rate in segments) * baseRTT
1052     */
1053    - target_cwnd = tp->snd_cwnd * vegas->baseRTT / rtt;
1054    + target_cwnd = (u64)tp->snd_cwnd * vegas->baseRTT;
1055    + do_div(target_cwnd, rtt);
1056    
1057     /* Calculate the difference between the window we had,
1058     * and the window we would like to have. This quantity
1059    diff --git a/net/ipv4/tcp_veno.c b/net/ipv4/tcp_veno.c
1060    index 1b8e28fcd7e1..4cd4e1be3a71 100644
1061    --- a/net/ipv4/tcp_veno.c
1062    +++ b/net/ipv4/tcp_veno.c
1063    @@ -145,7 +145,7 @@ static void tcp_veno_cong_avoid(struct sock *sk, u32 ack, u32 acked,
1064    
1065     rtt = veno->minrtt;
1066    
1067    - target_cwnd = (tp->snd_cwnd * veno->basertt);
1068    + target_cwnd = (u64)tp->snd_cwnd * veno->basertt;
1069     target_cwnd <<= V_PARAM_SHIFT;
1070     do_div(target_cwnd, rtt);
1071    
1072    diff --git a/net/ipv4/xfrm4_mode_tunnel.c b/net/ipv4/xfrm4_mode_tunnel.c
1073    index 05f2b484954f..91771a7c802f 100644
1074    --- a/net/ipv4/xfrm4_mode_tunnel.c
1075    +++ b/net/ipv4/xfrm4_mode_tunnel.c
1076    @@ -58,12 +58,12 @@ static int xfrm4_mode_tunnel_output(struct xfrm_state *x, struct sk_buff *skb)
1077    
1078     top_iph->frag_off = (flags & XFRM_STATE_NOPMTUDISC) ?
1079     0 : (XFRM_MODE_SKB_CB(skb)->frag_off & htons(IP_DF));
1080    - ip_select_ident(skb, dst->child, NULL);
1081    
1082     top_iph->ttl = ip4_dst_hoplimit(dst->child);
1083    
1084     top_iph->saddr = x->props.saddr.a4;
1085     top_iph->daddr = x->id.daddr.a4;
1086    + ip_select_ident(skb, NULL);
1087    
1088   void btree_destroy(struct btree_head *head)   return 0;
1089   {   }
1090  + mempool_free(head->node, head->mempool);  diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
1091   mempool_destroy(head->mempool);  index fbf11562b54c..1362d3a7b26f 100644
1092   head->mempool = NULL;  --- a/net/ipv6/ip6_output.c
1093    +++ b/net/ipv6/ip6_output.c
1094    @@ -537,6 +537,20 @@ static void ip6_copy_metadata(struct sk_buff *to, struct sk_buff *from)
1095     skb_copy_secmark(to, from);
1096   }   }
 diff --git a/mm/memcontrol.c b/mm/memcontrol.c  
 index 67c927a10add..fe99d963b987 100644  
 --- a/mm/memcontrol.c  
 +++ b/mm/memcontrol.c  
 @@ -5544,8 +5544,12 @@ static int mem_cgroup_oom_notify_cb(struct mem_cgroup *memcg)  
  {  
  struct mem_cgroup_eventfd_list *ev;  
1097    
1098  + spin_lock(&memcg_oom_lock);  +static void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
1099    +{
1100    + static u32 ip6_idents_hashrnd __read_mostly;
1101    + u32 hash, id;
1102  +  +
1103   list_for_each_entry(ev, &memcg->oom_notify, list)  + net_get_random_once(&ip6_idents_hashrnd, sizeof(ip6_idents_hashrnd));
  eventfd_signal(ev->eventfd, 1);  
1104  +  +
1105  + spin_unlock(&memcg_oom_lock);  + hash = __ipv6_addr_jhash(&rt->rt6i_dst.addr, ip6_idents_hashrnd);
1106   return 0;  + hash = __ipv6_addr_jhash(&rt->rt6i_src.addr, hash);
  }  
   
 diff --git a/mm/page-writeback.c b/mm/page-writeback.c  
 index 154af210178b..f972182d4218 100644  
 --- a/mm/page-writeback.c  
 +++ b/mm/page-writeback.c  
 @@ -1324,9 +1324,9 @@ static inline void bdi_dirty_limits(struct backing_dev_info *bdi,  
  *bdi_thresh = bdi_dirty_limit(bdi, dirty_thresh);  
   
  if (bdi_bg_thresh)  
 - *bdi_bg_thresh = div_u64((u64)*bdi_thresh *  
 - background_thresh,  
 - dirty_thresh);  
 + *bdi_bg_thresh = dirty_thresh ? div_u64((u64)*bdi_thresh *  
 + background_thresh,  
 + dirty_thresh) : 0;  
   
  /*  
  * In order to avoid the stacked BDI deadlock we need  
 diff --git a/mm/page_alloc.c b/mm/page_alloc.c  
 index d64f5f90000c..e98306fc4234 100644  
 --- a/mm/page_alloc.c  
 +++ b/mm/page_alloc.c  
 @@ -2435,7 +2435,7 @@ static inline int  
  gfp_to_alloc_flags(gfp_t gfp_mask)  
  {  
  int alloc_flags = ALLOC_WMARK_MIN | ALLOC_CPUSET;  
 - const gfp_t wait = gfp_mask & __GFP_WAIT;  
 + const bool atomic = !(gfp_mask & (__GFP_WAIT | __GFP_NO_KSWAPD));  
   
  /* __GFP_HIGH is assumed to be the same as ALLOC_HIGH to save a branch. */  
  BUILD_BUG_ON(__GFP_HIGH != (__force gfp_t) ALLOC_HIGH);  
 @@ -2444,20 +2444,20 @@ gfp_to_alloc_flags(gfp_t gfp_mask)  
  * The caller may dip into page reserves a bit more if the caller  
  * cannot run direct reclaim, or if the caller has realtime scheduling  
  * policy or is asking for __GFP_HIGH memory.  GFP_ATOMIC requests will  
 - * set both ALLOC_HARDER (!wait) and ALLOC_HIGH (__GFP_HIGH).  
 + * set both ALLOC_HARDER (atomic == true) and ALLOC_HIGH (__GFP_HIGH).  
  */  
  alloc_flags |= (__force int) (gfp_mask & __GFP_HIGH);  
   
 - if (!wait) {  
 + if (atomic) {  
  /*  
 - * Not worth trying to allocate harder for  
 - * __GFP_NOMEMALLOC even if it can't schedule.  
 + * Not worth trying to allocate harder for __GFP_NOMEMALLOC even  
 + * if it can't schedule.  
  */  
 - if  (!(gfp_mask & __GFP_NOMEMALLOC))  
 + if (!(gfp_mask & __GFP_NOMEMALLOC))  
  alloc_flags |= ALLOC_HARDER;  
  /*  
 - * Ignore cpuset if GFP_ATOMIC (!wait) rather than fail alloc.  
 - * See also cpuset_zone_allowed() comment in kernel/cpuset.c.  
 + * Ignore cpuset mems for GFP_ATOMIC rather than fail, see the  
 + * comment for __cpuset_node_allowed_softwall().  
  */  
  alloc_flags &= ~ALLOC_CPUSET;  
  } else if (unlikely(rt_task(current)) && !in_interrupt())  
 diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c  
 index 950909f04ee6..13752d96275e 100644  
 --- a/net/l2tp/l2tp_ppp.c  
 +++ b/net/l2tp/l2tp_ppp.c  
 @@ -1365,7 +1365,7 @@ static int pppol2tp_setsockopt(struct socket *sock, int level, int optname,  
  int err;  
   
  if (level != SOL_PPPOL2TP)  
 - return udp_prot.setsockopt(sk, level, optname, optval, optlen);  
 + return -EINVAL;  
   
  if (optlen < sizeof(int))  
  return -EINVAL;  
 @@ -1491,7 +1491,7 @@ static int pppol2tp_getsockopt(struct socket *sock, int level, int optname,  
  struct pppol2tp_session *ps;  
   
  if (level != SOL_PPPOL2TP)  
 - return udp_prot.getsockopt(sk, level, optname, optval, optlen);  
 + return -EINVAL;  
   
  if (get_user(len, optlen))  
  return -EFAULT;  
 diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c  
 index 19d36d4117e0..1fbb057b2db1 100644  
 --- a/net/mac80211/tx.c  
 +++ b/net/mac80211/tx.c  
 @@ -414,6 +414,9 @@ ieee80211_tx_h_multicast_ps_buf(struct ieee80211_tx_data *tx)  
  if (ieee80211_has_order(hdr->frame_control))  
  return TX_CONTINUE;  
   
 + if (ieee80211_is_probe_req(hdr->frame_control))  
 + return TX_CONTINUE;  
1107  +  +
1108   if (tx->local->hw.flags & IEEE80211_HW_QUEUE_CONTROL)  + id = ip_idents_reserve(hash, 1);
1109   info->hw_queue = tx->sdata->vif.cab_queue;  + fhdr->identification = htonl(id);
1110    +}
 @@ -463,6 +466,7 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx)  
  {  
  struct sta_info *sta = tx->sta;  
  struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);  
 + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;  
  struct ieee80211_local *local = tx->local;  
   
  if (unlikely(!sta))  
 @@ -473,6 +477,12 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx)  
      !(info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER))) {  
  int ac = skb_get_queue_mapping(tx->skb);  
   
 + if (ieee80211_is_mgmt(hdr->frame_control) &&  
 +    !ieee80211_is_bufferable_mmpdu(hdr->frame_control)) {  
 + info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER;  
 + return TX_CONTINUE;  
 + }  
1111  +  +
1112   ps_dbg(sta->sdata, "STA %pM aid %d: PS buffer for AC %d\n",   int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
        sta->sta.addr, sta->sta.aid, ac);  
  if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER)  
 @@ -531,19 +541,9 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx)  
  static ieee80211_tx_result debug_noinline  
  ieee80211_tx_h_ps_buf(struct ieee80211_tx_data *tx)  
1113   {   {
1114  - struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);   struct sk_buff *frag;
1115  - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;  diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c
1116  -  index 56596ce390a1..6179ac186ab9 100644
1117   if (unlikely(tx->flags & IEEE80211_TX_PS_BUFFERED))  --- a/net/ipv6/output_core.c
1118   return TX_CONTINUE;  +++ b/net/ipv6/output_core.c
1119    @@ -8,31 +8,6 @@
1120     #include <net/addrconf.h>
1121     #include <net/secure_seq.h>
1122    
1123  - if (ieee80211_is_mgmt(hdr->frame_control) &&  -void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
1124  -    !ieee80211_is_bufferable_mmpdu(hdr->frame_control)) {  -{
1125  - if (tx->flags & IEEE80211_TX_UNICAST)  - static atomic_t ipv6_fragmentation_id;
1126  - info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER;  - struct in6_addr addr;
1127  - return TX_CONTINUE;  - int ident;
1128    -
1129    -#if IS_ENABLED(CONFIG_IPV6)
1130    - struct inet_peer *peer;
1131    - struct net *net;
1132    -
1133    - net = dev_net(rt->dst.dev);
1134    - peer = inet_getpeer_v6(net->ipv6.peers, &rt->rt6i_dst.addr, 1);
1135    - if (peer) {
1136    - fhdr->identification = htonl(inet_getid(peer, 0));
1137    - inet_putpeer(peer);
1138    - return;
1139  - }  - }
1140    -#endif
1141    - ident = atomic_inc_return(&ipv6_fragmentation_id);
1142  -  -
1143   if (tx->flags & IEEE80211_TX_UNICAST)  - addr = rt->rt6i_dst.addr;
1144   return ieee80211_tx_h_unicast_ps_buf(tx);  - addr.s6_addr32[0] ^= (__force __be32)ident;
1145   else  - fhdr->identification = htonl(secure_ipv6_id(addr.s6_addr32));
1146  diff --git a/net/wireless/trace.h b/net/wireless/trace.h  -}
1147  index aabccf13e07b..0a46eba04a4a 100644  -EXPORT_SYMBOL(ipv6_select_ident);
1148  --- a/net/wireless/trace.h  
1149  +++ b/net/wireless/trace.h   int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr)
1150  @@ -2072,7 +2072,8 @@ TRACE_EVENT(cfg80211_michael_mic_failure,   {
1151   MAC_ASSIGN(addr, addr);  diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
1152   __entry->key_type = key_type;  index c47444e4cf8c..7f0e1cf2d7e8 100644
1153   __entry->key_id = key_id;  --- a/net/netfilter/ipvs/ip_vs_xmit.c
1154  - memcpy(__entry->tsc, tsc, 6);  +++ b/net/netfilter/ipvs/ip_vs_xmit.c
1155  + if (tsc)  @@ -883,7 +883,7 @@ ip_vs_tunnel_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
1156  + memcpy(__entry->tsc, tsc, 6);   iph->daddr = cp->daddr.ip;
1157   ),   iph->saddr = saddr;
1158   TP_printk(NETDEV_PR_FMT ", " MAC_PR_FMT ", key type: %d, key id: %d, tsc: %pm",   iph->ttl = old_iph->ttl;
1159    NETDEV_PR_ARG, MAC_PR_ARG(addr), __entry->key_type,  - ip_select_ident(skb, &rt->dst, NULL);
1160    + ip_select_ident(skb, NULL);
1161    
1162     /* Another hack: avoid icmp_send in ip_fragment */
1163     skb->local_df = 1;
1164    diff --git a/net/sctp/associola.c b/net/sctp/associola.c
1165    index 0b999987b658..a6953b0436a5 100644
1166    --- a/net/sctp/associola.c
1167    +++ b/net/sctp/associola.c
1168    @@ -1151,6 +1151,7 @@ void sctp_assoc_update(struct sctp_association *asoc,
1169     asoc->c = new->c;
1170     asoc->peer.rwnd = new->peer.rwnd;
1171     asoc->peer.sack_needed = new->peer.sack_needed;
1172    + asoc->peer.auth_capable = new->peer.auth_capable;
1173     asoc->peer.i = new->peer.i;
1174     sctp_tsnmap_init(&asoc->peer.tsn_map, SCTP_TSN_MAP_INITIAL,
1175     asoc->peer.i.initial_tsn, GFP_ATOMIC);
1176    diff --git a/net/sctp/output.c b/net/sctp/output.c
1177    index 0f4d15fc2627..8267b06c3646 100644
1178    --- a/net/sctp/output.c
1179    +++ b/net/sctp/output.c
1180    @@ -599,7 +599,7 @@ out:
1181     return err;
1182     no_route:
1183     kfree_skb(nskb);
1184    - IP_INC_STATS_BH(sock_net(asoc->base.sk), IPSTATS_MIB_OUTNOROUTES);
1185    + IP_INC_STATS(sock_net(asoc->base.sk), IPSTATS_MIB_OUTNOROUTES);
1186    
1187     /* FIXME: Returning the 'err' will effect all the associations
1188     * associated with a socket, although only one of the paths of the
1189    diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
1190    index c08fbd11ceff..ed608432e4f9 100644
1191    --- a/net/xfrm/xfrm_policy.c
1192    +++ b/net/xfrm/xfrm_policy.c
1193    @@ -2107,6 +2107,8 @@ struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig,
1194     goto no_transform;
1195     }
1196    
1197    + dst_hold(&xdst->u.dst);
1198    + xdst->u.dst.flags |= DST_NOCACHE;
1199     route = xdst->route;
1200     }
1201     }
1202    diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
1203    index 51398ae6cda8..d4c0fbe568ff 100644
1204    --- a/net/xfrm/xfrm_user.c
1205    +++ b/net/xfrm/xfrm_user.c
1206    @@ -177,9 +177,7 @@ static int verify_newsa_info(struct xfrm_usersa_info *p,
1207        attrs[XFRMA_ALG_AEAD] ||
1208        attrs[XFRMA_ALG_CRYPT] ||
1209        attrs[XFRMA_ALG_COMP] ||
1210    -    attrs[XFRMA_TFCPAD] ||
1211    -    (ntohl(p->id.spi) >= 0x10000))
1212    -
1213    +    attrs[XFRMA_TFCPAD])
1214     goto out;
1215     break;
1216    
1217    @@ -207,7 +205,8 @@ static int verify_newsa_info(struct xfrm_usersa_info *p,
1218        attrs[XFRMA_ALG_AUTH] ||
1219        attrs[XFRMA_ALG_AUTH_TRUNC] ||
1220        attrs[XFRMA_ALG_CRYPT] ||
1221    -    attrs[XFRMA_TFCPAD])
1222    +    attrs[XFRMA_TFCPAD] ||
1223    +    (ntohl(p->id.spi) >= 0x10000))
1224     goto out;
1225     break;
1226    

Legend:
Removed from v.2495  
changed lines
  Added in v.2496