All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/7] IBRS patch series
@ 2018-01-04 17:56 Tim Chen
  2018-01-04 17:56 ` [PATCH 1/7] x86/feature: Detect the x86 feature to control Speculation Tim Chen
                   ` (8 more replies)
  0 siblings, 9 replies; 114+ messages in thread
From: Tim Chen @ 2018-01-04 17:56 UTC (permalink / raw)
  To: Thomas Gleixner, Andy Lutomirski, Linus Torvalds, Greg KH
  Cc: Tim Chen, Dave Hansen, Andrea Arcangeli, Andi Kleen,
	Arjan Van De Ven, linux-kernel

This patch series enables the basic detection and usage of x86 indirect
branch speculation feature.  It enables the indirect branch restricted
speculation (IBRS) on kernel entry and disables it on exit.
It enumerates the indirect branch prediction barrier (IBPB).

The x86 IBRS feature requires corresponding microcode support.
It mitigates the variant 2 vulnerability described in
https://googleprojectzero.blogspot.com/2018/01/reading-privileged-memory-with-side.html

If IBRS is set, near returns and near indirect jumps/calls will not
allow their predicted target address to be controlled by code that
executed in a less privileged prediction mode before the IBRS mode was
last written with a value of 1 or on another logical processor so long
as all RSB entries from the previous less privileged prediction mode
are overwritten.

Setting of IBPB ensures that earlier code's behavior does not control later
indirect branch predictions.  It is used when context switching to new
untrusted address space. Unlike IBRS, IBPB is a command MSR
and does not retain its state.

Speculation on Skylake and later requires these patches ("dynamic IBRS")
be used instead of retpoline[1].  If you are very paranoid or you run on
a CPU where IBRS=1 is cheaper, you may also want to run in "IBRS always"
mode.

See: https://docs.google.com/document/d/e/2PACX-1vSMrwkaoSUBAFc6Fjd19F18c1O9pudkfAY-7lGYGOTN8mc9ul-J6pWadcAaBJZcVA7W_3jlLKRtKRbd/pub

More detailed description of IBRS is described in the first patch.

It is applied on top of the page table isolation changes.

A run time and boot time control of the IBRS feature is provided

There are 2 ways to control IBRS

1. At boot time
    noibrs kernel boot parameter will disable IBRS usage

Otherwise if the above parameters are not specified, the system
will enable ibrs and ibpb usage if the cpu supports it.

2. At run time
    echo 0 > /sys/kernel/debug/ibrs_enabled will turn off IBRS
    echo 1 > /sys/kernel/debug/ibrs_enabled will turn on IBRS in kernel
    echo 2 > /sys/kernel/debug/ibrs_enabled will turn on IBRS in both userspace and kernel (IBRS always)

[1] https://lkml.org/lkml/2018/1/4/174

Tim Chen (7):
  x86/feature: Detect the x86 feature to control Speculation
  x86/enter: MACROS to set/clear IBRS
  x86/enter: Use IBRS on syscall and interrupts
  x86/idle: Disable IBRS entering idle and enable it on wakeup
  x86: Use IBRS for firmware update path
  x86/spec_ctrl: Add sysctl knobs to enable/disable SPEC_CTRL feature
  x86/microcode: Recheck IBRS features on microcode reload

 Documentation/admin-guide/kernel-parameters.txt |   4 +
 arch/x86/entry/entry_64.S                       |  24 +++
 arch/x86/entry/entry_64_compat.S                |   9 +
 arch/x86/include/asm/apm.h                      |   6 +
 arch/x86/include/asm/cpufeatures.h              |   1 +
 arch/x86/include/asm/efi.h                      |  16 +-
 arch/x86/include/asm/msr-index.h                |   7 +
 arch/x86/include/asm/mwait.h                    |  19 ++
 arch/x86/include/asm/spec_ctrl.h                | 253 ++++++++++++++++++++++++
 arch/x86/kernel/cpu/Makefile                    |   1 +
 arch/x86/kernel/cpu/microcode/core.c            |   6 +
 arch/x86/kernel/cpu/scattered.c                 |  11 ++
 arch/x86/kernel/cpu/spec_ctrl.c                 | 124 ++++++++++++
 arch/x86/kernel/process.c                       |   9 +-
 14 files changed, 486 insertions(+), 4 deletions(-)
 create mode 100644 arch/x86/include/asm/spec_ctrl.h
 create mode 100644 arch/x86/kernel/cpu/spec_ctrl.c

-- 
2.9.4

^ permalink raw reply	[flat|nested] 114+ messages in thread

end of thread, other threads:[~2018-01-08  8:24 UTC | newest]

Thread overview: 114+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-04 17:56 [PATCH 0/7] IBRS patch series Tim Chen
2018-01-04 17:56 ` [PATCH 1/7] x86/feature: Detect the x86 feature to control Speculation Tim Chen
2018-01-04 19:58   ` Greg KH
2018-01-04 20:47     ` Tim Chen
2018-01-05 11:14   ` David Woodhouse
2018-01-05 15:14     ` Tom Lendacky
2018-01-05 17:07       ` Tim Chen
2018-01-05 13:09   ` Thomas Gleixner
2018-01-05 13:44     ` Andrea Arcangeli
2018-01-05 13:51       ` Thomas Gleixner
2018-01-04 17:56 ` [PATCH 2/7] x86/enter: MACROS to set/clear IBRS Tim Chen
2018-01-04 22:16   ` Peter Zijlstra
2018-01-04 22:21     ` Tim Chen
2018-01-04 22:23       ` Dave Hansen
2018-01-05  4:54         ` Andy Lutomirski
2018-01-05  5:05           ` Dave Hansen
2018-01-05 13:19       ` Thomas Gleixner
2018-01-04 17:56 ` [PATCH 3/7] x86/enter: Use IBRS on syscall and interrupts Tim Chen
2018-01-04 20:00   ` Greg KH
2018-01-04 20:26     ` Tim Chen
2018-01-04 20:45   ` Dave Hansen
2018-01-04 22:33   ` Peter Zijlstra
2018-01-04 23:12     ` Andrea Arcangeli
2018-01-05  0:08     ` Dave Hansen
2018-01-05  4:51       ` Andy Lutomirski
2018-01-05  5:11         ` Dave Hansen
2018-01-05 12:01           ` Alan Cox
2018-01-05 13:35   ` Thomas Gleixner
2018-01-04 17:56 ` [PATCH 4/7] x86/idle: Disable IBRS entering idle and enable it on wakeup Tim Chen
2018-01-04 22:47   ` Peter Zijlstra
2018-01-04 23:00     ` Andrea Arcangeli
2018-01-04 23:22     ` Tim Chen
2018-01-04 23:42       ` Andrea Arcangeli
2018-01-04 23:45         ` Thomas Gleixner
2018-01-05  0:03           ` Andrea Arcangeli
2018-01-08  8:24       ` Peter Zijlstra
2018-01-04 17:56 ` [PATCH 5/7] x86: Use IBRS for firmware update path Tim Chen
2018-01-04 18:48   ` Alan Cox
2018-01-04 20:05   ` Greg KH
2018-01-04 20:08     ` Woodhouse, David
2018-01-05 16:08       ` gregkh
2018-01-05 16:37         ` Andrea Arcangeli
2018-01-04 20:21     ` Andrew Cooper
2018-01-04 20:48     ` Andrea Arcangeli
2018-01-04 20:51   ` Yves-Alexis Perez
2018-01-04 21:13     ` Tim Chen
2018-01-04 22:51   ` Peter Zijlstra
2018-01-05 13:40   ` Thomas Gleixner
2018-01-04 17:56 ` [PATCH 6/7] x86/spec_ctrl: Add sysctl knobs to enable/disable SPEC_CTRL feature Tim Chen
2018-01-04 18:33   ` Borislav Petkov
2018-01-04 18:36     ` Dave Hansen
2018-01-04 18:52       ` Borislav Petkov
2018-01-04 18:57         ` Andrea Arcangeli
2018-01-04 18:59         ` Dave Hansen
2018-01-04 19:06           ` Borislav Petkov
2018-01-05 13:48       ` Thomas Gleixner
2018-01-04 18:38     ` Andrea Arcangeli
2018-01-04 18:54       ` Dave Hansen
2018-01-04 18:56         ` Borislav Petkov
2018-01-04 18:55       ` Borislav Petkov
2018-01-04 18:34   ` Andrea Arcangeli
2018-01-04 19:02     ` Tim Chen
2018-01-04 18:50   ` Alan Cox
2018-01-04 20:16   ` Greg KH
2018-01-04 20:58     ` Tim Chen
2018-01-04 22:54   ` Peter Zijlstra
2018-01-04 23:26     ` Tim Chen
2018-01-04 23:51       ` Andrea Arcangeli
2018-01-04 23:59         ` Borislav Petkov
2018-01-05  0:07           ` Thomas Gleixner
2018-01-05 11:16   ` David Woodhouse
2018-01-06  1:29     ` Tim Chen
2018-01-04 17:56 ` [PATCH 7/7] x86/microcode: Recheck IBRS features on microcode reload Tim Chen
2018-01-04 18:28   ` Borislav Petkov
2018-01-04 18:34     ` Andrea Arcangeli
2018-01-04 18:50       ` Borislav Petkov
2018-01-04 19:10         ` Tim Chen
2018-01-05 13:32         ` Greg KH
2018-01-05 13:37           ` Borislav Petkov
2018-01-05 13:47             ` Greg KH
2018-01-05 15:28           ` Andrea Arcangeli
2018-01-04 19:00 ` [PATCH 0/7] IBRS patch series Linus Torvalds
2018-01-04 19:19   ` David Woodhouse
2018-01-04 19:33     ` Linus Torvalds
2018-01-04 19:39       ` David Woodhouse
2018-01-04 19:40       ` Andrew Cooper
2018-01-04 19:46         ` David Woodhouse
2018-01-04 21:22       ` Van De Ven, Arjan
2018-01-05 11:32         ` Paolo Bonzini
2018-01-05 12:09           ` Paul Turner
2018-01-05 14:45           ` Van De Ven, Arjan
2018-01-05 14:43         ` Andrea Arcangeli
2018-01-05 14:52           ` Van De Ven, Arjan
2018-01-05 15:03             ` Andrea Arcangeli
2018-01-05 14:54           ` Thomas Gleixner
2018-01-05 11:52       ` Paul Turner
2018-01-05 14:28         ` David Woodhouse
2018-01-05 14:42           ` Van De Ven, Arjan
2018-01-05 15:38             ` David Woodhouse
2018-01-05 16:05               ` Andrea Arcangeli
2018-01-05 16:37                 ` David Woodhouse
2018-01-05 16:42                   ` Andrea Arcangeli
2018-01-05 16:44                     ` Van De Ven, Arjan
2018-01-05 16:46                     ` David Woodhouse
2018-01-05  5:25   ` Florian Weimer
2018-01-05 11:05     ` David Woodhouse
2018-01-04 19:05 ` Justin Forbes
2018-01-04 19:10   ` Tim Chen
2018-01-04 21:01     ` Yves-Alexis Perez
2018-01-05 13:28       ` Greg KH
2018-01-05 13:47         ` Yves-Alexis Perez
2018-01-05 14:01           ` Greg KH
2018-01-05 14:26             ` Paolo Bonzini
2018-01-05 14:54               ` Yves-Alexis Perez

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.