Skip to content
  1. Feb 15, 2018
    • Dominik Brodowski's avatar
      selftests/x86: Do not rely on "int $0x80" in single_step_syscall.c · 4105c697
      Dominik Brodowski authored
      
      
      On 64-bit builds, we should not rely on "int $0x80" working (it only does if
      CONFIG_IA32_EMULATION=y is enabled). To keep the "Set TF and check int80"
      test running on 64-bit installs with CONFIG_IA32_EMULATION=y enabled, build
      this test only if we can also build 32-bit binaries (which should be a
      good approximation for that).
      
      Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Dmitry Safonov <dsafonov@virtuozzo.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: linux-kselftest@vger.kernel.org
      Cc: shuah@kernel.org
      Link: http://lkml.kernel.org/r/20180211111013.16888-5-linux@dominikbrodowski.net
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      4105c697
  2. Feb 13, 2018
    • Dominik Brodowski's avatar
      selftests/x86: Do not rely on "int $0x80" in test_mremap_vdso.c · 2cbc0d66
      Dominik Brodowski authored
      
      
      On 64-bit builds, we should not rely on "int $0x80" working (it only does if
      CONFIG_IA32_EMULATION=y is enabled).
      
      Without this patch, the move test may succeed, but the "int $0x80" causes
      a segfault, resulting in a false negative output of this self-test.
      
      Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Dmitry Safonov <dsafonov@virtuozzo.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: linux-kselftest@vger.kernel.org
      Cc: shuah@kernel.org
      Link: http://lkml.kernel.org/r/20180211111013.16888-4-linux@dominikbrodowski.net
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      2cbc0d66
    • Dominik Brodowski's avatar
      selftests/x86: Fix build bug caused by the 5lvl test which has been moved to the VM directory · 7f951220
      Dominik Brodowski authored
      
      
      Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: linux-kselftest@vger.kernel.org
      Cc: shuah@kernel.org
      Fixes: 235266b8
      
       "selftests/vm: move 128TB mmap boundary test to generic directory"
      Link: http://lkml.kernel.org/r/20180211111013.16888-2-linux@dominikbrodowski.net
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      7f951220
    • Ingo Molnar's avatar
      selftests/x86/pkeys: Remove unused functions · ce676638
      Ingo Molnar authored
      
      
      This also gets rid of two build warnings:
      
        protection_keys.c: In function ‘dumpit’:
        protection_keys.c:419:3: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
           write(1, buf, nr_read);
           ^~~~~~~~~~~~~~~~~~~~~~
      
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Shuah Khan <shuahkh@osg.samsung.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      ce676638
    • Dominik Brodowski's avatar
      selftests/x86: Clean up and document sscanf() usage · d8e92de8
      Dominik Brodowski authored
      
      
      Replace a couple of magically connected buffer length literal constants with
      a common definition that makes their relationship obvious. Also document
      why our sscanf() usage is safe.
      
      No intended functional changes.
      
      Suggested-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
      Cc: Andrew Lutomirski <luto@kernel.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: linux-kselftest@vger.kernel.org
      Cc: shuah@kernel.org
      Link: http://lkml.kernel.org/r/20180211205924.GA23210@light.dominikbrodowski.net
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      d8e92de8
    • Dominik Brodowski's avatar
      selftests/x86: Fix vDSO selftest segfault for vsyscall=none · 198ee8e1
      Dominik Brodowski authored
      
      
      The vDSO selftest tries to execute a vsyscall unconditionally, even if it
      is not present on the test system (e.g. if booted with vsyscall=none or
      with CONFIG_LEGACY_VSYSCALL_NONE=y set. Fix this by copying (and tweaking)
      the vsyscall check from test_vsyscall.c
      
      Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
      Cc: Andrew Lutomirski <luto@kernel.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: linux-kselftest@vger.kernel.org
      Cc: shuah@kernel.org
      Link: http://lkml.kernel.org/r/20180211111013.16888-3-linux@dominikbrodowski.net
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      198ee8e1
    • Borislav Petkov's avatar
      x86/entry/64: Remove the unused 'icebp' macro · b498c261
      Borislav Petkov authored
      
      
      That macro was touched around 2.5.8 times, judging by the full history
      linux repo, but it was unused even then. Get rid of it already.
      
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: linux@dominikbrodowski.net
      Link: http://lkml.kernel.org/r/20180212201318.GD14640@pd.tnic
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      b498c261
    • Josh Poimboeuf's avatar
      x86/entry/64: Fix paranoid_entry() frame pointer warning · b3ccefae
      Josh Poimboeuf authored
      
      
      With the following commit:
      
        f09d160992d1 ("x86/entry/64: Get rid of the ALLOC_PT_GPREGS_ON_STACK and SAVE_AND_CLEAR_REGS macros")
      
      ... one of my suggested improvements triggered a frame pointer warning:
      
        arch/x86/entry/entry_64.o: warning: objtool: paranoid_entry()+0x11: call without frame pointer save/setup
      
      The warning is correct for the build-time code, but it's actually not
      relevant at runtime because of paravirt patching.  The paravirt swapgs
      call gets replaced with either a SWAPGS instruction or NOPs at runtime.
      
      Go back to the previous behavior by removing the ELF function annotation
      for paranoid_entry() and adding an unwind hint, which effectively
      silences the warning.
      
      Reported-by: default avatarkbuild test robot <fengguang.wu@intel.com>
      Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Dominik Brodowski <linux@dominikbrodowski.net>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: kbuild-all@01.org
      Cc: tipbuild@zytor.com
      Fixes: f09d160992d1 ("x86/entry/64: Get rid of the ALLOC_PT_GPREGS_ON_STACK and SAVE_AND_CLEAR_REGS macros")
      Link: http://lkml.kernel.org/r/20180212174503.5acbymg5z6p32snu@treble
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      b3ccefae
    • Dominik Brodowski's avatar
      x86/entry/64: Indent PUSH_AND_CLEAR_REGS and POP_REGS properly · 92816f57
      Dominik Brodowski authored
      
      
      ... same as the other macros in arch/x86/entry/calling.h
      
      Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: dan.j.williams@intel.com
      Link: http://lkml.kernel.org/r/20180211104949.12992-8-linux@dominikbrodowski.net
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      92816f57
    • Dominik Brodowski's avatar
      x86/entry/64: Get rid of the ALLOC_PT_GPREGS_ON_STACK and SAVE_AND_CLEAR_REGS macros · dde3036d
      Dominik Brodowski authored
      
      
      Previously, error_entry() and paranoid_entry() saved the GP registers
      onto stack space previously allocated by its callers. Combine these two
      steps in the callers, and use the generic PUSH_AND_CLEAR_REGS macro
      for that.
      
      This adds a significant amount ot text size. However, Ingo Molnar points
      out that:
      
      	"these numbers also _very_ significantly over-represent the
      	extra footprint. The assumptions that resulted in
      	us compressing the IRQ entry code have changed very
      	significantly with the new x86 IRQ allocation code we
      	introduced in the last year:
      
      	- IRQ vectors are usually populated in tightly clustered
      	  groups.
      
      	  With our new vector allocator code the typical per CPU
      	  allocation percentage on x86 systems is ~3 device vectors
      	  and ~10 fixed vectors out of ~220 vectors - i.e. a very
      	  low ~6% utilization (!). [...]
      
      	  The days where we allocated a lot of vectors on every
      	  CPU and the compression of the IRQ entry code text
      	  mattered are over.
      
      	- Another issue is that only a small minority of vectors
      	  is frequent enough to actually matter to cache utilization
      	  in practice: 3-4 key IPIs and 1-2 device IRQs at most - and
      	  those vectors tend to be tightly clustered as well into about
      	  two groups, and are probably already on 2-3 cache lines in
      	  practice.
      
      	  For the common case of 'cache cold' IRQs it's the depth of
      	  the call chain and the fragmentation of the resulting I$
      	  that should be the main performance limit - not the overall
      	  size of it.
      
      	- The CPU side cost of IRQ delivery is still very expensive
      	  even in the best, most cached case, as in 'over a thousand
      	  cycles'. So much stuff is done that maybe contemporary x86
      	  IRQ entry microcode already prefetches the IDT entry and its
      	  expected call target address."[*]
      
      [*] http://lkml.kernel.org/r/20180208094710.qnjixhm6hybebdv7@gmail.com
      
      The "testb $3, CS(%rsp)" instruction in the idtentry macro does not need
      modification. Previously, %rsp was manually decreased by 15*8; with
      this patch, %rsp is decreased by 15 pushq instructions.
      
      [jpoimboe@redhat.com: unwind hint improvements]
      
      Suggested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: dan.j.williams@intel.com
      Link: http://lkml.kernel.org/r/20180211104949.12992-7-linux@dominikbrodowski.net
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      dde3036d
    • Dominik Brodowski's avatar
      x86/entry/64: Use PUSH_AND_CLEAN_REGS in more cases · 30907fd1
      Dominik Brodowski authored
      
      
      entry_SYSCALL_64_after_hwframe() and nmi() can be converted to use
      PUSH_AND_CLEAN_REGS instead of opencoded variants thereof. Due to
      the interleaving, the additional XOR-based clearing of R8 and R9
      in entry_SYSCALL_64_after_hwframe() should not have any noticeable
      negative implications.
      
      Suggested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: dan.j.williams@intel.com
      Link: http://lkml.kernel.org/r/20180211104949.12992-6-linux@dominikbrodowski.net
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      30907fd1
    • Dominik Brodowski's avatar
      x86/entry/64: Introduce the PUSH_AND_CLEAN_REGS macro · 3f01daec
      Dominik Brodowski authored
      
      
      Those instances where ALLOC_PT_GPREGS_ON_STACK is called just before
      SAVE_AND_CLEAR_REGS can trivially be replaced by PUSH_AND_CLEAN_REGS.
      This macro uses PUSH instead of MOV and should therefore be faster, at
      least on newer CPUs.
      
      Suggested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: dan.j.williams@intel.com
      Link: http://lkml.kernel.org/r/20180211104949.12992-5-linux@dominikbrodowski.net
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      3f01daec
    • Dominik Brodowski's avatar
      x86/entry/64: Interleave XOR register clearing with PUSH instructions · f7bafa2b
      Dominik Brodowski authored
      
      
      Same as is done for syscalls, interleave XOR with PUSH instructions
      for exceptions/interrupts, in order to minimize the cost of the
      additional instructions required for register clearing.
      
      Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: dan.j.williams@intel.com
      Link: http://lkml.kernel.org/r/20180211104949.12992-4-linux@dominikbrodowski.net
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      f7bafa2b
    • Dominik Brodowski's avatar
      x86/entry/64: Merge the POP_C_REGS and POP_EXTRA_REGS macros into a single POP_REGS macro · 502af0d7
      Dominik Brodowski authored
      
      
      The two special, opencoded cases for POP_C_REGS can be handled by ASM
      macros.
      
      Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: dan.j.williams@intel.com
      Link: http://lkml.kernel.org/r/20180211104949.12992-3-linux@dominikbrodowski.net
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      502af0d7
    • Dominik Brodowski's avatar
      x86/entry/64: Merge SAVE_C_REGS and SAVE_EXTRA_REGS, remove unused extensions · 2e3f0098
      Dominik Brodowski authored
      
      
      All current code paths call SAVE_C_REGS and then immediately
      SAVE_EXTRA_REGS. Therefore, merge these two macros and order the MOV
      sequeneces properly.
      
      While at it, remove the macros to save all except specific registers,
      as these macros have been unused for a long time.
      
      Suggested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: dan.j.williams@intel.com
      Link: http://lkml.kernel.org/r/20180211104949.12992-2-linux@dominikbrodowski.net
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      2e3f0098
    • Ingo Molnar's avatar
      x86/speculation: Clean up various Spectre related details · 21e433bd
      Ingo Molnar authored
      
      
      Harmonize all the Spectre messages so that a:
      
          dmesg | grep -i spectre
      
      ... gives us most Spectre related kernel boot messages.
      
      Also fix a few other details:
      
       - clarify a comment about firmware speculation control
      
       - s/KPTI/PTI
      
       - remove various line-breaks that made the code uglier
      
      Acked-by: default avatarDavid Woodhouse <dwmw@amazon.co.uk>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Arjan van de Ven <arjan@linux.intel.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      21e433bd
    • KarimAllah Ahmed's avatar
      KVM/nVMX: Set the CPU_BASED_USE_MSR_BITMAPS if we have a valid L02 MSR bitmap · 3712caeb
      KarimAllah Ahmed authored
      We either clear the CPU_BASED_USE_MSR_BITMAPS and end up intercepting all
      MSR accesses or create a valid L02 MSR bitmap and use that. This decision
      has to be made every time we evaluate whether we are going to generate the
      L02 MSR bitmap.
      
      Before commit:
      
        d28b387f
      
       ("KVM/VMX: Allow direct access to MSR_IA32_SPEC_CTRL")
      
      ... this was probably OK since the decision was always identical.
      
      This is no longer the case now since the MSR bitmap might actually
      change once we decide to not intercept SPEC_CTRL and PRED_CMD.
      
      Signed-off-by: default avatarKarimAllah Ahmed <karahmed@amazon.de>
      Signed-off-by: default avatarDavid Woodhouse <dwmw@amazon.co.uk>
      Acked-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Arjan van de Ven <arjan@linux.intel.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Radim Krčmář <rkrcmar@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: arjan.van.de.ven@intel.com
      Cc: dave.hansen@intel.com
      Cc: jmattson@google.com
      Cc: kvm@vger.kernel.org
      Cc: sironi@amazon.de
      Link: http://lkml.kernel.org/r/1518305967-31356-6-git-send-email-dwmw@amazon.co.uk
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      3712caeb
    • KarimAllah Ahmed's avatar
      X86/nVMX: Properly set spec_ctrl and pred_cmd before merging MSRs · 206587a9
      KarimAllah Ahmed authored
      
      
      These two variables should check whether SPEC_CTRL and PRED_CMD are
      supposed to be passed through to L2 guests or not. While
      msr_write_intercepted_l01 would return 'true' if it is not passed through.
      
      So just invert the result of msr_write_intercepted_l01 to implement the
      correct semantics.
      
      Signed-off-by: default avatarKarimAllah Ahmed <karahmed@amazon.de>
      Signed-off-by: default avatarDavid Woodhouse <dwmw@amazon.co.uk>
      Reviewed-by: default avatarJim Mattson <jmattson@google.com>
      Acked-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Arjan van de Ven <arjan@linux.intel.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Radim Krčmář <rkrcmar@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: arjan.van.de.ven@intel.com
      Cc: dave.hansen@intel.com
      Cc: kvm@vger.kernel.org
      Cc: sironi@amazon.de
      Fixes: 086e7d4118cc ("KVM: VMX: Allow direct access to MSR_IA32_SPEC_CTRL")
      Link: http://lkml.kernel.org/r/1518305967-31356-5-git-send-email-dwmw@amazon.co.uk
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      206587a9
    • David Woodhouse's avatar
      KVM/x86: Reduce retpoline performance impact in slot_handle_level_range(), by... · 928a4c39
      David Woodhouse authored
      
      KVM/x86: Reduce retpoline performance impact in slot_handle_level_range(), by always inlining iterator helper methods
      
      With retpoline, tight loops of "call this function for every XXX" are
      very much pessimised by taking a prediction miss *every* time. This one
      is by far the biggest contributor to the guest launch time with retpoline.
      
      By marking the iterator slot_handle_…() functions always_inline, we can
      ensure that the indirect function call can be optimised away into a
      direct call and it actually generates slightly smaller code because
      some of the other conditionals can get optimised away too.
      
      Performance is now pretty close to what we see with nospectre_v2 on
      the command line.
      
      Suggested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Tested-by: default avatarFilippo Sironi <sironi@amazon.de>
      Signed-off-by: default avatarDavid Woodhouse <dwmw@amazon.co.uk>
      Reviewed-by: default avatarFilippo Sironi <sironi@amazon.de>
      Acked-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Arjan van de Ven <arjan@linux.intel.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: arjan.van.de.ven@intel.com
      Cc: dave.hansen@intel.com
      Cc: jmattson@google.com
      Cc: karahmed@amazon.de
      Cc: kvm@vger.kernel.org
      Cc: rkrcmar@redhat.com
      Link: http://lkml.kernel.org/r/1518305967-31356-4-git-send-email-dwmw@amazon.co.uk
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      928a4c39
    • David Woodhouse's avatar
      Revert "x86/speculation: Simplify indirect_branch_prediction_barrier()" · f208820a
      David Woodhouse authored
      This reverts commit 64e16720
      
      .
      
      We cannot call C functions like that, without marking all the
      call-clobbered registers as, well, clobbered. We might have got away
      with it for now because the __ibp_barrier() function was *fairly*
      unlikely to actually use any other registers. But no. Just no.
      
      Signed-off-by: default avatarDavid Woodhouse <dwmw@amazon.co.uk>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Arjan van de Ven <arjan@linux.intel.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: arjan.van.de.ven@intel.com
      Cc: dave.hansen@intel.com
      Cc: jmattson@google.com
      Cc: karahmed@amazon.de
      Cc: kvm@vger.kernel.org
      Cc: pbonzini@redhat.com
      Cc: rkrcmar@redhat.com
      Cc: sironi@amazon.de
      Link: http://lkml.kernel.org/r/1518305967-31356-3-git-send-email-dwmw@amazon.co.uk
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      f208820a
    • David Woodhouse's avatar
      x86/speculation: Correct Speculation Control microcode blacklist again · d37fc6d3
      David Woodhouse authored
      
      
      Arjan points out that the Intel document only clears the 0xc2 microcode
      on *some* parts with CPUID 506E3 (INTEL_FAM6_SKYLAKE_DESKTOP stepping 3).
      For the Skylake H/S platform it's OK but for Skylake E3 which has the
      same CPUID it isn't (yet) cleared.
      
      So removing it from the blacklist was premature. Put it back for now.
      
      Also, Arjan assures me that the 0x84 microcode for Kaby Lake which was
      featured in one of the early revisions of the Intel document was never
      released to the public, and won't be until/unless it is also validated
      as safe. So those can change to 0x80 which is what all *other* versions
      of the doc have identified.
      
      Once the retrospective testing of existing public microcodes is done, we
      should be back into a mode where new microcodes are only released in
      batches and we shouldn't even need to update the blacklist for those
      anyway, so this tweaking of the list isn't expected to be a thing which
      keeps happening.
      
      Requested-by: default avatarArjan van de Ven <arjan.van.de.ven@intel.com>
      Signed-off-by: default avatarDavid Woodhouse <dwmw@amazon.co.uk>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Arjan van de Ven <arjan@linux.intel.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: arjan.van.de.ven@intel.com
      Cc: dave.hansen@intel.com
      Cc: kvm@vger.kernel.org
      Cc: pbonzini@redhat.com
      Link: http://lkml.kernel.org/r/1518449255-2182-1-git-send-email-dwmw@amazon.co.uk
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      d37fc6d3
  3. Feb 11, 2018
    • David Woodhouse's avatar
      x86/speculation: Update Speculation Control microcode blacklist · 17513420
      David Woodhouse authored
      
      
      Intel have retroactively blessed the 0xc2 microcode on Skylake mobile
      and desktop parts, and the Gemini Lake 0x22 microcode is apparently fine
      too. We blacklisted the latter purely because it was present with all
      the other problematic ones in the 2018-01-08 release, but now it's
      explicitly listed as OK.
      
      We still list 0x84 for the various Kaby Lake / Coffee Lake parts, as
      that appeared in one version of the blacklist and then reverted to
      0x80 again. We can change it if 0x84 is actually announced to be safe.
      
      Signed-off-by: default avatarDavid Woodhouse <dwmw@amazon.co.uk>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Arjan van de Ven <arjan@linux.intel.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: arjan.van.de.ven@intel.com
      Cc: jmattson@google.com
      Cc: karahmed@amazon.de
      Cc: kvm@vger.kernel.org
      Cc: pbonzini@redhat.com
      Cc: rkrcmar@redhat.com
      Cc: sironi@amazon.de
      Link: http://lkml.kernel.org/r/1518305967-31356-2-git-send-email-dwmw@amazon.co.uk
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      17513420
  4. Feb 10, 2018
    • Nadav Amit's avatar
      x86/mm/pti: Fix PTI comment in entry_SYSCALL_64() · 14b1fcc6
      Nadav Amit authored
      
      
      The comment is confusing since the path is taken when
      CONFIG_PAGE_TABLE_ISOLATION=y is disabled (while the comment says it is not
      taken).
      
      Signed-off-by: default avatarNadav Amit <namit@vmware.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Arjan van de Ven <arjan@linux.intel.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: nadav.amit@gmail.com
      Link: http://lkml.kernel.org/r/20180209170638.15161-1-namit@vmware.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      14b1fcc6
  5. Feb 09, 2018
  6. Feb 06, 2018
    • Dan Williams's avatar
      x86/entry/64/compat: Clear registers for compat syscalls, to reduce speculation attack surface · 6b8cf5cc
      Dan Williams authored
      
      
      At entry userspace may have populated registers with values that could
      otherwise be useful in a speculative execution attack. Clear them to
      minimize the kernel's attack surface.
      
      Originally-From: Andi Kleen <ak@linux.intel.com>
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      Cc: <stable@vger.kernel.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/151787989697.7847.4083702787288600552.stgit@dwillia2-desk3.amr.corp.intel.com
      [ Made small improvements to the changelog. ]
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      6b8cf5cc
    • Dan Williams's avatar
      x86/entry/64: Clear registers for exceptions/interrupts, to reduce speculation attack surface · 3ac6d8c7
      Dan Williams authored
      
      
      Clear the 'extra' registers on entering the 64-bit kernel for exceptions
      and interrupts. The common registers are not cleared since they are
      likely clobbered well before they can be exploited in a speculative
      execution attack.
      
      Originally-From: Andi Kleen <ak@linux.intel.com>
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      Cc: <stable@vger.kernel.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/151787989146.7847.15749181712358213254.stgit@dwillia2-desk3.amr.corp.intel.com
      [ Made small improvements to the changelog and the code comments. ]
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      3ac6d8c7
    • Dan Williams's avatar
      x86/entry/64: Clear extra registers beyond syscall arguments, to reduce speculation attack surface · 8e1eb3fa
      Dan Williams authored
      
      
      At entry userspace may have (maliciously) populated the extra registers
      outside the syscall calling convention with arbitrary values that could
      be useful in a speculative execution (Spectre style) attack.
      
      Clear these registers to minimize the kernel's attack surface.
      
      Note, this only clears the extra registers and not the unused
      registers for syscalls less than 6 arguments, since those registers are
      likely to be clobbered well before their values could be put to use
      under speculation.
      
      Note, Linus found that the XOR instructions can be executed with
      minimized cost if interleaved with the PUSH instructions, and Ingo's
      analysis found that R10 and R11 should be included in the register
      clearing beyond the typical 'extra' syscall calling convention
      registers.
      
      Suggested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Reported-by: default avatarAndi Kleen <ak@linux.intel.com>
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      Cc: <stable@vger.kernel.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/151787988577.7847.16733592218894189003.stgit@dwillia2-desk3.amr.corp.intel.com
      [ Made small improvements to the changelog and the code comments. ]
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      8e1eb3fa
  7. Feb 04, 2018
    • KarimAllah Ahmed's avatar
      KVM/SVM: Allow direct access to MSR_IA32_SPEC_CTRL · b2ac58f9
      KarimAllah Ahmed authored
      
      
      [ Based on a patch from Paolo Bonzini <pbonzini@redhat.com> ]
      
      ... basically doing exactly what we do for VMX:
      
      - Passthrough SPEC_CTRL to guests (if enabled in guest CPUID)
      - Save and restore SPEC_CTRL around VMExit and VMEntry only if the guest
        actually used it.
      
      Signed-off-by: default avatarKarimAllah Ahmed <karahmed@amazon.de>
      Signed-off-by: default avatarDavid Woodhouse <dwmw@amazon.co.uk>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarDarren Kenny <darren.kenny@oracle.com>
      Reviewed-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Cc: Andrea Arcangeli <aarcange@redhat.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jun Nakajima <jun.nakajima@intel.com>
      Cc: kvm@vger.kernel.org
      Cc: Dave Hansen <dave.hansen@intel.com>
      Cc: Tim Chen <tim.c.chen@linux.intel.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Asit Mallick <asit.k.mallick@intel.com>
      Cc: Arjan Van De Ven <arjan.van.de.ven@intel.com>
      Cc: Greg KH <gregkh@linuxfoundation.org>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Ashok Raj <ashok.raj@intel.com>
      Link: https://lkml.kernel.org/r/1517669783-20732-1-git-send-email-karahmed@amazon.de
      b2ac58f9
    • KarimAllah Ahmed's avatar
      KVM/VMX: Allow direct access to MSR_IA32_SPEC_CTRL · d28b387f
      KarimAllah Ahmed authored
      
      
      [ Based on a patch from Ashok Raj <ashok.raj@intel.com> ]
      
      Add direct access to MSR_IA32_SPEC_CTRL for guests. This is needed for
      guests that will only mitigate Spectre V2 through IBRS+IBPB and will not
      be using a retpoline+IBPB based approach.
      
      To avoid the overhead of saving and restoring the MSR_IA32_SPEC_CTRL for
      guests that do not actually use the MSR, only start saving and restoring
      when a non-zero is written to it.
      
      No attempt is made to handle STIBP here, intentionally. Filtering STIBP
      may be added in a future patch, which may require trapping all writes
      if we don't want to pass it through directly to the guest.
      
      [dwmw2: Clean up CPUID bits, save/restore manually, handle reset]
      
      Signed-off-by: default avatarKarimAllah Ahmed <karahmed@amazon.de>
      Signed-off-by: default avatarDavid Woodhouse <dwmw@amazon.co.uk>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarDarren Kenny <darren.kenny@oracle.com>
      Reviewed-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Reviewed-by: default avatarJim Mattson <jmattson@google.com>
      Cc: Andrea Arcangeli <aarcange@redhat.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jun Nakajima <jun.nakajima@intel.com>
      Cc: kvm@vger.kernel.org
      Cc: Dave Hansen <dave.hansen@intel.com>
      Cc: Tim Chen <tim.c.chen@linux.intel.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Asit Mallick <asit.k.mallick@intel.com>
      Cc: Arjan Van De Ven <arjan.van.de.ven@intel.com>
      Cc: Greg KH <gregkh@linuxfoundation.org>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Ashok Raj <ashok.raj@intel.com>
      Link: https://lkml.kernel.org/r/1517522386-18410-5-git-send-email-karahmed@amazon.de
      d28b387f
    • KarimAllah Ahmed's avatar
      KVM/VMX: Emulate MSR_IA32_ARCH_CAPABILITIES · 28c1c9fa
      KarimAllah Ahmed authored
      
      
      Intel processors use MSR_IA32_ARCH_CAPABILITIES MSR to indicate RDCL_NO
      (bit 0) and IBRS_ALL (bit 1). This is a read-only MSR. By default the
      contents will come directly from the hardware, but user-space can still
      override it.
      
      [dwmw2: The bit in kvm_cpuid_7_0_edx_x86_features can be unconditional]
      
      Signed-off-by: default avatarKarimAllah Ahmed <karahmed@amazon.de>
      Signed-off-by: default avatarDavid Woodhouse <dwmw@amazon.co.uk>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Reviewed-by: default avatarDarren Kenny <darren.kenny@oracle.com>
      Reviewed-by: default avatarJim Mattson <jmattson@google.com>
      Reviewed-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Cc: Andrea Arcangeli <aarcange@redhat.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jun Nakajima <jun.nakajima@intel.com>
      Cc: kvm@vger.kernel.org
      Cc: Dave Hansen <dave.hansen@intel.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Asit Mallick <asit.k.mallick@intel.com>
      Cc: Arjan Van De Ven <arjan.van.de.ven@intel.com>
      Cc: Greg KH <gregkh@linuxfoundation.org>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Tim Chen <tim.c.chen@linux.intel.com>
      Cc: Ashok Raj <ashok.raj@intel.com>
      Link: https://lkml.kernel.org/r/1517522386-18410-4-git-send-email-karahmed@amazon.de
      28c1c9fa
    • Ashok Raj's avatar
      KVM/x86: Add IBPB support · 15d45071
      Ashok Raj authored
      
      
      The Indirect Branch Predictor Barrier (IBPB) is an indirect branch
      control mechanism. It keeps earlier branches from influencing
      later ones.
      
      Unlike IBRS and STIBP, IBPB does not define a new mode of operation.
      It's a command that ensures predicted branch targets aren't used after
      the barrier. Although IBRS and IBPB are enumerated by the same CPUID
      enumeration, IBPB is very different.
      
      IBPB helps mitigate against three potential attacks:
      
      * Mitigate guests from being attacked by other guests.
        - This is addressed by issing IBPB when we do a guest switch.
      
      * Mitigate attacks from guest/ring3->host/ring3.
        These would require a IBPB during context switch in host, or after
        VMEXIT. The host process has two ways to mitigate
        - Either it can be compiled with retpoline
        - If its going through context switch, and has set !dumpable then
          there is a IBPB in that path.
          (Tim's patch: https://patchwork.kernel.org/patch/10192871)
        - The case where after a VMEXIT you return back to Qemu might make
          Qemu attackable from guest when Qemu isn't compiled with retpoline.
        There are issues reported when doing IBPB on every VMEXIT that resulted
        in some tsc calibration woes in guest.
      
      * Mitigate guest/ring0->host/ring0 attacks.
        When host kernel is using retpoline it is safe against these attacks.
        If host kernel isn't using retpoline we might need to do a IBPB flush on
        every VMEXIT.
      
      Even when using retpoline for indirect calls, in certain conditions 'ret'
      can use the BTB on Skylake-era CPUs. There are other mitigations
      available like RSB stuffing/clearing.
      
      * IBPB is issued only for SVM during svm_free_vcpu().
        VMX has a vmclear and SVM doesn't.  Follow discussion here:
        https://lkml.org/lkml/2018/1/15/146
      
      Please refer to the following spec for more details on the enumeration
      and control.
      
      Refer here to get documentation about mitigations.
      
      https://software.intel.com/en-us/side-channel-security-support
      
      [peterz: rebase and changelog rewrite]
      [karahmed: - rebase
                 - vmx: expose PRED_CMD if guest has it in CPUID
                 - svm: only pass through IBPB if guest has it in CPUID
                 - vmx: support !cpu_has_vmx_msr_bitmap()]
                 - vmx: support nested]
      [dwmw2: Expose CPUID bit too (AMD IBPB only for now as we lack IBRS)
              PRED_CMD is a write-only MSR]
      
      Signed-off-by: default avatarAshok Raj <ashok.raj@intel.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: default avatarDavid Woodhouse <dwmw@amazon.co.uk>
      Signed-off-by: default avatarKarimAllah Ahmed <karahmed@amazon.de>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Cc: Andrea Arcangeli <aarcange@redhat.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: kvm@vger.kernel.org
      Cc: Asit Mallick <asit.k.mallick@intel.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Dave Hansen <dave.hansen@intel.com>
      Cc: Arjan Van De Ven <arjan.van.de.ven@intel.com>
      Cc: Greg KH <gregkh@linuxfoundation.org>
      Cc: Jun Nakajima <jun.nakajima@intel.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Tim Chen <tim.c.chen@linux.intel.com>
      Link: http://lkml.kernel.org/r/1515720739-43819-6-git-send-email-ashok.raj@intel.com
      Link: https://lkml.kernel.org/r/1517522386-18410-3-git-send-email-karahmed@amazon.de
      15d45071
    • KarimAllah Ahmed's avatar
      KVM/x86: Update the reverse_cpuid list to include CPUID_7_EDX · b7b27aa0
      KarimAllah Ahmed authored
      
      
      [dwmw2: Stop using KF() for bits in it, too]
      Signed-off-by: default avatarKarimAllah Ahmed <karahmed@amazon.de>
      Signed-off-by: default avatarDavid Woodhouse <dwmw@amazon.co.uk>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Reviewed-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Reviewed-by: default avatarJim Mattson <jmattson@google.com>
      Cc: kvm@vger.kernel.org
      Cc: Radim Krčmář <rkrcmar@redhat.com>
      Link: https://lkml.kernel.org/r/1517522386-18410-2-git-send-email-karahmed@amazon.de
      b7b27aa0
    • Thomas Gleixner's avatar
      Merge branch 'msr-bitmaps' of git://git.kernel.org/pub/scm/virt/kvm/kvm into x86/pti · a96223f1
      Thomas Gleixner authored
      Pull the KVM prerequisites so the IBPB patches apply.
      a96223f1
  8. Feb 03, 2018
    • Darren Kenny's avatar
      x86/speculation: Fix typo IBRS_ATT, which should be IBRS_ALL · af189c95
      Darren Kenny authored
      Fixes: 117cc7a9
      
       ("x86/retpoline: Fill return stack buffer on vmexit")
      Signed-off-by: default avatarDarren Kenny <darren.kenny@oracle.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Cc: Tom Lendacky <thomas.lendacky@amd.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Arjan van de Ven <arjan@linux.intel.com>
      Cc: David Woodhouse <dwmw@amazon.co.uk>
      Link: https://lkml.kernel.org/r/20180202191220.blvgkgutojecxr3b@starbug-vm.ie.oracle.com
      af189c95
    • Arnd Bergmann's avatar
      x86/pti: Mark constant arrays as __initconst · 4bf5d56d
      Arnd Bergmann authored
      I'm seeing build failures from the two newly introduced arrays that
      are marked 'const' and '__initdata', which are mutually exclusive:
      
      arch/x86/kernel/cpu/common.c:882:43: error: 'cpu_no_speculation' causes a section type conflict with 'e820_table_firmware_init'
      arch/x86/kernel/cpu/common.c:895:43: error: 'cpu_no_meltdown' causes a section type conflict with 'e820_table_firmware_init'
      
      The correct annotation is __initconst.
      
      Fixes: fec9434a
      
       ("x86/pti: Do not enable PTI on CPUs which are not vulnerable to Meltdown")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Thomas Garnier <thgarnie@google.com>
      Cc: David Woodhouse <dwmw@amazon.co.uk>
      Link: https://lkml.kernel.org/r/20180202213959.611210-1-arnd@arndb.de
      4bf5d56d
  9. Feb 02, 2018
  10. Feb 01, 2018