Merge branch 'l1tf-final' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 14 Aug 2018 16:46:06 +0000 (09:46 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 14 Aug 2018 16:46:06 +0000 (09:46 -0700)
Merge L1 Terminal Fault fixes from Thomas Gleixner:
 "L1TF, aka L1 Terminal Fault, is yet another speculative hardware
  engineering trainwreck. It's a hardware vulnerability which allows
  unprivileged speculative access to data which is available in the
  Level 1 Data Cache when the page table entry controlling the virtual
  address, which is used for the access, has the Present bit cleared or
  other reserved bits set.

  If an instruction accesses a virtual address for which the relevant
  page table entry (PTE) has the Present bit cleared or other reserved
  bits set, then speculative execution ignores the invalid PTE and loads
  the referenced data if it is present in the Level 1 Data Cache, as if
  the page referenced by the address bits in the PTE was still present
  and accessible.

  While this is a purely speculative mechanism and the instruction will
  raise a page fault when it is retired eventually, the pure act of
  loading the data and making it available to other speculative
  instructions opens up the opportunity for side channel attacks to
  unprivileged malicious code, similar to the Meltdown attack.

  While Meltdown breaks the user space to kernel space protection, L1TF
  allows to attack any physical memory address in the system and the
  attack works across all protection domains. It allows an attack of SGX
  and also works from inside virtual machines because the speculation
  bypasses the extended page table (EPT) protection mechanism.

  The assoicated CVEs are: CVE-2018-3615, CVE-2018-3620, CVE-2018-3646

  The mitigations provided by this pull request include:

   - Host side protection by inverting the upper address bits of a non
     present page table entry so the entry points to uncacheable memory.

   - Hypervisor protection by flushing L1 Data Cache on VMENTER.

   - SMT (HyperThreading) control knobs, which allow to 'turn off' SMT
     by offlining the sibling CPU threads. The knobs are available on
     the kernel command line and at runtime via sysfs

   - Control knobs for the hypervisor mitigation, related to L1D flush
     and SMT control. The knobs are available on the kernel command line
     and at runtime via sysfs

   - Extensive documentation about L1TF including various degrees of
     mitigations.

  Thanks to all people who have contributed to this in various ways -
  patches, review, testing, backporting - and the fruitful, sometimes
  heated, but at the end constructive discussions.

  There is work in progress to provide other forms of mitigations, which
  might be less horrible performance wise for a particular kind of
  workloads, but this is not yet ready for consumption due to their
  complexity and limitations"

* 'l1tf-final' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (75 commits)
  x86/microcode: Allow late microcode loading with SMT disabled
  tools headers: Synchronise x86 cpufeatures.h for L1TF additions
  x86/mm/kmmio: Make the tracer robust against L1TF
  x86/mm/pat: Make set_memory_np() L1TF safe
  x86/speculation/l1tf: Make pmd/pud_mknotpresent() invert
  x86/speculation/l1tf: Invert all not present mappings
  cpu/hotplug: Fix SMT supported evaluation
  KVM: VMX: Tell the nested hypervisor to skip L1D flush on vmentry
  x86/speculation: Use ARCH_CAPABILITIES to skip L1D flush on vmentry
  x86/speculation: Simplify sysfs report of VMX L1TF vulnerability
  Documentation/l1tf: Remove Yonah processors from not vulnerable list
  x86/KVM/VMX: Don't set l1tf_flush_l1d from vmx_handle_external_intr()
  x86/irq: Let interrupt handlers set kvm_cpu_l1tf_flush_l1d
  x86: Don't include linux/irq.h from asm/hardirq.h
  x86/KVM/VMX: Introduce per-host-cpu analogue of l1tf_flush_l1d
  x86/irq: Demote irq_cpustat_t::__softirq_pending to u16
  x86/KVM/VMX: Move the l1tf_flush_l1d test to vmx_l1d_flush()
  x86/KVM/VMX: Replace 'vmx_l1d_flush_always' with 'vmx_l1d_flush_cond'
  x86/KVM/VMX: Don't set l1tf_flush_l1d to true from vmx_l1d_flush()
  cpu/hotplug: detect SMT disabled by BIOS
  ...

27 files changed:
1  2 
Documentation/admin-guide/kernel-parameters.txt
arch/x86/Kconfig
arch/x86/include/asm/cpufeatures.h
arch/x86/include/asm/pgtable-2level.h
arch/x86/include/asm/pgtable-3level.h
arch/x86/include/asm/pgtable.h
arch/x86/include/asm/pgtable_64.h
arch/x86/include/asm/processor.h
arch/x86/kernel/apic/apic.c
arch/x86/kernel/apic/vector.c
arch/x86/kernel/cpu/amd.c
arch/x86/kernel/cpu/bugs.c
arch/x86/kernel/cpu/common.c
arch/x86/kernel/cpu/intel.c
arch/x86/kernel/kvmclock.c
arch/x86/kernel/setup.c
arch/x86/kvm/vmx.c
arch/x86/mm/init.c
arch/x86/mm/pageattr.c
arch/x86/mm/pti.c
arch/x86/platform/uv/tlb_uv.c
include/asm-generic/pgtable.h
include/linux/cpu.h
kernel/cpu.c
kernel/sched/core.c
kernel/sched/fair.c
mm/memory.c

Simple merge
  #define X86_FEATURE_IBPB              ( 7*32+26) /* Indirect Branch Prediction Barrier */
  #define X86_FEATURE_STIBP             ( 7*32+27) /* Single Thread Indirect Branch Predictors */
  #define X86_FEATURE_ZEN                       ( 7*32+28) /* "" CPU is AMD family 0x17 (Zen) */
- #define X86_FEATURE_IBRS_ENHANCED     ( 7*32+29) /* Enhanced IBRS */
+ #define X86_FEATURE_L1TF_PTEINV               ( 7*32+29) /* "" L1TF workaround PTE inversion */
++#define X86_FEATURE_IBRS_ENHANCED     ( 7*32+30) /* Enhanced IBRS */
  
  /* Virtualization flags: Linux defined, word 8 */
  #define X86_FEATURE_TPR_SHADOW                ( 8*32+ 0) /* Intel TPR Shadow */
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -1016,26 -1022,13 +1025,31 @@@ static void __init cpu_set_bug_bits(str
                return;
  
        setup_force_cpu_bug(X86_BUG_CPU_MELTDOWN);
+       if (x86_match_cpu(cpu_no_l1tf))
+               return;
+       setup_force_cpu_bug(X86_BUG_L1TF);
  }
  
 +/*
 + * The NOPL instruction is supposed to exist on all CPUs of family >= 6;
 + * unfortunately, that's not true in practice because of early VIA
 + * chips and (more importantly) broken virtualizers that are not easy
 + * to detect. In the latter case it doesn't even *fail* reliably, so
 + * probing for it doesn't even work. Disable it completely on 32-bit
 + * unless we can find a reliable way to detect all the broken cases.
 + * Enable it explicitly on 64-bit for non-constant inputs of cpu_has().
 + */
 +static void detect_nopl(void)
 +{
 +#ifdef CONFIG_X86_32
 +      setup_clear_cpu_cap(X86_FEATURE_NOPL);
 +#else
 +      setup_force_cpu_cap(X86_FEATURE_NOPL);
 +#endif
 +}
 +
  /*
   * Do minimum CPU detection early.
   * Fields really needed: vendor, cpuid_level, family, model, mask,
Simple merge
  #include <asm/apic.h>
  #include <linux/percpu.h>
  #include <linux/hardirq.h>
 -#include <linux/memblock.h>
 +#include <linux/cpuhotplug.h>
  #include <linux/sched.h>
  #include <linux/sched/clock.h>
 +#include <linux/mm.h>
++#include <linux/slab.h>
  
 +#include <asm/hypervisor.h>
  #include <asm/mem_encrypt.h>
  #include <asm/x86_init.h>
  #include <asm/reboot.h>
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc kernel/cpu.c
@@@ -2015,7 -2265,8 +2270,8 @@@ void __init boot_cpu_init(void
  /*
   * Must be called _AFTER_ setting up the per_cpu areas
   */
 -void __init boot_cpu_state_init(void)
 +void __init boot_cpu_hotplug_init(void)
  {
-       per_cpu_ptr(&cpuhp_state, smp_processor_id())->state = CPUHP_ONLINE;
+       this_cpu_write(cpuhp_state.booted_once, true);
+       this_cpu_write(cpuhp_state.state, CPUHP_ONLINE);
  }
Simple merge
Simple merge
diff --cc mm/memory.c
Simple merge