CHROMIUM: Merge 'kaiser-3.14-merge-tag' into chromeos-3.14

Implement KAISER/KPTI for 3.14 kernels on Intel.

Changelog:
----------------------------------------------------------------
Aaron Lu (1):
      UPSTREAM: x86/irq: Do not substract irq_tlb_count from irq_call_count

Andrea Arcangeli (1):
      CHROMIUM: x86/mm/kaiser: re-enable vsyscalls

Andrew Morton (1):
      UPSTREAM: include/linux/mmdebug.h: add VM_WARN_ON() and VM_WARN_ON_ONCE()

Andy Lutomirski (20):
      UPSTREAM: x86/mm: Add INVPCID helpers
      UPSTREAM: x86/mm: Add a 'noinvpcid' boot option to turn off INVPCID
      UPSTREAM: x86/mm: If INVPCID is available, use it to flush global mappings
      UPSTREAM: sched/core: Add switch_mm_irqs_off() and use it in the scheduler
      UPSTREAM: x86/mm: Build arch/x86/mm/tlb.c even on !SMP
      UPSTREAM: x86/mm, sched/core: Uninline switch_mm()
      UPSTREAM: x86/mm, sched/core: Turn off IRQs in switch_mm()
      UPSTREAM: sched/core: Idle_task_exit() shouldn't use switch_mm_irqs_off()
      UPSTREAM: x86/vm86/32: Switch to flush_tlb_mm_range() in mark_screen_rdonly()
      UPSTREAM: x86/mm: Remove flush_tlb() and flush_tlb_current_task()
      UPSTREAM: x86/mm: Make flush_tlb_mm_range() more predictable
      UPSTREAM: x86/mm: Fix flush_tlb_page() on Xen
      UPSTREAM: x86/mm: Reimplement flush_tlb_page() using flush_tlb_mm_range()
      UPSTREAM: x86/mm: Remove the UP asm/tlbflush.h code, always use the (formerly) SMP code
      UPSTREAM: x86/mm: Disable PCID on 32-bit kernels
      UPSTREAM: x86/mm: Add the 'nopcid' boot option to turn off PCID
      UPSTREAM: x86/mm: Enable CR4.PCIDE on supported systems
      UPSTREAM: x86/paravirt: Replace the paravirt nop with a bona fide empty function
      UPSTREAM: x86/nmi/64: Fix a paravirt stack-clobbering bug in the NMI code
      CHROMIUM: x86/mm/64: Fix reboot interaction with CR4.PCIDE

Ben Serebrin (1):
      UPSTREAM: KVM: VMX: Preserve host CR4.MCE value while in guest mode.

Borislav Petkov (4):
      UPSTREAM: kbuild: Steal gcc's pie from the very beginning
      UPSTREAM: x86, cpu: Kill cpu_has_mp
      UPSTREAM: x86/mm: Fix INVPCID asm constraint
      CHROMIUM: x86/mm: fix bad backport to disable PCID on Xen

Christian Borntraeger (1):
      UPSTREAM: kernel: Change ASSIGN_ONCE(val, x) to WRITE_ONCE(x, val)

Dave Hansen (11):
      UPSTREAM: x86/mm: Clean up the TLB flushing code
      UPSTREAM: x86/mm: Rip out complicated, out-of-date, buggy TLB flushing
      UPSTREAM: x86/mm: Fix missed global TLB flush stat
      UPSTREAM: x86/mm: Unify remote INVLPG code
      UPSTREAM: x86/mm: Add tracepoints for TLB flushes
      UPSTREAM: x86/mm: New tunable for single vs full TLB flush
      UPSTREAM: x86/mm: Set TLB flush tunable to sane value (33)
      UPSTREAM: x86/mm: Fix RCU splat from new TLB tracepoints
      UPSTREAM: x86: Axe the lightly-used cpu_has_pae
      UPSTREAM: x86: Introduce disabled-features
      UPSTREAM: x86: Add more disabled features

Denys Vlasenko (1):
      UPSTREAM: include/stddef.h: Move offsetofend() from vfio.h to a generic kernel header

Fenghua Yu (2):
      UPSTREAM: x86/xsaves: Detect xsaves/xrstors feature
      UPSTREAM: x86/xsaves: Add a kernel parameter noxsaves to disable xsaves/xrstors

H. Peter Anvin (6):
      UPSTREAM: x86, cpufeature: Rename X86_FEATURE_CLFLSH to X86_FEATURE_CLFLUSH
      UPSTREAM: x86-64, espfix: Don't leak bits 31:16 of %esp returning to 16-bit stack
      UPSTREAM: x86, espfix: Move espfix definitions into a separate header file
      UPSTREAM: x86, espfix: Fix broken header guard
      UPSTREAM: x86, espfix: Make espfix64 a Kconfig option, fix UML
      UPSTREAM: x86, espfix: Make it possible to disable 16-bit support

Hugh Dickins (25):
      CHROMIUM: kaiser: merged update
      CHROMIUM: kaiser: do not set _PAGE_NX on pgd_none
      CHROMIUM: kaiser: stack map PAGE_SIZE at THREAD_SIZE-PAGE_SIZE
      CHROMIUM: kaiser: fix build and FIXME in alloc_ldt_struct()
      CHROMIUM: kaiser: KAISER depends on SMP
      CHROMIUM: kaiser: fix regs to do_nmi() ifndef CONFIG_KAISER
      CHROMIUM: kaiser: fix perf crashes
      CHROMIUM: kaiser: ENOMEM if kaiser_pagetable_walk() NULL
      CHROMIUM: kaiser: tidied up asm/kaiser.h somewhat
      CHROMIUM: kaiser: tidied up kaiser_add/remove_mapping slightly
      CHROMIUM: kaiser: kaiser_remove_mapping() move along the pgd
      CHROMIUM: kaiser: align addition to x86/mm/Makefile
      CHROMIUM: kaiser: cleanups while trying for gold link
      CHROMIUM: kaiser: name that 0x1000 KAISER_SHADOW_PGD_OFFSET
      CHROMIUM: kaiser: delete KAISER_REAL_SWITCH option
      CHROMIUM: kaiser: vmstat show NR_KAISERTABLE as nr_overhead
      CHROMIUM: kaiser: enhanced by kernel and user PCIDs
      CHROMIUM: kaiser: load_new_mm_cr3() let SWITCH_USER_CR3 flush user
      CHROMIUM: kaiser: PCID 0 for kernel and 128 for user
      CHROMIUM: kaiser: x86_cr3_pcid_noflush and x86_cr3_pcid_user
      CHROMIUM: kaiser: paranoid_entry pass cr3 need to paranoid_exit
      CHROMIUM: kaiser: _pgd_alloc() without __GFP_REPEAT to avoid stalls
      CHROMIUM: kaiser: fix unlikely error in alloc_ldt_struct()
      CHROMIUM: kaiser: alloc_ldt_struct() use get_zeroed_page()
      CHROMIUM: kaiser: user_map __kprobes_text too

Ingo Molnar (1):
      UPSTREAM: mm/mmu_context, sched/core: Fix mmu_context.h assumption

Jan Beulich (1):
      CHROMIUM: x86/debug: Drop several unnecessary CFI annotations

Jeremiah Mahler (1):
      UPSTREAM: x86/mm: Fix sparse 'tlb_single_page_flush_ceiling' warning and make the variable read-mostly

Jiri Olsa (1):
      CHROMIUM: perf/x86/intel: Use PAGE_SIZE for PEBS buffer size on Core2

Jorge Lucangeli Obes (2):
      CHROMIUM: kaiser: Fix kernel_stack.
      Merge branch 'linux/kaiser-3.14-merge-tag' into merge/chromeos-3.14-kaiser-3.14-merge-tag

Kees Cook (3):
      UPSTREAM: kbuild: Silence unused stuff
      UPSTREAM: cgroup: Silence paren warning
      CHROMIUM: kaiser: Fix build with CONFIG_FUNCTION_GRAPH_TRACER

Linus Torvalds (2):
      UPSTREAM: Disable "frame-address" warning
      UPSTREAM: kernel: make READ_ONCE() valid on const arguments

Marcelo Tosatti (1):
      UPSTREAM: kvmclock: export kvmclock clocksource and data pointers

Martin Schwidefsky (1):
      UPSTREAM: sched/mm: call finish_arch_post_lock_switch in idle_task_exit and use_mm

Masami Hiramatsu (1):
      CHROMIUM: kprobes: Prohibit probing on .entry.text code

Paolo Bonzini (1):
      UPSTREAM: x86: kvm: use alternatives for VMCALL vs. VMMCALL if kernel text is read-only

Paul E. McKenney (1):
      UPSTREAM: rcu: Provide counterpart to rcu_dereference() for non-RCU situations

Richard Fellner (1):
      CHROMIUM: KAISER: Kernel Address Isolation

Steven Rostedt (1):
      UPSTREAM: ARM: Hide finish_arch_post_lock_switch() from modules

Tim Gardner (2):
      UPSTREAM: fs: namespace: suppress 'may be used uninitialized' warnings
      UPSTREAM: scripts/sortextable: suppress warning: `relocs_size' may be used uninitialized

Zhengyu He (1):
      UPSTREAM: core: fix typo in percpu read_mostly section

 Documentation/kernel-parameters.txt         |  23 +-
 Documentation/x86/tlb.txt                   |  75 +++++
 Documentation/x86/x86_64/mm.txt             |   2 +
 Makefile                                    |   7 +-
 arch/arm/include/asm/mmu_context.h          |   2 +
 arch/x86/Kconfig                            |  25 +-
 arch/x86/boot/compressed/misc.h             |   1 +
 arch/x86/boot/mkcpustr.c                    |   1 +
 arch/x86/ia32/ia32entry.S                   |  81 +++---
 arch/x86/include/asm/cpufeature.h           |  73 ++---
 arch/x86/include/asm/desc.h                 |   2 +-
 arch/x86/include/asm/disabled-features.h    |  41 +++
 arch/x86/include/asm/espfix.h               |  16 ++
 arch/x86/include/asm/hardirq.h              |   6 +-
 arch/x86/include/asm/hw_irq.h               |   2 +-
 arch/x86/include/asm/kaiser.h               | 126 +++++++++
 arch/x86/include/asm/kvm_para.h             |  10 +-
 arch/x86/include/asm/kvmclock.h             |   6 +
 arch/x86/include/asm/mmu.h                  |   6 -
 arch/x86/include/asm/mmu_context.h          |  55 +---
 arch/x86/include/asm/pgtable.h              |  18 +-
 arch/x86/include/asm/pgtable_64.h           |  30 +-
 arch/x86/include/asm/pgtable_64_types.h     |   2 +
 arch/x86/include/asm/pgtable_types.h        |  33 ++-
 arch/x86/include/asm/processor.h            |   5 +-
 arch/x86/include/asm/setup.h                |   2 +
 arch/x86/include/asm/tlbflush.h             | 227 +++++++++------
 arch/x86/include/asm/vsyscall.h             |   1 +
 arch/x86/include/uapi/asm/msr-index.h       |   2 +
 arch/x86/include/uapi/asm/processor-flags.h |   3 +-
 arch/x86/kernel/Makefile                    |   1 +
 arch/x86/kernel/cpu/amd.c                   |  14 +-
 arch/x86/kernel/cpu/bugs.c                  |   8 +
 arch/x86/kernel/cpu/common.c                | 110 ++++++--
 arch/x86/kernel/cpu/intel.c                 |  26 --
 arch/x86/kernel/cpu/mtrr/main.c             |   6 +-
 arch/x86/kernel/cpu/perf_event.h            |   1 +
 arch/x86/kernel/cpu/perf_event_intel_ds.c   |  67 ++++-
 arch/x86/kernel/cpu/scattered.c             |   1 -
 arch/x86/kernel/entry_32.S                  |  45 +--
 arch/x86/kernel/entry_64.S                  | 358 ++++++++++++++++++------
 arch/x86/kernel/espfix_64.c                 | 218 +++++++++++++++
 arch/x86/kernel/head_64.S                   |  31 ++-
 arch/x86/kernel/hpet.c                      |   3 +
 arch/x86/kernel/irq.c                       |   3 +-
 arch/x86/kernel/irqinit.c                   |   2 +-
 arch/x86/kernel/kprobes/core.c              |   8 +
 arch/x86/kernel/kvmclock.c                  |   4 +-
 arch/x86/kernel/ldt.c                       |  32 ++-
 arch/x86/kernel/machine_kexec_32.c          |   3 +-
 arch/x86/kernel/paravirt.c                  |  16 +-
 arch/x86/kernel/process.c                   |   2 +-
 arch/x86/kernel/process_64.c                |   2 +-
 arch/x86/kernel/reboot.c                    |   4 +
 arch/x86/kernel/smpboot.c                   |   9 +-
 arch/x86/kernel/tracepoint.c                |   2 +
 arch/x86/kernel/vm86_32.c                   |   2 +-
 arch/x86/kernel/vsyscall_64.c               |   7 +-
 arch/x86/kvm/cpuid.c                        |   2 +-
 arch/x86/kvm/vmx.c                          |  12 +-
 arch/x86/kvm/x86.c                          |   3 +-
 arch/x86/mm/Makefile                        |   4 +-
 arch/x86/mm/dump_pagetables.c               |  31 ++-
 arch/x86/mm/init.c                          |   9 +-
 arch/x86/mm/kaiser.c                        | 414 ++++++++++++++++++++++++++++
 arch/x86/mm/pageattr.c                      |  63 +++--
 arch/x86/mm/pgtable.c                       |  31 ++-
 arch/x86/mm/tlb.c                           | 247 +++++++++++------
 arch/x86/xen/enlighten.c                    |   6 +
 drivers/gpu/drm/gma500/mmu.c                |   2 +-
 fs/compat.c                                 |  10 +-
 fs/internal.h                               |   2 +-
 fs/namespace.c                              |  26 +-
 include/asm-generic/vmlinux.lds.h           |   9 +-
 include/linux/compiler.h                    |  16 +-
 include/linux/kaiser.h                      |  52 ++++
 include/linux/kprobes.h                     |   1 +
 include/linux/mm_types.h                    |   8 +
 include/linux/mmdebug.h                     |   4 +
 include/linux/mmu_context.h                 |   7 +
 include/linux/mmzone.h                      |   3 +-
 include/linux/percpu-defs.h                 |  36 ++-
 include/linux/rcupdate.h                    |  15 +
 include/linux/stddef.h                      |   9 +
 include/linux/vfio.h                        |  14 -
 include/trace/events/tlb.h                  |  40 +++
 init/main.c                                 |   6 +
 kernel/cgroup.c                             |   6 +-
 kernel/fork.c                               |   6 +
 kernel/kprobes.c                            |  13 +-
 kernel/sched/core.c                         |   8 +-
 mm/mmu_context.c                            |   5 +-
 mm/vmstat.c                                 |   1 +
 scripts/sortextable.h                       |   2 +-
 security/Kconfig                            |  10 +
 95 files changed, 2372 insertions(+), 629 deletions(-)
 create mode 100644 Documentation/x86/tlb.txt
 create mode 100644 arch/x86/include/asm/disabled-features.h
 create mode 100644 arch/x86/include/asm/espfix.h
 create mode 100644 arch/x86/include/asm/kaiser.h
 create mode 100644 arch/x86/include/asm/kvmclock.h
 create mode 100644 arch/x86/kernel/espfix_64.c
 create mode 100644 arch/x86/mm/kaiser.c
 create mode 100644 include/linux/kaiser.h
 create mode 100644 include/trace/events/tlb.h

BUG=chromium:804387
TEST=Build and test on various affected systems
Signed-off-by: Jorge Lucangeli Obes <jorgelo@chromium.org>

Change-Id: I18dc0fa2d8e39d248d511c77b16c78bd83142eb2
(cherry picked from commit 1869c728d9d4f109cb46e33da84d9cc367d3eea9)
Reviewed-on: https://chromium-review.googlesource.com/955822
Reviewed-by: Bernie Thompson <bhthompson@chromium.org>
Commit-Queue: Bernie Thompson <bhthompson@chromium.org>
Tested-by: Bernie Thompson <bhthompson@chromium.org>
95 files changed