All of lore.kernel.org
 help / color / mirror / Atom feed
* [MODERATED] [PATCH v5 00/27] MDSv5 19
@ 2019-01-19  0:50 Andi Kleen
  2019-01-19  0:50 ` [MODERATED] [PATCH v5 01/27] MDSv5 26 Andi Kleen
                   ` (28 more replies)
  0 siblings, 29 replies; 105+ messages in thread
From: Andi Kleen @ 2019-01-19  0:50 UTC (permalink / raw)
  To: speck; +Cc: Andi Kleen

Here's a new version of flushing CPU buffers for group 4.

This mainly covers single thread, not SMT (except for the idle case).

I lumped all the issues together under the Microarchitectural Data
Sampling (MDS) name because they need the same mitigations,a
and it doesn't seem worth duplicating the sysfs files and bug entries.

This version drops support for software sequences, and also
does VERW unconditionally unless disabled.

This version implements Linus' suggestion to only clear the CPU
buffer when needed. The patch kit is now a lot more complicated:
different subsystems determine if they might touch other user's
or sensitive data and schedule a cpu clear on next kernel exit.

Generally process context doesn't clear (unless it is cryptographic
or does context switches), and interrupt context schedules a clear.
There are some exceptions to these rules.

For details on the security model see the Documentation/clearcpu.txt
file. In my tests the number of clears is much lower now.

For most benchmarks we tried the difference is in the noise
level now. ebizzy and loopback apache both show about 1.7%
degradation.

It makes various assumptions on how kernel code behaves.
I did some auditing, but wasn't able to do it for everything.
Please double check the assumptions laid out in the document.

Likely a lot more interrupt and timer handlers (and tasklets
and irq poll handlers) could be white listed to not need clear, but I only
did a fairly minimum set for now that I could test.

For some of the white listed code, especially the networking and
block softirqs, as well as the EBPF mitigation, some additional auditing that
no rules are violated would be useful.

Some notes:
- Against 5.0-rc1

Changes against previous versions:
- Remove software sequences
- Make VERW unconditional
- Improved documentation
- Some other minor changes

Changes against previous versions:
- By default now flushes only when needed
- Define security model
- New administrator document
- Added mds=verw and mds=full
- Renamed mds_disable to mds=off
- KVM virtualization much improved
- Too many others to list. Most things different now.

Changes against previous versions:
- Now idle clears too to avoid an extra SMT leakage
- Don't do any workarounds for MDS_NO
- Various small changes, see individual patches

Andi Kleen (27):
  x86/speculation/mds: Add basic bug infrastructure for MDS
  x86/speculation/mds: Add mds=off
  x86/speculation/mds: Support clearing CPU data on kernel exit
  x86/speculation/mds: Support mds=full
  x86/speculation/mds: Support mds=full for NMIs
  x86/speculation/mds: Clear CPU buffers on entering idle
  x86/speculation/mds: Add sysfs reporting
  x86/speculation/mds: Export MD_CLEAR CPUID to KVM guests.
  mds: Add documentation for clear cpu usage
  mds: Add preliminary administrator documentation
  x86/speculation/mds: Introduce lazy_clear_cpu
  x86/speculation/mds: Schedule cpu clear on context switch
  x86/speculation/mds: Add tracing for clear_cpu
  mds: Force clear cpu on kernel preemption
  mds: Schedule cpu clear for memzero_explicit and kzfree
  mds: Mark interrupts clear cpu, unless opted-out
  mds: Clear cpu on all timers, unless the timer opts-out
  mds: Clear CPU on tasklets, unless opted-out
  mds: Clear CPU on irq poll, unless opted-out
  mds: Clear cpu for string io/memcpy_*io in interrupts
  mds: Schedule clear cpu in swiotlb
  mds: Instrument skb functions to clear cpu automatically
  mds: Opt out tcp tasklet to not touch user data
  mds: mark kernel/* timers safe as not touching user data
  mds: Mark AHCI interrupt as not needing cpu clear
  mds: Mark ACPI interrupt as not needing cpu clear
  mds: Mitigate BPF

 .../ABI/testing/sysfs-devices-system-cpu      |   1 +
 .../admin-guide/kernel-parameters.txt         |   8 +
 Documentation/admin-guide/mds.rst             | 108 +++++++++++
 Documentation/clearcpu.txt                    | 172 ++++++++++++++++++
 arch/Kconfig                                  |   3 +
 arch/x86/Kconfig                              |   1 +
 arch/x86/entry/common.c                       |  13 +-
 arch/x86/include/asm/clearbpf.h               |  29 +++
 arch/x86/include/asm/clearcpu.h               |  82 +++++++++
 arch/x86/include/asm/cpufeatures.h            |   3 +
 arch/x86/include/asm/io.h                     |   3 +
 arch/x86/include/asm/msr-index.h              |   1 +
 arch/x86/include/asm/thread_info.h            |   2 +
 arch/x86/include/asm/trace/clearcpu.h         |  27 +++
 arch/x86/kernel/acpi/cstate.c                 |   2 +
 arch/x86/kernel/cpu/bugs.c                    |  48 +++++
 arch/x86/kernel/cpu/common.c                  |  13 ++
 arch/x86/kernel/kvm.c                         |   3 +
 arch/x86/kernel/nmi.c                         |   6 +-
 arch/x86/kernel/process.c                     |   5 +
 arch/x86/kernel/process.h                     |  25 +++
 arch/x86/kernel/smpboot.c                     |   3 +
 arch/x86/kvm/cpuid.c                          |   3 +-
 drivers/acpi/acpi_pad.c                       |   2 +
 drivers/acpi/osl.c                            |   3 +-
 drivers/acpi/processor_idle.c                 |   3 +
 drivers/ata/ahci.c                            |   2 +-
 drivers/ata/ahci.h                            |   2 +
 drivers/ata/libahci.c                         |  40 ++--
 drivers/base/cpu.c                            |   8 +
 drivers/idle/intel_idle.c                     |   5 +
 include/asm-generic/io.h                      |   3 +
 include/linux/clearcpu.h                      |  36 ++++
 include/linux/filter.h                        |  21 ++-
 include/linux/hrtimer.h                       |   4 +
 include/linux/interrupt.h                     |  18 +-
 include/linux/irq_poll.h                      |   2 +
 include/linux/skbuff.h                        |   2 +
 include/linux/timer.h                         |   9 +-
 kernel/bpf/core.c                             |   2 +
 kernel/dma/swiotlb.c                          |   2 +
 kernel/events/core.c                          |   6 +-
 kernel/fork.c                                 |   3 +-
 kernel/futex.c                                |   6 +-
 kernel/irq/handle.c                           |   8 +
 kernel/irq/manage.c                           |   1 +
 kernel/sched/core.c                           |  14 +-
 kernel/sched/deadline.c                       |   6 +-
 kernel/sched/fair.c                           |   6 +-
 kernel/sched/idle.c                           |   3 +-
 kernel/sched/rt.c                             |   3 +-
 kernel/softirq.c                              |  25 ++-
 kernel/time/alarmtimer.c                      |   2 +-
 kernel/time/hrtimer.c                         |  11 +-
 kernel/time/posix-timers.c                    |   6 +-
 kernel/time/sched_clock.c                     |   3 +-
 kernel/time/tick-sched.c                      |   6 +-
 kernel/time/timer.c                           |   8 +
 kernel/watchdog.c                             |   3 +-
 lib/irq_poll.c                                |  18 +-
 lib/string.c                                  |   6 +
 mm/slab_common.c                              |   5 +-
 net/core/skbuff.c                             |  26 +++
 net/ipv4/tcp_output.c                         |   5 +-
 64 files changed, 843 insertions(+), 62 deletions(-)
 create mode 100644 Documentation/admin-guide/mds.rst
 create mode 100644 Documentation/clearcpu.txt
 create mode 100644 arch/x86/include/asm/clearbpf.h
 create mode 100644 arch/x86/include/asm/clearcpu.h
 create mode 100644 arch/x86/include/asm/trace/clearcpu.h
 create mode 100644 include/linux/clearcpu.h

-- 
2.17.2

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

end of thread, other threads:[~2019-02-21 12:06 UTC | newest]

Thread overview: 105+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-19  0:50 [MODERATED] [PATCH v5 00/27] MDSv5 19 Andi Kleen
2019-01-19  0:50 ` [MODERATED] [PATCH v5 01/27] MDSv5 26 Andi Kleen
2019-01-22  4:17   ` [MODERATED] " Konrad Rzeszutek Wilk
2019-01-22 12:46   ` Thomas Gleixner
2019-01-19  0:50 ` [MODERATED] [PATCH v5 02/27] MDSv5 14 Andi Kleen
2019-01-22  4:20   ` [MODERATED] " Konrad Rzeszutek Wilk
2019-01-22 12:51   ` Thomas Gleixner
2019-01-19  0:50 ` [MODERATED] [PATCH v5 03/27] MDSv5 16 Andi Kleen
2019-01-22  4:23   ` [MODERATED] " Konrad Rzeszutek Wilk
2019-01-22 12:55   ` Thomas Gleixner
2019-01-27 21:58   ` Thomas Gleixner
2019-01-28  3:30     ` [MODERATED] " Andi Kleen
2019-01-19  0:50 ` [MODERATED] [PATCH v5 04/27] MDSv5 15 Andi Kleen
2019-01-22  4:33   ` [MODERATED] " Konrad Rzeszutek Wilk
2019-01-22 12:59   ` Thomas Gleixner
2019-01-19  0:50 ` [MODERATED] [PATCH v5 05/27] MDSv5 21 Andi Kleen
2019-01-22  4:35   ` [MODERATED] " Konrad Rzeszutek Wilk
2019-01-22 13:01   ` Thomas Gleixner
2019-02-21 12:06   ` Thomas Gleixner
2019-01-19  0:50 ` [MODERATED] [PATCH v5 06/27] MDSv5 18 Andi Kleen
2019-01-21 22:41   ` [MODERATED] " Josh Poimboeuf
2019-01-22  1:16     ` Andi Kleen
2019-01-19  0:50 ` [MODERATED] [PATCH v5 07/27] MDSv5 0 Andi Kleen
2019-01-22  4:39   ` [MODERATED] " Konrad Rzeszutek Wilk
2019-01-27 22:09   ` Thomas Gleixner
2019-01-28  3:33     ` [MODERATED] " Andi Kleen
2019-01-28  8:29       ` Thomas Gleixner
2019-02-13 22:26   ` [MODERATED] " Tyler Hicks
2019-01-19  0:50 ` [MODERATED] [PATCH v5 08/27] MDSv5 13 Andi Kleen
2019-01-22  4:40   ` [MODERATED] " Konrad Rzeszutek Wilk
2019-01-19  0:50 ` [MODERATED] [PATCH v5 09/27] MDSv5 23 Andi Kleen
2019-01-22  4:56   ` [MODERATED] " Konrad Rzeszutek Wilk
2019-01-22  7:26   ` Greg KH
2019-01-22 13:07   ` Thomas Gleixner
2019-01-19  0:50 ` [MODERATED] [PATCH v5 10/27] MDSv5 7 Andi Kleen
2019-01-19  0:50 ` [MODERATED] [PATCH v5 11/27] MDSv5 2 Andi Kleen
2019-01-22 13:11   ` Thomas Gleixner
2019-01-19  0:50 ` [MODERATED] [PATCH v5 12/27] MDSv5 6 Andi Kleen
2019-01-22 14:01   ` Thomas Gleixner
2019-01-22 15:42     ` Thomas Gleixner
2019-01-22 18:01     ` [MODERATED] " Andi Kleen
2019-01-19  0:50 ` [MODERATED] [PATCH v5 13/27] MDSv5 17 Andi Kleen
2019-01-19  0:50 ` [MODERATED] [PATCH v5 14/27] MDSv5 3 Andi Kleen
2019-01-22  4:48   ` [MODERATED] " Konrad Rzeszutek Wilk
2019-01-22 15:58   ` Thomas Gleixner
2019-01-22 17:57     ` Thomas Gleixner
2019-01-23  1:35       ` [MODERATED] " Andi Kleen
2019-01-23  9:27         ` Thomas Gleixner
2019-01-23 16:02           ` [MODERATED] " Andi Kleen
2019-01-23 22:40             ` Josh Poimboeuf
2019-01-23 22:57               ` Josh Poimboeuf
2019-01-24  0:25                 ` Josh Poimboeuf
2019-01-24  2:26               ` Andi Kleen
2019-01-24 12:04             ` Thomas Gleixner
2019-01-28  3:42               ` [MODERATED] " Andi Kleen
2019-01-28  8:33                 ` Thomas Gleixner
2019-02-16  2:00       ` [MODERATED] " Andi Kleen
2019-02-16 10:32         ` Thomas Gleixner
2019-02-16 16:58           ` [MODERATED] " Andi Kleen
2019-02-16 17:12             ` Andi Kleen
2019-01-19  0:50 ` [MODERATED] [PATCH v5 15/27] MDSv5 1 Andi Kleen
2019-01-22  4:48   ` [MODERATED] " Konrad Rzeszutek Wilk
2019-01-19  0:50 ` [MODERATED] [PATCH v5 16/27] MDSv5 10 Andi Kleen
2019-01-22  4:54   ` [MODERATED] " Konrad Rzeszutek Wilk
2019-01-22  7:33   ` Greg KH
2019-01-19  0:50 ` [MODERATED] [PATCH v5 17/27] MDSv5 9 Andi Kleen
2019-01-19  0:50 ` [MODERATED] [PATCH v5 18/27] MDSv5 8 Andi Kleen
2019-01-22  5:07   ` [MODERATED] " Konrad Rzeszutek Wilk
2019-01-19  0:50 ` [MODERATED] [PATCH v5 19/27] MDSv5 12 Andi Kleen
2019-01-22  5:09   ` [MODERATED] " Konrad Rzeszutek Wilk
2019-01-19  0:50 ` [MODERATED] [PATCH v5 20/27] MDSv5 27 Andi Kleen
2019-01-19  0:50 ` [MODERATED] [PATCH v5 21/27] MDSv5 20 Andi Kleen
2019-01-22  5:11   ` [MODERATED] " Konrad Rzeszutek Wilk
2019-01-19  0:50 ` [MODERATED] [PATCH v5 22/27] MDSv5 24 Andi Kleen
2019-01-21 21:24   ` [MODERATED] " Linus Torvalds
2019-01-22  1:22     ` Andi Kleen
2019-01-22 16:09       ` Thomas Gleixner
2019-01-22 17:56         ` [MODERATED] " Andi Kleen
2019-01-22 18:56           ` Thomas Gleixner
2019-01-23  1:39             ` [MODERATED] " Andi Kleen
2019-01-23  6:39               ` Greg KH
2019-01-24  9:55               ` Thomas Gleixner
2019-01-19  0:50 ` [MODERATED] [PATCH v5 23/27] MDSv5 22 Andi Kleen
2019-01-19  0:50 ` [MODERATED] [PATCH v5 24/27] MDSv5 5 Andi Kleen
2019-01-21 21:20   ` [MODERATED] " Linus Torvalds
2019-01-19  0:50 ` [MODERATED] [PATCH v5 25/27] MDSv5 4 Andi Kleen
2019-01-22  5:15   ` [MODERATED] " Konrad Rzeszutek Wilk
2019-01-19  0:50 ` [MODERATED] [PATCH v5 26/27] MDSv5 11 Andi Kleen
2019-01-19  0:50 ` [MODERATED] [PATCH v5 27/27] MDSv5 25 Andi Kleen
2019-01-21 21:18 ` [MODERATED] Re: [PATCH v5 00/27] MDSv5 19 Linus Torvalds
2019-01-22  1:14   ` Andi Kleen
2019-01-22  7:38     ` Greg KH
2019-01-28 11:34 ` Thomas Gleixner
2019-02-13 22:33   ` [MODERATED] " Tyler Hicks
2019-02-14 13:09     ` Jiri Kosina
2019-02-14 13:51       ` Greg KH
2019-02-14 16:53       ` Andi Kleen
2019-02-14 18:00         ` Greg KH
2019-02-14 18:05           ` Andrew Cooper
2019-02-14 18:33           ` Andi Kleen
2019-02-14 18:52             ` Greg KH
2019-02-14 19:50               ` Andi Kleen
2019-02-15  7:06                 ` Greg KH
2019-02-15 13:06                   ` Andi Kleen
2019-02-19 12:12                     ` Greg KH

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.