All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch V6 00/14] MDS basics 0
@ 2019-03-01 21:47 Thomas Gleixner
  2019-03-01 21:47 ` [patch V6 01/14] MDS basics 1 Thomas Gleixner
                   ` (15 more replies)
  0 siblings, 16 replies; 89+ messages in thread
From: Thomas Gleixner @ 2019-03-01 21:47 UTC (permalink / raw)
  To: speck

Changes vs. V5:

  - Fix tools/ build (Josh)

  - Dropped the AIRMONT_MID change as it needs confirmation from Intel

  - Made the consolidated whitelist more readable and correct

  - Added the MSBDS only quirk for XEON PHI, made the idle flush
    depend on it and updated the sysfs output accordingly.

  - Fixed the protection matrix in the admin documentation and clarified
    the SMT situation vs. MSBDS only.

  - Updated the KVM/VMX changelog.

Delta patch against V5 below.

Available from git:

   cvs.ou.linutronix.de:linux/speck/linux WIP.mds

The linux-4.20.y, linux-4.19.y and linux-4.14.y branches are updated as
well and contain the untested backports of the pile for reference.

I'll send git bundles of the pile as well.

Thanks,

	tglx

8<---------------------------
diff --git a/Documentation/admin-guide/hw-vuln/mds.rst b/Documentation/admin-guide/hw-vuln/mds.rst
index 73cdc390aece..1de29d28903d 100644
--- a/Documentation/admin-guide/hw-vuln/mds.rst
+++ b/Documentation/admin-guide/hw-vuln/mds.rst
@@ -23,6 +23,10 @@ vulnerability is not present on:
 Whether a processor is affected or not can be read out from the MDS
 vulnerability file in sysfs. See :ref:`mds_sys_info`.
 
+Not all processors are affected by all variants of MDS, but the mitigation
+is identical for all of them so the kernel treats them as a single
+vulnerability.
+
 Related CVEs
 ------------
 
@@ -112,6 +116,7 @@ to the above information:
 
     ========================  ============================================
     'SMT vulnerable'          SMT is enabled
+    'SMT mitigated'           SMT is enabled and mitigated
     'SMT disabled'            SMT is disabled
     'SMT Host state unknown'  Kernel runs in a VM, Host SMT state unknown
     ========================  ============================================
@@ -153,8 +158,12 @@ CPU buffer clearing
   The mitigation for MDS clears the affected CPU buffers on return to user
   space and when entering a guest.
 
-  If SMT is enabled it also clears the buffers on idle entry, but that's not
-  a sufficient SMT protection for all MDS variants; it covers solely MSBDS.
+  If SMT is enabled it also clears the buffers on idle entry when the CPU
+  is only affected by MSBDS and not any other MDS variant, because the
+  other variants cannot be protected against cross Hyper-Thread attacks.
+
+  For CPUs which are only affected by MSBDS the user space, guest and idle
+  transition mitigations are sufficient and SMT is not affected.
 
 .. _virt_mechanism:
 
@@ -168,8 +177,10 @@ Virtualization mitigation
 
     If the L1D flush mitigation is enabled and up to date microcode is
     available, the L1D flush mitigation is automatically protecting the
-    guest transition. If the L1D flush mitigation is disabled the MDS
-    mitigation is disabled as well.
+    guest transition.
+
+    If the L1D flush mitigation is disabled then the MDS mitigation is
+    invoked explicit when the host MDS mitigation is enabled.
 
     For details on L1TF and virtualization see:
     :ref:`Documentation/admin-guide/hw-vuln//l1tf.rst <mitigation_control_kvm>`.
@@ -177,16 +188,18 @@ Virtualization mitigation
   - CPU is not affected by L1TF:
 
     CPU buffers are flushed before entering the guest when the host MDS
-    protection is enabled.
+    mitigation is enabled.
 
   The resulting MDS protection matrix for the host to guest transition:
 
   ============ ===== ============= ============ =================
-   L1TF         MDS   VMX-L1FLUSH   Host MDS     State
+   L1TF         MDS   VMX-L1FLUSH   Host MDS     MDS-State
 
    Don't care   No    Don't care    N/A          Not affected
 
-   Yes          Yes   Disabled      Don't care   Vulnerable
+   Yes          Yes   Disabled      Off          Vulnerable
+
+   Yes          Yes   Disabled      Full         Mitigated
 
    Yes          Yes   Enabled       Don't care   Mitigated
 
@@ -196,7 +209,7 @@ Virtualization mitigation
   ============ ===== ============= ============ =================
 
   This only covers the host to guest transition, i.e. prevents leakage from
-  host to guest, but does not protect the guest internally. Guest need to
+  host to guest, but does not protect the guest internally. Guests need to
   have their own protections.
 
 .. _xeon_phi:
@@ -210,14 +223,22 @@ XEON PHI specific considerations
   for malicious user space. The exposure can be disabled on the kernel
   command line with the 'ring3mwait=disable' command line option.
 
+  XEON PHI is not affected by the other MDS variants and MSBDS is mitigated
+  before the CPU enters a idle state. As XEON PHI is not affected by L1TF
+  either disabling SMT is not required for full protection.
+
 .. _mds_smt_control:
 
 SMT control
 ^^^^^^^^^^^
 
-  To prevent the SMT issues of MDS it might be necessary to disable SMT
-  completely. Disabling SMT can have a significant performance impact, but
-  the impact depends on the type of workloads.
+  All MDS variants except MSBDS can be attacked cross Hyper-Threads. That
+  means on CPUs which are affected by MFBDS or MLPDS it is necessary to
+  disable SMT for full protection. These are most of the affected CPUs; the
+  exception is XEON PHI, see :ref:`xeon_phi`.
+
+  Disabling SMT can have a significant performance impact, but the impact
+  depends on the type of workloads.
 
   See the relevant chapter in the L1TF mitigation documentation for details:
   :ref:`Documentation/admin-guide/hw-vuln/l1tf.rst <smt_control>`.
@@ -260,9 +281,7 @@ Mitigation selection guide
 2. Virtualization with trusted guests
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-   The same considerations as above versus trusted user space apply. See
-   also: :ref:`Documentation/admin-guide/hw-vuln//l1tf.rst <mitigation_selection>`.
-
+   The same considerations as above versus trusted user space apply.
 
 3. Virtualization with untrusted guests
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -270,6 +289,8 @@ Mitigation selection guide
    The protection depends on the state of the L1TF mitigations.
    See :ref:`virt_mechanism`.
 
+   If the MDS mitigation is enabled and SMT is disabled, guest to host and
+   guest to guest attacks are prevented.
 
 .. _mds_default_mitigations:
 
diff --git a/Documentation/x86/mds.rst b/Documentation/x86/mds.rst
index b050623c869c..3d6f943f1afb 100644
--- a/Documentation/x86/mds.rst
+++ b/Documentation/x86/mds.rst
@@ -107,19 +107,19 @@ user space or VM guests.
 Kernel internal mitigation modes
 --------------------------------
 
- ======= ===========================================================
- off     Mitigation is disabled. Either the CPU is not affected or
-         mds=off is supplied on the kernel command line
+ ======= ============================================================
+ off      Mitigation is disabled. Either the CPU is not affected or
+          mds=off is supplied on the kernel command line
 
- full    Mitigation is eanbled. CPU is affected and MD_CLEAR is
-         advertised in CPUID.
+ full     Mitigation is eanbled. CPU is affected and MD_CLEAR is
+          advertised in CPUID.
 
- vmwerv	 Mitigation is enabled. CPU is affected and MD_CLEAR is not
-	 advertised in CPUID. That is mainly for virtualization
-	 scenarios where the host has the updated microcode but the
-	 hypervisor does not expose MD_CLEAR in CPUID. It's a best
-	 effort approach without guarantee.
- ======= ===========================================================
+ vmwerv	  Mitigation is enabled. CPU is affected and MD_CLEAR is not
+	  advertised in CPUID. That is mainly for virtualization
+	  scenarios where the host has the updated microcode but the
+	  hypervisor does not expose MD_CLEAR in CPUID. It's a best
+	  effort approach without guarantee.
+ ======= ============================================================
 
 If the CPU is affected and mds=off is not supplied on the kernel command
 line then the kernel selects the appropriate mitigation mode depending on
@@ -189,6 +189,13 @@ Mitigation points
    When SMT is inactive, i.e. either the CPU does not support it or all
    sibling threads are offline CPU buffer clearing is not required.
 
+   The idle clearing is enabled on CPUs which are only affected by MSBDS
+   and not by any other MDS variant. The other MDS variants cannot be
+   protected against cross Hyper-Thread attacks because the Fill Buffer and
+   the Load Ports are shared. So on CPUs affected by other variants, the
+   idle clearing would be a window dressing exercise and is therefore not
+   activated.
+
    The invocation is controlled by the static key mds_idle_clear which is
    switched depending on the chosen mitigation mode and the SMT state of
    the system.
diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
index ae3f987b24f1..bdcea163850a 100644
--- a/arch/x86/include/asm/cpufeatures.h
+++ b/arch/x86/include/asm/cpufeatures.h
@@ -383,5 +383,6 @@
 #define X86_BUG_SPEC_STORE_BYPASS	X86_BUG(17) /* CPU is affected by speculative store bypass attack */
 #define X86_BUG_L1TF			X86_BUG(18) /* CPU is affected by L1 Terminal Fault */
 #define X86_BUG_MDS			X86_BUG(19) /* CPU is affected by Microarchitectural data sampling */
+#define X86_BUG_MSBDS_ONLY		X86_BUG(20) /* CPU is only affected by the  MSDBS variant of BUG_MDS */
 
 #endif /* _ASM_X86_CPUFEATURES_H */
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index aea871e69d64..e11654f93e71 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -667,6 +667,15 @@ static void update_indir_branch_cond(void)
 /* Update the static key controlling the MDS CPU buffer clear in idle */
 static void update_mds_branch_idle(void)
 {
+	/*
+	 * Enable the idle clearing on CPUs which are affected only by
+	 * MDBDS and not any other MDS variant. The other variants cannot
+	 * be mitigated when SMT is enabled, so clearing the buffers on
+	 * idle would be a window dressing exercise.
+	 */
+	if (!boot_cpu_has(X86_BUG_MSBDS_ONLY))
+		return;
+
 	if (sched_smt_active())
 		static_branch_enable(&mds_idle_clear);
 	else
@@ -1174,6 +1183,11 @@ static ssize_t mds_show_state(char *buf)
 			       mds_strings[mds_mitigation]);
 	}
 
+	if (boot_cpu_has(X86_BUG_MSBDS_ONLY)) {
+		return sprintf(buf, "%s; SMT %s\n", mds_strings[mds_mitigation],
+			       sched_smt_active() ? "mitigated" : "disabled");
+	}
+
 	return sprintf(buf, "%s; SMT %s\n", mds_strings[mds_mitigation],
 		       sched_smt_active() ? "vulnerable" : "disabled");
 }
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 389853338c2f..71d953a2c4db 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -953,38 +953,57 @@ static void identify_cpu_without_cpuid(struct cpuinfo_x86 *c)
 #define NO_SSB		BIT(2)
 #define NO_L1TF		BIT(3)
 #define NO_MDS		BIT(4)
+#define MSBDS_ONLY	BIT(5)
+
+#define VULNWL(_vendor, _family, _model, _whitelist)	\
+	{ X86_VENDOR_##_vendor, _family, _model, X86_FEATURE_ANY, _whitelist }
+
+#define VULNWL_INTEL(model, whitelist)		\
+	VULNWL(INTEL, 6, INTEL_FAM6_##model, whitelist)
+
+#define VULNWL_AMD(family, whitelist)		\
+	VULNWL(AMD, family, X86_MODEL_ANY, whitelist)
+
+#define VULNWL_HYGON(family, whitelist)		\
+	VULNWL(HYGON, family, X86_MODEL_ANY, whitelist)
 
 static const __initconst struct x86_cpu_id cpu_vuln_whitelist[] = {
-	{ X86_VENDOR_ANY,	4, X86_MODEL_ANY,			X86_FEATURE_ANY, NO_SPECULATION },
-	{ X86_VENDOR_CENTAUR,	5, X86_MODEL_ANY,			X86_FEATURE_ANY, NO_SPECULATION },
-	{ X86_VENDOR_INTEL,	5, X86_MODEL_ANY,			X86_FEATURE_ANY, NO_SPECULATION },
-	{ X86_VENDOR_NSC,	5, X86_MODEL_ANY,			X86_FEATURE_ANY, NO_SPECULATION },
-	{ X86_VENDOR_INTEL,	6, INTEL_FAM6_ATOM_SALTWELL,		X86_FEATURE_ANY, NO_SPECULATION },
-	{ X86_VENDOR_INTEL,	6, INTEL_FAM6_ATOM_SALTWELL_TABLET,	X86_FEATURE_ANY, NO_SPECULATION },
-	{ X86_VENDOR_INTEL,	6, INTEL_FAM6_ATOM_BONNELL_MID,		X86_FEATURE_ANY, NO_SPECULATION },
-	{ X86_VENDOR_INTEL,	6, INTEL_FAM6_ATOM_SALTWELL_MID,	X86_FEATURE_ANY, NO_SPECULATION },
-	{ X86_VENDOR_INTEL,	6, INTEL_FAM6_ATOM_BONNELL,		X86_FEATURE_ANY, NO_SPECULATION },
-
-	{ X86_VENDOR_AMD,	X86_FAMILY_ANY, X86_MODEL_ANY,		X86_FEATURE_ANY, NO_MELTDOWN | NO_L1TF },
-	{ X86_VENDOR_HYGON,	X86_FAMILY_ANY, X86_MODEL_ANY,		X86_FEATURE_ANY, NO_MELTDOWN | NO_L1TF },
-
-	{ X86_VENDOR_INTEL,	6, INTEL_FAM6_ATOM_SILVERMONT,		X86_FEATURE_ANY, NO_SSB | NO_L1TF },
-	{ X86_VENDOR_INTEL,	6, INTEL_FAM6_ATOM_SILVERMONT_X,	X86_FEATURE_ANY, NO_SSB | NO_L1TF },
-	{ X86_VENDOR_INTEL,	6, INTEL_FAM6_ATOM_SILVERMONT_MID,	X86_FEATURE_ANY, NO_SSB | NO_L1TF },
-	{ X86_VENDOR_INTEL,	6, INTEL_FAM6_ATOM_AIRMONT,		X86_FEATURE_ANY, NO_SSB | NO_L1TF },
-	{ X86_VENDOR_INTEL,	6, INTEL_FAM6_ATOM_AIRMONT_MID,		X86_FEATURE_ANY, NO_SSB | NO_L1TF },
-	{ X86_VENDOR_INTEL,	6, INTEL_FAM6_CORE_YONAH,		X86_FEATURE_ANY, NO_SSB | NO_L1TF },
-	{ X86_VENDOR_INTEL,	6, INTEL_FAM6_XEON_PHI_KNL,		X86_FEATURE_ANY, NO_SSB | NO_L1TF },
-	{ X86_VENDOR_INTEL,	6, INTEL_FAM6_XEON_PHI_KNM,		X86_FEATURE_ANY, NO_SSB | NO_L1TF },
-
-	{ X86_VENDOR_INTEL,	6, INTEL_FAM6_ATOM_GOLDMONT,		X86_FEATURE_ANY, NO_L1TF | NO_MDS },
-	{ X86_VENDOR_INTEL,	6, INTEL_FAM6_ATOM_GOLDMONT_X,		X86_FEATURE_ANY, NO_L1TF | NO_MDS },
-	{ X86_VENDOR_INTEL,	6, INTEL_FAM6_ATOM_GOLDMONT_PLUS,	X86_FEATURE_ANY, NO_L1TF | NO_MDS },
-
-	{ X86_VENDOR_AMD,	0x0f, X86_MODEL_ANY,			X86_FEATURE_ANY, NO_SSB },
-	{ X86_VENDOR_AMD,	0x10, X86_MODEL_ANY,			X86_FEATURE_ANY, NO_SSB },
-	{ X86_VENDOR_AMD,	0x11, X86_MODEL_ANY,			X86_FEATURE_ANY, NO_SSB },
-	{ X86_VENDOR_AMD,	0x12, X86_MODEL_ANY,			X86_FEATURE_ANY, NO_SSB },
+	VULNWL(ANY,	4, X86_MODEL_ANY,	NO_SPECULATION),
+	VULNWL(CENTAUR,	5, X86_MODEL_ANY,	NO_SPECULATION),
+	VULNWL(INTEL,	5, X86_MODEL_ANY,	NO_SPECULATION),
+	VULNWL(NSC,	5, X86_MODEL_ANY,	NO_SPECULATION),
+
+	/* Intel Family 6 */
+	VULNWL_INTEL(ATOM_SALTWELL,		NO_SPECULATION),
+	VULNWL_INTEL(ATOM_SALTWELL_TABLET,	NO_SPECULATION),
+	VULNWL_INTEL(ATOM_SALTWELL_MID,		NO_SPECULATION),
+	VULNWL_INTEL(ATOM_BONNELL,		NO_SPECULATION),
+	VULNWL_INTEL(ATOM_BONNELL_MID,		NO_SPECULATION),
+
+	VULNWL_INTEL(ATOM_SILVERMONT,		NO_SSB | NO_L1TF),
+	VULNWL_INTEL(ATOM_SILVERMONT_X,		NO_SSB | NO_L1TF),
+	VULNWL_INTEL(ATOM_SILVERMONT_MID,	NO_SSB | NO_L1TF),
+	VULNWL_INTEL(ATOM_AIRMONT,		NO_SSB | NO_L1TF),
+	VULNWL_INTEL(XEON_PHI_KNL,		NO_SSB | NO_L1TF | MSBDS_ONLY),
+	VULNWL_INTEL(XEON_PHI_KNM,		NO_SSB | NO_L1TF | MSBDS_ONLY),
+
+	VULNWL_INTEL(CORE_YONAH,		NO_SSB),
+
+	VULNWL_INTEL(ATOM_AIRMONT_MID,		NO_L1TF),
+
+	VULNWL_INTEL(ATOM_GOLDMONT,		NO_MDS | NO_L1TF),
+	VULNWL_INTEL(ATOM_GOLDMONT_X,		NO_MDS | NO_L1TF),
+	VULNWL_INTEL(ATOM_GOLDMONT_PLUS,	NO_MDS | NO_L1TF),
+
+	/* AMD Family 0xf - 0x12 */
+	VULNWL_AMD(0x0f,	NO_MELTDOWN | NO_SSB | NO_L1TF | NO_MDS),
+	VULNWL_AMD(0x10,	NO_MELTDOWN | NO_SSB | NO_L1TF | NO_MDS),
+	VULNWL_AMD(0x11,	NO_MELTDOWN | NO_SSB | NO_L1TF | NO_MDS),
+	VULNWL_AMD(0x12,	NO_MELTDOWN | NO_SSB | NO_L1TF | NO_MDS),
+
+	/* FAMILY_ANY must be last, otherwise 0x0f - 0x12 matches won't work */
+	VULNWL_AMD(X86_FAMILY_ANY,	NO_MELTDOWN | NO_L1TF | NO_MDS),
+	VULNWL_HYGON(X86_FAMILY_ANY,	NO_MELTDOWN | NO_L1TF | NO_MDS),
 	{}
 };
 
@@ -1015,8 +1034,11 @@ static void __init cpu_set_bug_bits(struct cpuinfo_x86 *c)
 	if (ia32_cap & ARCH_CAP_IBRS_ALL)
 		setup_force_cpu_cap(X86_FEATURE_IBRS_ENHANCED);
 
-	if (!cpu_matches(NO_MDS) && !(ia32_cap & ARCH_CAP_MDS_NO))
+	if (!cpu_matches(NO_MDS) && !(ia32_cap & ARCH_CAP_MDS_NO)) {
 		setup_force_cpu_bug(X86_BUG_MDS);
+		if (cpu_matches(MSBDS_ONLY))
+			setup_force_cpu_bug(X86_BUG_MSBDS_ONLY);
+	}
 
 	if (cpu_matches(NO_MELTDOWN))
 		return;
diff --git a/tools/power/x86/turbostat/Makefile b/tools/power/x86/turbostat/Makefile
index 1598b4fa0b11..045f5f7d68ab 100644
--- a/tools/power/x86/turbostat/Makefile
+++ b/tools/power/x86/turbostat/Makefile
@@ -9,7 +9,7 @@ ifeq ("$(origin O)", "command line")
 endif
 
 turbostat : turbostat.c
-override CFLAGS +=	-Wall
+override CFLAGS +=	-Wall -I../../../include
 override CFLAGS +=	-DMSRHEADER='"../../../../arch/x86/include/asm/msr-index.h"'
 override CFLAGS +=	-DINTEL_FAMILY_HEADER='"../../../../arch/x86/include/asm/intel-family.h"'
 
diff --git a/tools/power/x86/x86_energy_perf_policy/Makefile b/tools/power/x86/x86_energy_perf_policy/Makefile
index ae7a0e09b722..1fdeef864e7c 100644
--- a/tools/power/x86/x86_energy_perf_policy/Makefile
+++ b/tools/power/x86/x86_energy_perf_policy/Makefile
@@ -9,7 +9,7 @@ ifeq ("$(origin O)", "command line")
 endif
 
 x86_energy_perf_policy : x86_energy_perf_policy.c
-override CFLAGS +=	-Wall
+override CFLAGS +=	-Wall -I../../../include
 override CFLAGS +=	-DMSRHEADER='"../../../../arch/x86/include/asm/msr-index.h"'
 
 %: %.c

^ permalink raw reply related	[flat|nested] 89+ messages in thread
* [MODERATED] Starting to go public?
@ 2019-03-05 16:43 Linus Torvalds
  2019-03-05 17:02 ` [MODERATED] " Andrew Cooper
  2019-03-05 17:10 ` Jon Masters
  0 siblings, 2 replies; 89+ messages in thread
From: Linus Torvalds @ 2019-03-05 16:43 UTC (permalink / raw)
  To: speck

Looks like the papers are starting to leak:

   https://arxiv.org/pdf/1903.00446.pdf

yes, yes, a lot of the attack seems to be about rowhammer, but the
"spolier" part looks like MDS.

             Linus

^ permalink raw reply	[flat|nested] 89+ messages in thread
* [MODERATED] [PATCH RFC 0/4] Proposed cmdline improvements
@ 2019-03-04  1:21 Josh Poimboeuf
  2019-03-04  1:23 ` [MODERATED] [PATCH RFC 1/4] 1 Josh Poimboeuf
                   ` (2 more replies)
  0 siblings, 3 replies; 89+ messages in thread
From: Josh Poimboeuf @ 2019-03-04  1:21 UTC (permalink / raw)
  To: speck


For MDS and SMT, I'd propose that we do something similar to what we did
for L1TF: a) add an mds=full,nosmt option; and b) add a printk warning
if SMT is enabled.  That's the first three patches.

The last patch proposes a meta-option which is intended to make it
easier for users to choose sane mitigation defaults for all the
speculative vulnerabilities at once.

Josh Poimboeuf (4):
  x86/speculation/mds: Add mds=full,nosmt cmdline option
  x86/speculation: Move arch_smt_update() call to after mitigation
    decisions
  x86/speculation/mds: Add SMT warning message
  x86/speculation: Add 'cpu_spec_mitigations=' cmdline options

 Documentation/admin-guide/hw-vuln/mds.rst     |  3 +
 .../admin-guide/kernel-parameters.txt         | 49 ++++++++++++-
 arch/powerpc/kernel/security.c                |  6 +-
 arch/powerpc/kernel/setup_64.c                |  2 +-
 arch/s390/kernel/nospec-branch.c              |  4 +-
 arch/x86/include/asm/processor.h              |  2 +
 arch/x86/kernel/cpu/bugs.c                    | 68 ++++++++++++++++---
 arch/x86/mm/pti.c                             |  3 +-
 include/linux/cpu.h                           |  8 +++
 kernel/cpu.c                                  | 15 ++++
 10 files changed, 144 insertions(+), 16 deletions(-)

-- 
2.17.2

^ permalink raw reply	[flat|nested] 89+ messages in thread
* [MODERATED] [PATCH v6 00/43] MDSv6
@ 2019-02-24 15:07 Andi Kleen
  2019-02-24 15:07 ` [MODERATED] [PATCH v6 10/43] MDSv6 Andi Kleen
  2019-02-24 15:07 ` [MODERATED] [PATCH v6 31/43] MDSv6 Andi Kleen
  0 siblings, 2 replies; 89+ messages in thread
From: Andi Kleen @ 2019-02-24 15:07 UTC (permalink / raw)
  To: speck; +Cc: Andi Kleen

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

I would be mainly interested in feedback on the lazy approach,
so please focus on the later patches.

There didn't seem to be much interest in it, so I wonder
if it still makes sense to continue with it? Or could
we just stay with the full approach?

The lazy approach is faster, but not by that much
and may not be worth the short and long term impact
all over the tree.

This version is based on my earlier base patches, with the 
mds=full implementation being at the beginning, and a lazy
implementation building on top of it. The patch can
be rebased on the rewrite once it matures.

Even the base has some features not in Thomas' version which would
need to be ported (e.g. more complete virtualization support
and EBPF mitigation)

This patch implements the "full tree audit" approach that
was suggested by several reviewers. We (me and Mark Gross) 
went through most asynchronous code in the kernel and marked the
functions that touch user or IO data. This leaves most asynchronous
interrupts etc. to not schedule a clear. However this would
need to be continuously enforced for new code too.

It also implements various other review suggestions
and improvements. clearcpu.txt is now clarified in many ways.

Before reviewing please read Documentation/clearcpu.txt

Some performance data for lazy:  

Kernel build: 		~+1%   (slightly faster, but that's within noise)
loopback apache	      	 -1%   (within noise)
ebizzy           	-0.3%  (within noise)
aim7		        -5.0%
netperf rr 	        -0.7%
netperf stream		 0.0%

In comparison an older version of mds=full showed:

kernel build	        -2.4%
ebizzy			-3.3%
apache loopback	       -10.0%

For networking workloads there is practically no regression now.
AIM7 is showing some regression. I assume this is due to the context
switch overhead.

mds=full is a bit slower, but not that much. The only real outlier is
apache loopback, which is probably not too realistic a workload
because it mainly does tight loops over some syscalls.

No changelog against previous versions, too many changes.

Andi Kleen (42):
  x86/speculation/mds: Add basic bug infrastructure for MDS
  x86/speculation/mds: Clear CPU on every kernel exit
  x86/speculation/mds: Clear CPU buffers on entering idle
  x86/speculation/mds: Add command line options to control mds
  x86/speculation/mds: Add sysfs reporting
  mds: Add some administrator documentation
  x86/speculation/mds: Export MD_CLEAR CPUID to KVM guests.
  x86/cpufeatures: Add word 20 for additional features
  x86/speculation/mds: Handle VMENTRY clear for CPUs without l1tf
  mds: Add documentation for clear cpu usage
  x86/speculation/mds: Introduce lazy_clear_cpu
  x86/speculation/mds: Add basic implementation of mds=full
  x86/speculation/mds: Check lazy clear in kernel exit
  x86/speculation/mds: Add tracing for clear_cpu
  x86/speculation/mds: Schedule cpu clear on context switch
  mds: Force clear cpu on kernel preemption
  mds: Clear cpu in memzero_explicit and kzfree
  mds: Support cpu clear in interrupts
  mds: Support cpu clear after tasklets
  mds: Support cpu clearing in timers
  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: Clear cpu for kmap_atomic in interrupts
  mds: Support cpu clearing for BPF
  mds sweep: Schedule clear cpus in sound core
  mds sweep: Make MPU401 interrupts clear cpu
  mds sweep: Clear cpu on processing input layer data
  mds sweep: Clear cpu for tty input
  mds sweep: Clear cpu for usbmon intercepts
  mds sweep: Clear cpu in some Xen drivers
  mds sweep: Clear cpu in DVB software filters
  mds sweep: Mark all DRM interrupts to clear cpu
  mds sweep: Make all old style IDE driver interrupts clear cpu
  mds sweep: Make Amazon ena driver management interrupt clear cpu
  mds sweep: Make all PCMCIA interrupts clear cpu
  mds sweep: Mark common functions in comedi as clear cpu
  mds sweep: Make usb hcd poll clear cpu
  x86/speculation/mds: Switch mds=auto to lazy
  mds sweep: Mark interrupts that touch user data
  mds sweep: Mark timer handlers that touch user data
  mds sweep: Mark tasklets that touch user data

Mark Gross (1):
  mds sweep: Clear cpu in sg_copy_from_buffer for SCSI

 .../ABI/testing/sysfs-devices-system-cpu      |   1 +
 .../admin-guide/kernel-parameters.txt         |  11 +
 Documentation/admin-guide/mds.rst             |  95 +++++++
 Documentation/clearcpu.txt                    | 261 ++++++++++++++++++
 arch/Kconfig                                  |   3 +
 arch/x86/Kconfig                              |   1 +
 arch/x86/entry/common.c                       |   8 +
 arch/x86/events/intel/uncore.c                |   3 +-
 arch/x86/include/asm/clearbpf.h               |  29 ++
 arch/x86/include/asm/clearcpu.h               |  83 ++++++
 arch/x86/include/asm/cpufeature.h             |   6 +-
 arch/x86/include/asm/cpufeatures.h            |   9 +-
 arch/x86/include/asm/disabled-features.h      |   3 +-
 arch/x86/include/asm/floppy.h                 |   6 +-
 arch/x86/include/asm/io.h                     |   3 +
 arch/x86/include/asm/msr-index.h              |   1 +
 arch/x86/include/asm/required-features.h      |   3 +-
 arch/x86/include/asm/trace/clearcpu.h         |  27 ++
 arch/x86/kernel/acpi/cstate.c                 |   2 +
 arch/x86/kernel/cpu/bugs.c                    |  82 ++++++
 arch/x86/kernel/cpu/common.c                  |  25 ++
 arch/x86/kernel/kvm.c                         |   3 +
 arch/x86/kernel/nmi.c                         |   6 +-
 arch/x86/kernel/process.c                     |   5 +
 arch/x86/kernel/process.h                     |   1 +
 arch/x86/kernel/smpboot.c                     |   3 +
 arch/x86/kvm/cpuid.c                          |   3 +-
 arch/x86/kvm/vmx/vmx.c                        |  20 +-
 arch/x86/mm/highmem_32.c                      |   3 +
 arch/x86/mm/tlb.c                             |  14 +
 drivers/acpi/acpi_pad.c                       |   2 +
 drivers/acpi/processor_idle.c                 |   3 +
 drivers/atm/eni.c                             |   3 +-
 drivers/atm/he.c                              |   3 +-
 drivers/atm/lanai.c                           |   4 +-
 drivers/atm/nicstar.c                         |   4 +-
 drivers/auxdisplay/img-ascii-lcd.c            |   2 +-
 drivers/base/cpu.c                            |   8 +
 drivers/block/xsysace.c                       |   5 +-
 drivers/char/ipmi/ipmi_si_intf.c              |   6 +-
 drivers/char/sonypi.c                         |   3 +-
 drivers/crypto/ixp4xx_crypto.c                |   3 +-
 drivers/crypto/qat/qat_common/adf_isr.c       |   7 +-
 drivers/crypto/qat/qat_common/adf_sriov.c     |   6 +-
 drivers/crypto/qat/qat_common/adf_vf_isr.c    |  10 +-
 drivers/dma/dw/core.c                         |   3 +-
 drivers/dma/ioat/init.c                       |   3 +-
 drivers/dma/virt-dma.c                        |   3 +-
 drivers/firewire/core-transaction.c           |   5 +-
 drivers/firewire/nosy.c                       |   3 +-
 drivers/gpu/drm/drm_irq.c                     |   3 +-
 drivers/gpu/drm/gma500/oaktrail_hdmi_i2c.c    |   3 +-
 drivers/gpu/drm/i915/i915_pmu.c               |   3 +-
 drivers/gpu/drm/i915/intel_lrc.c              |   5 +-
 .../gpu/drm/nouveau/nvkm/subdev/pci/base.c    |   3 +-
 drivers/hv/channel_mgmt.c                     |   4 +-
 drivers/hv/hv.c                               |   4 +-
 drivers/i2c/busses/i2c-emev2.c                |   5 +-
 drivers/i2c/busses/i2c-i801.c                 |   2 +-
 drivers/i2c/busses/i2c-pxa.c                  |   4 +-
 drivers/i2c/busses/i2c-rk3x.c                 |   3 +-
 drivers/ide/ide-probe.c                       |   5 +-
 drivers/idle/intel_idle.c                     |   5 +
 drivers/iio/trigger/iio-trig-hrtimer.c        |   3 +-
 drivers/infiniband/hw/bnxt_re/qplib_fp.c      |   4 +-
 drivers/infiniband/hw/bnxt_re/qplib_rcfw.c    |   4 +-
 drivers/infiniband/hw/i40iw/i40iw_main.c      |   9 +-
 drivers/infiniband/hw/mthca/mthca_eq.c        |  14 +-
 drivers/infiniband/hw/qib/qib_sdma.c          |   4 +-
 drivers/infiniband/sw/rxe/rxe_cq.c            |   3 +-
 drivers/input/ff-memless.c                    |   2 +-
 drivers/input/input.c                         |   5 +-
 drivers/input/misc/xen-kbdfront.c             |   3 +-
 drivers/input/serio/hil_mlc.c                 |   2 +-
 drivers/input/serio/i8042.c                   |  13 +-
 drivers/input/serio/serio.c                   |   3 +
 drivers/ipack/carriers/tpci200.c              |   6 +-
 drivers/isdn/capi/capidrv.c                   |   2 +-
 drivers/isdn/gigaset/bas-gigaset.c            |   8 +-
 drivers/isdn/gigaset/common.c                 |   4 +-
 drivers/isdn/gigaset/ser-gigaset.c            |   4 +-
 drivers/isdn/gigaset/usb-gigaset.c            |   4 +-
 drivers/isdn/hardware/avm/b1isa.c             |   4 +-
 drivers/isdn/hardware/avm/b1pci.c             |   6 +-
 drivers/isdn/hardware/avm/b1pcmcia.c          |   3 +-
 drivers/isdn/hardware/avm/c4.c                |   3 +-
 drivers/isdn/hardware/avm/t1isa.c             |   4 +-
 drivers/isdn/hardware/avm/t1pci.c             |   3 +-
 drivers/isdn/hardware/mISDN/avmfritz.c        |   4 +-
 drivers/isdn/hardware/mISDN/hfcmulti.c        |   3 +-
 drivers/isdn/hardware/mISDN/hfcpci.c          |   2 +-
 drivers/isdn/hardware/mISDN/mISDNinfineon.c   |   3 +-
 drivers/isdn/hardware/mISDN/netjet.c          |   2 +-
 drivers/isdn/hardware/mISDN/speedfax.c        |   3 +-
 drivers/isdn/hardware/mISDN/w6692.c           |   2 +-
 drivers/isdn/hisax/config.c                   |   2 +-
 drivers/isdn/hisax/hfc4s8s_l1.c               |   3 +-
 drivers/isdn/hisax/hisax_fcpcipnp.c           |  13 +-
 drivers/isdn/i4l/isdn_common.c                |   2 +-
 drivers/media/cec/cec-pin.c                   |   3 +-
 drivers/media/common/saa7146/saa7146_core.c   |   4 +-
 drivers/media/dvb-core/dvb_demux.c            |   3 +
 drivers/media/pci/b2c2/flexcop-pci.c          |   3 +-
 drivers/media/pci/bt8xx/bttv-driver.c         |   2 +-
 drivers/media/pci/bt8xx/bttv-input.c          |   5 +-
 drivers/media/pci/bt8xx/dvb-bt8xx.c           |   3 +-
 drivers/media/pci/cobalt/cobalt-driver.c      |   3 +-
 drivers/media/pci/cx18/cx18-driver.c          |   3 +-
 drivers/media/pci/cx25821/cx25821-core.c      |   2 +-
 drivers/media/pci/cx88/cx88-alsa.c            |   3 +-
 drivers/media/pci/cx88/cx88-mpeg.c            |   2 +-
 drivers/media/pci/cx88/cx88-video.c           |   2 +-
 drivers/media/pci/dt3155/dt3155.c             |   2 +-
 drivers/media/pci/intel/ipu3/ipu3-cio2.c      |   2 +-
 drivers/media/pci/ivtv/ivtv-driver.c          |   3 +-
 drivers/media/pci/mantis/mantis_dvb.c         |   3 +-
 drivers/media/pci/meye/meye.c                 |   3 +-
 .../pci/netup_unidvb/netup_unidvb_core.c      |   3 +-
 drivers/media/pci/ngene/ngene-core.c          |   5 +-
 drivers/media/pci/pluto2/pluto2.c             |   3 +-
 drivers/media/pci/saa7134/saa7134-alsa.c      |   4 +-
 drivers/media/pci/saa7134/saa7134-core.c      |   2 +-
 drivers/media/pci/saa7134/saa7134-input.c     |   3 +-
 drivers/media/pci/saa7134/saa7134-ts.c        |   3 +-
 drivers/media/pci/saa7134/saa7134-vbi.c       |   3 +-
 drivers/media/pci/saa7134/saa7134-video.c     |   3 +-
 drivers/media/pci/saa7164/saa7164-core.c      |   7 +-
 drivers/media/pci/smipcie/smipcie-main.c      |   3 +-
 drivers/media/pci/solo6x10/solo6x10-core.c    |   4 +-
 drivers/media/pci/sta2x11/sta2x11_vip.c       |   5 +-
 drivers/media/pci/ttpci/av7110.c              |  12 +-
 drivers/media/pci/ttpci/av7110_ir.c           |   3 +-
 drivers/media/pci/ttpci/budget-ci.c           |   9 +-
 drivers/media/pci/ttpci/budget-core.c         |   3 +-
 drivers/media/pci/tw5864/tw5864-video.c       |   4 +-
 drivers/media/pci/tw68/tw68-core.c            |   2 +-
 drivers/media/pci/tw686x/tw686x-core.c        |   4 +-
 drivers/media/platform/aspeed-video.c         |   5 +-
 .../media/platform/marvell-ccic/cafe-driver.c |   3 +-
 .../media/platform/marvell-ccic/mcam-core.c   |   4 +-
 drivers/media/radio/radio-cadet.c             |   2 +-
 drivers/media/radio/wl128x/fmdrv_common.c     |   9 +-
 drivers/media/rc/fintek-cir.c                 |   3 +-
 drivers/media/rc/gpio-ir-recv.c               |   2 +-
 drivers/media/rc/img-ir/img-ir-raw.c          |   2 +-
 drivers/media/rc/ir-hix5hd2.c                 |   3 +-
 drivers/media/rc/ir-rx51.c                    |   3 +-
 drivers/media/rc/ite-cir.c                    |   3 +-
 drivers/media/rc/nuvoton-cir.c                |   3 +-
 drivers/media/rc/serial_ir.c                  |   2 +-
 drivers/media/rc/sir_ir.c                     |   3 +-
 drivers/media/rc/winbond-cir.c                |   2 +-
 drivers/media/usb/au0828/au0828-video.c       |   6 +-
 drivers/media/usb/ttusb-dec/ttusb_dec.c       |   5 +-
 drivers/memstick/host/jmb38x_ms.c             |   6 +-
 drivers/message/fusion/mptbase.c              |   3 +-
 drivers/mfd/ezx-pcap.c                        |   4 +-
 drivers/misc/ibmasm/module.c                  |   4 +-
 drivers/misc/sgi-gru/grufile.c                |   7 +-
 drivers/misc/sgi-xp/xpc_uv.c                  |   3 +-
 drivers/misc/vmw_vmci/vmci_guest.c            |   8 +-
 drivers/mmc/host/mtk-sd.c                     |   3 +-
 drivers/mmc/host/wbsd.c                       |  20 +-
 drivers/net/appletalk/cops.c                  |   2 +-
 drivers/net/arcnet/arc-rimi.c                 |   2 +-
 drivers/net/arcnet/com20020.c                 |   3 +-
 drivers/net/arcnet/com90io.c                  |   3 +-
 drivers/net/arcnet/com90xx.c                  |   2 +-
 drivers/net/caif/caif_hsi.c                   |   9 +-
 drivers/net/can/cc770/cc770.c                 |   4 +-
 drivers/net/can/peak_canfd/peak_pciefd_main.c |   8 +-
 drivers/net/can/sja1000/ems_pcmcia.c          |   4 +-
 drivers/net/can/sja1000/peak_pcmcia.c         |   3 +-
 drivers/net/can/sja1000/sja1000.c             |   5 +-
 drivers/net/ethernet/3com/3c509.c             |   3 +-
 drivers/net/ethernet/3com/3c515.c             |   6 +-
 drivers/net/ethernet/8390/axnet_cs.c          |   3 +-
 drivers/net/ethernet/8390/ne.c                |   3 +-
 drivers/net/ethernet/8390/ne2k-pci.c          |   3 +-
 drivers/net/ethernet/8390/pcnet_cs.c          |   3 +-
 drivers/net/ethernet/8390/smc-ultra.c         |   3 +-
 drivers/net/ethernet/8390/wd.c                |   3 +-
 drivers/net/ethernet/agere/et131x.c           |   4 +-
 drivers/net/ethernet/amazon/ena/ena_netdev.c  |   5 +-
 drivers/net/ethernet/amazon/ena/ena_netdev.h  |   1 +
 drivers/net/ethernet/amd/lance.c              |   2 +-
 drivers/net/ethernet/amd/ni65.c               |   5 +-
 drivers/net/ethernet/atheros/atlx/atl1.c      |   4 +-
 drivers/net/ethernet/atheros/atlx/atl2.c      |   4 +-
 drivers/net/ethernet/broadcom/cnic.c          |   8 +-
 drivers/net/ethernet/cadence/macb_main.c      |   4 +-
 .../net/ethernet/chelsio/cxgb3/cxgb3_main.c   |  16 +-
 drivers/net/ethernet/micrel/ks8842.c          |   7 +-
 drivers/net/ethernet/micrel/ks8851_mll.c      |   3 +-
 drivers/net/ethernet/microchip/lan743x_main.c |   7 +-
 drivers/net/ethernet/realtek/atp.c            |   3 +-
 drivers/net/fddi/skfp/skfddi.c                |   4 +-
 drivers/net/hamradio/6pack.c                  |   4 +-
 drivers/net/hamradio/baycom_ser_fdx.c         |   3 +-
 drivers/net/hamradio/baycom_ser_hdx.c         |   3 +-
 drivers/net/hamradio/scc.c                    |   8 +-
 drivers/net/hamradio/yam.c                    |   6 +-
 drivers/net/hippi/rrunner.c                   |   2 +-
 drivers/net/ieee802154/at86rf230.c            |   6 +-
 drivers/net/ieee802154/ca8210.c               |  10 +-
 drivers/net/ieee802154/mcr20a.c               |   3 +-
 drivers/net/ieee802154/mrf24j40.c             |   3 +-
 drivers/net/ppp/ppp_async.c                   |   3 +-
 drivers/net/ppp/ppp_synctty.c                 |   3 +-
 drivers/net/slip/slip.c                       |   4 +-
 drivers/net/usb/cdc_ncm.c                     |   3 +-
 drivers/net/usb/hso.c                         |   6 +-
 drivers/net/wan/cosa.c                        |   2 +-
 drivers/net/wan/farsync.c                     |   6 +-
 drivers/net/wan/hostess_sv11.c                |   3 +-
 drivers/net/wan/sbni.c                        |   2 +-
 drivers/net/wan/sdla.c                        |   4 +-
 drivers/net/wan/sealevel.c                    |   3 +-
 drivers/net/wireless/ath/ath9k/init.c         |   5 +-
 drivers/net/wireless/ath/carl9170/usb.c       |   4 +-
 .../net/wireless/broadcom/b43legacy/main.c    |   8 +-
 drivers/net/wireless/broadcom/b43legacy/pio.c |   4 +-
 .../broadcom/brcm80211/brcmfmac/bcmsdh.c      |   7 +-
 .../broadcom/brcm80211/brcmsmac/mac80211_if.c |   3 +-
 drivers/net/wireless/cisco/airo.c             |   4 +-
 drivers/net/wireless/intel/ipw2x00/ipw2100.c  |   9 +-
 drivers/net/wireless/intel/ipw2x00/ipw2200.c  |   8 +-
 .../net/wireless/intel/iwlegacy/3945-mac.c    |   9 +-
 .../net/wireless/intel/iwlegacy/4965-mac.c    |   9 +-
 .../net/wireless/intersil/hostap/hostap_ap.c  |   2 +-
 .../net/wireless/intersil/hostap/hostap_pci.c |   3 +-
 .../net/wireless/intersil/hostap/hostap_plx.c |   3 +-
 drivers/net/wireless/intersil/orinoco/main.c  |   4 +-
 .../intersil/orinoco/orinoco_nortel.c         |   4 +-
 .../wireless/intersil/orinoco/orinoco_pci.c   |   4 +-
 .../wireless/intersil/orinoco/orinoco_plx.c   |   4 +-
 .../wireless/intersil/orinoco/orinoco_tmd.c   |   4 +-
 drivers/net/wireless/intersil/p54/p54pci.c    |   2 +-
 drivers/net/wireless/intersil/p54/p54spi.c    |   4 +-
 .../intersil/prism54/islpci_hotplug.c         |   2 +-
 drivers/net/wireless/mac80211_hwsim.c         |   6 +-
 drivers/net/wireless/marvell/libertas/if_cs.c |   2 +-
 .../net/wireless/marvell/libertas/if_spi.c    |   3 +-
 .../wireless/marvell/mwifiex/11n_rxreorder.c  |   3 +-
 drivers/net/wireless/marvell/mwifiex/main.c   |   5 +-
 drivers/net/wireless/marvell/mwifiex/pcie.c   |   8 +-
 drivers/net/wireless/marvell/mwifiex/usb.c    |   2 +-
 drivers/net/wireless/marvell/mwl8k.c          |  10 +-
 .../net/wireless/mediatek/mt76/mt76x0/pci.c   |   3 +-
 .../net/wireless/mediatek/mt76/mt76x2/pci.c   |   3 +-
 .../quantenna/qtnfmac/pcie/pearl_pcie.c       |   3 +-
 .../quantenna/qtnfmac/pcie/topaz_pcie.c       |   3 +-
 .../net/wireless/ralink/rt2x00/rt2x00mmio.c   |   6 +-
 .../wireless/realtek/rtl818x/rtl8180/dev.c    |   6 +-
 drivers/net/wireless/realtek/rtlwifi/pci.c    |  16 +-
 drivers/net/wireless/ti/wl1251/sdio.c         |   4 +-
 drivers/net/wireless/ti/wl1251/spi.c          |   5 +-
 drivers/ntb/hw/amd/ntb_hw_amd.c               |  12 +-
 drivers/ntb/hw/intel/ntb_hw_gen1.c            |  12 +-
 drivers/ntb/hw/mscc/ntb_hw_switchtec.c        |   8 +-
 drivers/parport/parport_ax88796.c             |   3 +-
 drivers/parport/parport_pc.c                  |   3 +-
 drivers/pci/controller/pcie-xilinx.c          |   2 +-
 drivers/pci/controller/vmd.c                  |  11 +-
 drivers/pci/hotplug/cpci_hotplug_core.c       |   6 +-
 drivers/pci/hotplug/cpqphp_core.c             |   3 +-
 drivers/pci/hotplug/shpchp_hpc.c              |   5 +-
 drivers/pci/pcie/pme.c                        |   3 +-
 drivers/pci/switch/switchtec.c                |  10 +-
 drivers/pcmcia/i82092.c                       |   2 +-
 drivers/pcmcia/i82365.c                       |   9 +-
 drivers/pcmcia/pcmcia_resource.c              |   9 +-
 drivers/pcmcia/pd6729.c                       |   8 +-
 drivers/pcmcia/tcic.c                         |   7 +-
 drivers/pcmcia/yenta_socket.c                 |   7 +-
 drivers/pinctrl/intel/pinctrl-intel.c         |   2 +-
 drivers/pinctrl/pinctrl-amd.c                 |   3 +-
 drivers/pinctrl/pinctrl-single.c              |   3 +-
 drivers/platform/goldfish/goldfish_pipe.c     |   6 +-
 drivers/platform/mellanox/mlxreg-hotplug.c    |   5 +-
 drivers/platform/x86/fujitsu-tablet.c         |   3 +-
 drivers/platform/x86/intel_int0002_vgpio.c    |   2 +-
 drivers/platform/x86/intel_ips.c              |   3 +-
 drivers/platform/x86/intel_pmc_ipc.c          |   8 +-
 drivers/platform/x86/intel_punit_ipc.c        |   4 +-
 drivers/platform/x86/intel_scu_ipc.c          |   5 +-
 drivers/platform/x86/sony-laptop.c            |   5 +-
 drivers/pnp/resource.c                        |   3 +-
 drivers/power/reset/ltc2952-poweroff.c        |   6 +-
 drivers/power/supply/act8945a_charger.c       |   6 +-
 drivers/power/supply/goldfish_battery.c       |   5 +-
 .../power/supply/max14656_charger_detector.c  |   2 +-
 drivers/power/supply/pda_power.c              |   6 +-
 drivers/power/supply/wm97xx_battery.c         |   5 +-
 drivers/pps/clients/pps-gpio.c                |   3 +-
 drivers/ptp/ptp_pch.c                         |   3 +-
 drivers/rapidio/devices/tsi721.c              |  25 +-
 drivers/rapidio/devices/tsi721_dma.c          |   8 +-
 drivers/regulator/qcom_spmi-regulator.c       |   5 +-
 drivers/rpmsg/qcom_glink_native.c             |   5 +-
 drivers/rtc/rtc-cmos.c                        |   5 +-
 drivers/rtc/rtc-ds1305.c                      |   3 +-
 drivers/rtc/rtc-ds1374.c                      |   5 +-
 drivers/rtc/rtc-ds1511.c                      |   3 +-
 drivers/rtc/rtc-ds1553.c                      |   4 +-
 drivers/rtc/rtc-ds1685.c                      |   3 +-
 drivers/rtc/rtc-ftrtc010.c                    |   2 +-
 drivers/rtc/rtc-m48t59.c                      |   5 +-
 drivers/rtc/rtc-mrst.c                        |   3 +-
 drivers/rtc/rtc-pcap.c                        |  10 +-
 drivers/rtc/rtc-r7301.c                       |   3 +-
 drivers/rtc/rtc-snvs.c                        |   3 +-
 drivers/rtc/rtc-stk17ta8.c                    |   5 +-
 drivers/rtc/rtc-zynqmp.c                      |   6 +-
 drivers/scsi/3w-9xxx.c                        |   6 +-
 drivers/scsi/3w-sas.c                         |   6 +-
 drivers/scsi/3w-xxxx.c                        |   3 +-
 drivers/scsi/BusLogic.c                       |   3 +-
 drivers/scsi/a100u2w.c                        |   4 +-
 drivers/scsi/aacraid/commsup.c                |   8 +-
 drivers/scsi/aacraid/rx.c                     |   3 +-
 drivers/scsi/aacraid/sa.c                     |   3 +-
 drivers/scsi/aacraid/src.c                    |   3 +-
 drivers/scsi/advansys.c                       |   4 +-
 drivers/scsi/aha152x.c                        |   4 +-
 drivers/scsi/aha1542.c                        |   2 +-
 drivers/scsi/aha1740.c                        |   3 +-
 drivers/scsi/aic7xxx/aic7770_osm.c            |   3 +-
 drivers/scsi/aic7xxx/aic79xx_osm_pci.c        |   2 +-
 drivers/scsi/aic7xxx/aic7xxx_osm_pci.c        |   2 +-
 drivers/scsi/aic94xx/aic94xx_hwi.c            |   4 +-
 drivers/scsi/aic94xx/aic94xx_init.c           |   5 +-
 drivers/scsi/am53c974.c                       |   4 +-
 drivers/scsi/arcmsr/arcmsr_hba.c              |   3 +-
 drivers/scsi/atp870u.c                        |   3 +-
 drivers/scsi/be2iscsi/be_main.c               |  12 +-
 drivers/scsi/bfa/bfad.c                       |   9 +-
 drivers/scsi/csiostor/csio_isr.c              |  16 +-
 drivers/scsi/dpt_i2o.c                        |   2 +-
 drivers/scsi/esas2r/esas2r_init.c             |   8 +-
 drivers/scsi/fnic/fnic_isr.c                  |  13 +-
 drivers/scsi/g_NCR5380.c                      |   7 +-
 drivers/scsi/gdth.c                           |   8 +-
 drivers/scsi/hpsa.c                           |  19 +-
 drivers/scsi/hptiop.c                         |   3 +-
 drivers/scsi/initio.c                         |   3 +-
 drivers/scsi/ipr.c                            |  23 +-
 drivers/scsi/ips.c                            |   4 +-
 drivers/scsi/isci/init.c                      |   8 +-
 drivers/scsi/lpfc/lpfc_init.c                 |  35 ++-
 drivers/scsi/megaraid.c                       |   4 +-
 drivers/scsi/megaraid/megaraid_mbox.c         |   3 +-
 drivers/scsi/megaraid/megaraid_sas_base.c     |   8 +-
 drivers/scsi/mpt3sas/mpt3sas_base.c           |   2 +-
 drivers/scsi/mvsas/mv_init.c                  |   4 +-
 drivers/scsi/mvumi.c                          |   8 +-
 drivers/scsi/myrb.c                           |   2 +-
 drivers/scsi/myrs.c                           |   2 +-
 drivers/scsi/nsp32.c                          |   3 +-
 drivers/scsi/pcmcia/qlogic_stub.c             |   2 +-
 drivers/scsi/pcmcia/sym53c500_cs.c            |   2 +-
 drivers/scsi/pm8001/pm8001_init.c             |  10 +-
 drivers/scsi/pmcraid.c                        |   5 +-
 drivers/scsi/qedf/qedf_main.c                 |   4 +-
 drivers/scsi/qedi/qedi_main.c                 |   3 +-
 drivers/scsi/qla1280.c                        |   3 +-
 drivers/scsi/qla2xxx/qla_isr.c                |  22 +-
 drivers/scsi/qla4xxx/ql4_isr.c                |   5 +-
 drivers/scsi/qla4xxx/ql4_nx.c                 |  10 +-
 drivers/scsi/qlogicfas.c                      |   2 +-
 drivers/scsi/sim710.c                         |   2 +-
 drivers/scsi/smartpqi/smartpqi_init.c         |  11 +-
 drivers/scsi/snic/snic_isr.c                  |   5 +-
 drivers/scsi/stex.c                           |   4 +-
 drivers/scsi/sym53c8xx_2/sym_glue.c           |   3 +-
 drivers/scsi/ufs/ufshcd.c                     |   7 +-
 drivers/scsi/vmw_pvscsi.c                     |   9 +-
 drivers/scsi/wd719x.c                         |   4 +-
 drivers/slimbus/qcom-ctrl.c                   |   3 +-
 drivers/spi/spi-altera.c                      |   3 +-
 drivers/spi/spi-axi-spi-engine.c              |   3 +-
 drivers/spi/spi-cadence.c                     |   3 +-
 drivers/spi/spi-dw.c                          |   4 +-
 drivers/spi/spi-fsl-spi.c                     |   3 +-
 drivers/spi/spi-oc-tiny.c                     |   3 +-
 drivers/spi/spi-pxa2xx.c                      |   4 +-
 drivers/spi/spi-topcliff-pch.c                |   5 +-
 drivers/spi/spi-xilinx.c                      |   5 +-
 drivers/spi/spi-zynqmp-gqspi.c                |   3 +-
 drivers/staging/android/vsoc.c                |   3 +-
 drivers/staging/axis-fifo/axis-fifo.c         |   3 +-
 drivers/staging/comedi/comedi_buf.c           |   5 +
 .../staging/comedi/drivers/addi_apci_1032.c   |   3 +-
 .../staging/comedi/drivers/addi_apci_1500.c   |   3 +-
 .../staging/comedi/drivers/addi_apci_1564.c   |   3 +-
 .../staging/comedi/drivers/addi_apci_2032.c   |   3 +-
 .../staging/comedi/drivers/addi_apci_3120.c   |   3 +-
 .../staging/comedi/drivers/addi_apci_3xxx.c   |   3 +-
 drivers/staging/comedi/drivers/adl_pci9111.c  |   3 +-
 drivers/staging/comedi/drivers/adl_pci9118.c  |   3 +-
 drivers/staging/comedi/drivers/adv_pci1710.c  |   3 +-
 drivers/staging/comedi/drivers/aio_iiro_16.c  |   3 +-
 .../comedi/drivers/amplc_dio200_common.c      |   3 +-
 .../comedi/drivers/amplc_pc236_common.c       |   3 +-
 drivers/staging/comedi/drivers/amplc_pci224.c |   3 +-
 drivers/staging/comedi/drivers/amplc_pci230.c |   3 +-
 drivers/staging/comedi/drivers/cb_pcidas.c    |   4 +-
 drivers/staging/comedi/drivers/cb_pcidas64.c  |   5 +-
 .../staging/comedi/drivers/comedi_parport.c   |   3 +-
 drivers/staging/comedi/drivers/comedi_test.c  |   6 +-
 drivers/staging/comedi/drivers/das16m1.c      |   3 +-
 drivers/staging/comedi/drivers/das1800.c      |   3 +-
 drivers/staging/comedi/drivers/das6402.c      |   3 +-
 drivers/staging/comedi/drivers/das800.c       |   5 +-
 drivers/staging/comedi/drivers/dmm32at.c      |   3 +-
 drivers/staging/comedi/drivers/dt2811.c       |   3 +-
 drivers/staging/comedi/drivers/dt2814.c       |   3 +-
 drivers/staging/comedi/drivers/dt282x.c       |   2 +-
 drivers/staging/comedi/drivers/dt3000.c       |   3 +-
 drivers/staging/comedi/drivers/gsc_hpdi.c     |   3 +-
 drivers/staging/comedi/drivers/jr3_pci.c      |   2 +-
 drivers/staging/comedi/drivers/me4000.c       |   3 +-
 drivers/staging/comedi/drivers/ni_6527.c      |   4 +-
 drivers/staging/comedi/drivers/ni_65xx.c      |   3 +-
 drivers/staging/comedi/drivers/ni_660x.c      |   4 +-
 drivers/staging/comedi/drivers/ni_at_a2150.c  |   2 +-
 drivers/staging/comedi/drivers/ni_atmio.c     |   3 +-
 drivers/staging/comedi/drivers/ni_atmio16d.c  |   3 +-
 .../staging/comedi/drivers/ni_labpc_common.c  |   5 +-
 drivers/staging/comedi/drivers/ni_pcidio.c    |   3 +-
 drivers/staging/comedi/drivers/ni_pcimio.c    |   3 +-
 drivers/staging/comedi/drivers/pcl711.c       |   3 +-
 drivers/staging/comedi/drivers/pcl726.c       |   3 +-
 drivers/staging/comedi/drivers/pcl812.c       |   3 +-
 drivers/staging/comedi/drivers/pcl816.c       |   2 +-
 drivers/staging/comedi/drivers/pcl818.c       |   3 +-
 drivers/staging/comedi/drivers/pcmmio.c       |   3 +-
 drivers/staging/comedi/drivers/pcmuio.c       |   6 +-
 drivers/staging/comedi/drivers/rtd520.c       |   3 +-
 drivers/staging/comedi/drivers/s626.c         |   3 +-
 drivers/staging/gasket/gasket_interrupt.c     |   3 +-
 drivers/staging/goldfish/goldfish_audio.c     |   5 +-
 drivers/staging/iio/adc/ad7606.c              |   3 +-
 drivers/staging/ks7010/ks_hostif.c            |   3 +-
 drivers/staging/media/bcm2048/radio-bcm2048.c |   4 +-
 drivers/staging/media/zoran/zoran_card.c      |   2 +-
 drivers/staging/most/dim2/dim2.c              |   6 +-
 drivers/staging/most/i2c/i2c.c                |   3 +-
 drivers/staging/olpc_dcon/olpc_dcon_xo_1.c    |   2 +-
 drivers/staging/olpc_dcon/olpc_dcon_xo_1_5.c  |   2 +-
 drivers/staging/pi433/pi433_if.c              |   6 +-
 drivers/staging/rtl8188eu/core/rtw_recv.c     |   2 +-
 .../staging/rtl8188eu/hal/rtl8188eu_recv.c    |   6 +-
 .../staging/rtl8188eu/hal/rtl8188eu_xmit.c    |   6 +-
 drivers/staging/rtl8188eu/os_dep/mlme_linux.c |  17 +-
 drivers/staging/rtl8188eu/os_dep/recv_linux.c |   2 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_core.c  |  20 +-
 drivers/staging/rtl8192e/rtllib_softmac.c     |   6 +-
 .../rtl8192u/ieee80211/ieee80211_module.c     |   2 +-
 .../rtl8192u/ieee80211/ieee80211_softmac.c    |   6 +-
 drivers/staging/rtl8712/rtl8712_recv.c        |   6 +-
 drivers/staging/rtl8712/rtl871x_xmit.c        |   6 +-
 .../staging/rtl8723bs/hal/rtl8723bs_recv.c    |   8 +-
 drivers/staging/rtl8723bs/os_dep/mlme_linux.c |  22 +-
 drivers/staging/rtl8723bs/os_dep/recv_linux.c |   2 +-
 drivers/staging/rtlwifi/pci.c                 |   4 +-
 drivers/staging/rts5208/rtsx.c                |   4 +-
 drivers/staging/speakup/main.c                |   2 +-
 drivers/staging/speakup/serialio.c            |   5 +-
 drivers/staging/vt6655/device_main.c          |   2 +-
 drivers/thermal/ti-soc-thermal/ti-bandgap.c   |   6 +-
 drivers/thunderbolt/nhi.c                     |   6 +-
 drivers/tty/cyclades.c                        |   9 +-
 drivers/tty/goldfish.c                        |   4 +-
 drivers/tty/hvc/hvc_irq.c                     |   4 +-
 drivers/tty/ipwireless/hardware.c             |   3 +-
 drivers/tty/isicom.c                          |   4 +-
 drivers/tty/moxa.c                            |   2 +-
 drivers/tty/mxser.c                           |   4 +-
 drivers/tty/n_gsm.c                           |   5 +-
 drivers/tty/n_r3964.c                         |   2 +-
 drivers/tty/rocket.c                          |   2 +-
 drivers/tty/serial/8250/8250_core.c           |   6 +-
 drivers/tty/serial/8250/8250_exar.c           |   2 +-
 drivers/tty/serial/8250/8250_port.c           |   4 +-
 drivers/tty/serial/altera_jtaguart.c          |   4 +-
 drivers/tty/serial/altera_uart.c              |   5 +-
 drivers/tty/serial/arc_uart.c                 |   2 +-
 drivers/tty/serial/digicolor-usart.c          |   3 +-
 drivers/tty/serial/fsl_lpuart.c               |  12 +-
 drivers/tty/serial/ifx6x60.c                  |  11 +-
 drivers/tty/serial/jsm/jsm_driver.c           |   3 +-
 drivers/tty/serial/max3100.c                  |   5 +-
 drivers/tty/serial/men_z135_uart.c            |   4 +-
 drivers/tty/serial/mux.c                      |   2 +-
 drivers/tty/serial/pch_uart.c                 |   4 +-
 drivers/tty/serial/pnx8xxx_uart.c             |   3 +-
 drivers/tty/serial/rp2.c                      |   2 +-
 drivers/tty/serial/sc16is7xx.c                |   2 +-
 drivers/tty/serial/sccnxp.c                   |   2 +-
 drivers/tty/serial/sh-sci.c                   |   9 +-
 drivers/tty/serial/timbuart.c                 |   4 +-
 drivers/tty/serial/uartlite.c                 |   3 +-
 drivers/tty/serial/xilinx_uartps.c            |   4 +-
 drivers/tty/synclink.c                        |   3 +-
 drivers/tty/synclink_gt.c                     |   6 +-
 drivers/tty/synclinkmp.c                      |   7 +-
 drivers/tty/tty_buffer.c                      |   5 +-
 drivers/tty/vcc.c                             |   4 +-
 drivers/tty/vt/keyboard.c                     |   2 +-
 drivers/uio/uio.c                             |   3 +-
 drivers/usb/atm/usbatm.c                      |   6 +-
 drivers/usb/c67x00/c67x00-drv.c               |   3 +-
 drivers/usb/chipidea/core.c                   |   5 +-
 drivers/usb/chipidea/otg_fsm.c                |   3 +-
 drivers/usb/core/hcd.c                        |   8 +-
 drivers/usb/dwc2/gadget.c                     |   3 +-
 drivers/usb/dwc2/hcd_queue.c                  |   6 +-
 drivers/usb/dwc2/platform.c                   |   3 +-
 drivers/usb/gadget/function/f_midi.c          |   3 +-
 drivers/usb/gadget/function/f_ncm.c           |   3 +-
 drivers/usb/gadget/udc/amd5536udc_pci.c       |   2 +-
 drivers/usb/gadget/udc/bdc/bdc_udc.c          |   3 +-
 drivers/usb/gadget/udc/dummy_hcd.c            |   4 +-
 drivers/usb/gadget/udc/fotg210-udc.c          |   4 +-
 drivers/usb/gadget/udc/fusb300_udc.c          |   6 +-
 drivers/usb/gadget/udc/goku_udc.c             |   3 +-
 drivers/usb/gadget/udc/m66592-udc.c           |   6 +-
 drivers/usb/gadget/udc/mv_u3d_core.c          |   3 +-
 drivers/usb/gadget/udc/mv_udc_core.c          |   3 +-
 drivers/usb/gadget/udc/net2272.c              |   3 +-
 drivers/usb/gadget/udc/net2280.c              |   3 +-
 drivers/usb/gadget/udc/pch_udc.c              |   8 +-
 drivers/usb/gadget/udc/pxa27x_udc.c           |   3 +-
 drivers/usb/gadget/udc/r8a66597-udc.c         |   7 +-
 drivers/usb/gadget/udc/snps_udc_plat.c        |   4 +-
 drivers/usb/gadget/udc/udc-xilinx.c           |   3 +-
 drivers/usb/host/max3421-hcd.c                |   3 +-
 drivers/usb/host/xhci.c                       |  12 +-
 drivers/usb/isp1760/isp1760-udc.c             |   3 +-
 drivers/usb/musb/musb_core.c                  |   2 +-
 drivers/usb/phy/phy-gpio-vbus-usb.c           |   4 +-
 drivers/usb/serial/mos7720.c                  |   4 +-
 drivers/usb/usbip/vudc_transfer.c             |   2 +-
 drivers/uwb/neh.c                             |   2 +-
 drivers/uwb/rsv.c                             |   5 +-
 drivers/uwb/whc-rc.c                          |   5 +-
 drivers/vfio/pci/vfio_pci_intrs.c             |   5 +-
 drivers/video/fbdev/arcfb.c                   |   3 +-
 drivers/video/fbdev/aty/atyfb_base.c          |   2 +-
 drivers/video/fbdev/goldfishfb.c              |   4 +-
 drivers/video/fbdev/matrox/matroxfb_base.c    |   3 +-
 drivers/video/fbdev/mb862xx/mb862xxfbdrv.c    |   7 +-
 drivers/video/fbdev/via/via-core.c            |   3 +-
 drivers/video/fbdev/xen-fbfront.c             |   2 +
 drivers/virt/vboxguest/vboxguest_linux.c      |   5 +-
 drivers/virtio/virtio_mmio.c                  |   4 +-
 drivers/virtio/virtio_pci_common.c            |  20 +-
 drivers/visorbus/visorbus_main.c              |   2 +-
 drivers/vme/bridges/vme_ca91cx42.c            |   5 +-
 drivers/vme/bridges/vme_tsi148.c              |   7 +-
 drivers/w1/masters/ds1wm.c                    |   3 +-
 drivers/xen/events/events_base.c              |  12 +-
 drivers/xen/platform-pci.c                    |   4 +-
 drivers/xen/pvcalls-front.c                   |   2 +
 drivers/xen/xen-pciback/pciback_ops.c         |   6 +-
 include/asm-generic/io.h                      |   3 +
 include/linux/clearcpu.h                      |  36 +++
 include/linux/filter.h                        |  21 +-
 include/linux/highmem.h                       |   2 +
 include/linux/hrtimer.h                       |   4 +
 include/linux/interrupt.h                     |  18 +-
 include/linux/skbuff.h                        |   2 +
 include/linux/timer.h                         |  14 +-
 include/linux/tty_flip.h                      |   4 +
 include/linux/usb/hcd.h                       |   5 +-
 kernel/bpf/core.c                             |   2 +
 kernel/bpf/cpumap.c                           |   3 +
 kernel/dma/swiotlb.c                          |   2 +
 kernel/irq/handle.c                           |   4 +
 kernel/irq/manage.c                           |   1 +
 kernel/sched/core.c                           |   9 +
 kernel/softirq.c                              |  25 +-
 kernel/time/alarmtimer.c                      |   2 +-
 kernel/time/hrtimer.c                         |   5 +
 kernel/time/timer.c                           |   8 +
 lib/random32.c                                |   2 +-
 lib/scatterlist.c                             |   2 +
 lib/string.c                                  |   6 +
 mm/slab_common.c                              |   5 +-
 net/atm/pppoatm.c                             |   2 +-
 net/core/skbuff.c                             |  32 +++
 net/mac80211/main.c                           |  14 +-
 net/rds/ib_cm.c                               |   8 +-
 net/wireless/lib80211.c                       |   2 +-
 net/xfrm/xfrm_state.c                         |   3 +-
 samples/v4l/v4l2-pci-skeleton.c               |   5 +-
 security/keys/gc.c                            |   2 +-
 sound/core/hrtimer.c                          |   3 +-
 sound/core/pcm_lib.c                          |   3 +
 sound/core/rawmidi.c                          |   3 +
 sound/core/timer.c                            |   7 +-
 sound/drivers/mpu401/mpu401_uart.c            |   8 +-
 sound/drivers/mtpav.c                         |   5 +-
 sound/drivers/pcsp/pcsp.c                     |   3 +-
 sound/drivers/serial-u16550.c                 |   6 +-
 sound/isa/ad1816a/ad1816a_lib.c               |   2 +-
 sound/isa/es1688/es1688_lib.c                 |   4 +-
 sound/isa/es18xx.c                            |   3 +-
 sound/isa/gus/gus_main.c                      |   2 +-
 sound/isa/gus/gusmax.c                        |   2 +-
 sound/isa/gus/interwave.c                     |   3 +-
 sound/isa/msnd/msnd_pinnacle.c                |   3 +-
 sound/isa/opl3sa2.c                           |   4 +-
 sound/isa/opti9xx/opti92x-ad1848.c            |   3 +-
 sound/isa/sb/emu8000_pcm.c                    |   2 +-
 sound/isa/sb/sb8_midi.c                       |   3 +-
 sound/isa/sb/sb_common.c                      |   6 +-
 sound/isa/wavefront/wavefront.c               |   3 +-
 sound/isa/wavefront/wavefront_midi.c          |   4 +-
 sound/isa/wss/wss_lib.c                       |   3 +-
 sound/pci/ad1889.c                            |   3 +-
 sound/pci/ali5451/ali5451.c                   |   3 +-
 sound/pci/als300.c                            |   3 +-
 sound/pci/asihpi/asihpi.c                     |   4 +-
 sound/pci/asihpi/hpioctl.c                    |   3 +-
 sound/pci/atiixp.c                            |   3 +-
 sound/pci/atiixp_modem.c                      |   3 +-
 sound/pci/aw2/aw2-alsa.c                      |   3 +-
 sound/pci/azt3328.c                           |   3 +-
 sound/pci/bt87x.c                             |   4 +-
 sound/pci/ca0106/ca0106_main.c                |   3 +-
 sound/pci/cmipci.c                            |   3 +-
 sound/pci/cs4281.c                            |   3 +-
 sound/pci/cs46xx/cs46xx_lib.c                 |   3 +-
 sound/pci/cs5535audio/cs5535audio.c           |   3 +-
 sound/pci/ctxfi/cthw20k1.c                    |   3 +-
 sound/pci/ctxfi/cthw20k2.c                    |   3 +-
 sound/pci/echoaudio/midi.c                    |   2 +-
 sound/pci/emu10k1/emu10k1_main.c              |   3 +-
 sound/pci/emu10k1/emu10k1x.c                  |   3 +-
 sound/pci/ens1370.c                           |   3 +-
 sound/pci/es1938.c                            |   6 +-
 sound/pci/es1968.c                            |   3 +-
 sound/pci/fm801.c                             |   3 +-
 sound/pci/hda/hda_intel.c                     |   4 +-
 sound/pci/ice1712/ice1712.c                   |   3 +-
 sound/pci/ice1712/ice1724.c                   |   3 +-
 sound/pci/intel8x0.c                          |   6 +-
 sound/pci/intel8x0m.c                         |   6 +-
 sound/pci/korg1212/korg1212.c                 |   4 +-
 sound/pci/lola/lola.c                         |   3 +-
 sound/pci/maestro3.c                          |   3 +-
 sound/pci/nm256/nm256.c                       |   3 +-
 sound/pci/oxygen/oxygen_lib.c                 |   4 +-
 sound/pci/riptide/riptide.c                   |   3 +-
 sound/pci/rme32.c                             |   3 +-
 sound/pci/rme96.c                             |   3 +-
 sound/pci/rme9652/hdsp.c                      |   8 +-
 sound/pci/rme9652/hdspm.c                     |  10 +-
 sound/pci/rme9652/rme9652.c                   |   3 +-
 sound/pci/sis7019.c                           |   7 +-
 sound/pci/sonicvibes.c                        |   3 +-
 sound/pci/trident/trident_main.c              |   3 +-
 sound/pci/via82xx.c                           |   6 +-
 sound/pci/via82xx_modem.c                     |   3 +-
 sound/pci/ymfpci/ymfpci_main.c                |   3 +-
 sound/soc/amd/acp-pcm-dma.c                   |   3 +-
 sound/soc/amd/raven/acp3x-pcm-dma.c           |   3 +-
 sound/soc/codecs/rt5640.c                     |   4 +-
 sound/soc/codecs/rt5651.c                     |   4 +-
 sound/soc/codecs/rt5663.c                     |   4 +-
 sound/soc/dwc/dwc-i2s.c                       |   5 +-
 sound/soc/fsl/fsl_asrc.c                      |   3 +-
 sound/soc/fsl/fsl_esai.c                      |   3 +-
 sound/soc/fsl/fsl_sai.c                       |   3 +-
 sound/soc/fsl/fsl_spdif.c                     |   3 +-
 sound/soc/fsl/fsl_ssi.c                       |   3 +-
 sound/usb/midi.c                              |   6 +-
 sound/usb/misc/ua101.c                        |   4 +-
 sound/x86/intel_hdmi_audio.c                  |   5 +-
 681 files changed, 2457 insertions(+), 1308 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] 89+ messages in thread
* [patch V4 00/11] MDS basics
@ 2019-02-22 22:24 Thomas Gleixner
  2019-02-22 22:24 ` [patch V4 04/11] x86/speculation/mds: Add mds_clear_cpu_buffer() Thomas Gleixner
  0 siblings, 1 reply; 89+ messages in thread
From: Thomas Gleixner @ 2019-02-22 22:24 UTC (permalink / raw)
  To: speck

Hi!

Another day, another update.

Changes since V3:

  - Add the #DF mitigation and document why I can't be bothered
    to sprinkle the buffer clear into #MC

  - Add a comment about the segment selector choice. It makes sense on it's
    own but it won't prevent anyone from thinking that we're crazy.

  - Addressed the review feedback vs. documentation

  - Resurrected the admin documentation patch, tidied it up and filled the
    gaps.

Delta patch without the admin documentation parts below.

Git tree WIP.mds branch is updated as well.

If anyone of the people new to this need access to the git repo,
please send me a public SSH key so I can add to the gitolite config.

There is one point left which I did not look into yet and I'm happy to
delegate that to the virtualization wizards:

  XEON PHI is not affected by L1TF, so it won't get the L1TF
  mitigations. But it is affected by MSBDS, so it needs separate
  mitigation, i.e. clearing CPU buffers on VMENTER.


Thanks,

	Thomas

8<-------------------

 Documentation/ABI/testing/sysfs-devices-system-cpu |    1 
 Documentation/admin-guide/hw-vuln/index.rst        |   13 +
 Documentation/admin-guide/hw-vuln/l1tf.rst         |    1 
 Documentation/admin-guide/hw-vuln/mds.rst          |  258 +++++++++++++++++++++
 Documentation/admin-guide/index.rst                |    6 
 Documentation/admin-guide/kernel-parameters.txt    |   27 ++
 Documentation/index.rst                            |    1 
 Documentation/x86/conf.py                          |   10 
 Documentation/x86/index.rst                        |    8 
 Documentation/x86/mds.rst                          |  205 ++++++++++++++++
 arch/x86/entry/common.c                            |   10 
 arch/x86/include/asm/cpufeatures.h                 |    2 
 arch/x86/include/asm/irqflags.h                    |    4 
 arch/x86/include/asm/msr-index.h                   |   39 +--
 arch/x86/include/asm/mwait.h                       |    7 
 arch/x86/include/asm/nospec-branch.h               |   39 +++
 arch/x86/include/asm/processor.h                   |    7 
 arch/x86/kernel/cpu/bugs.c                         |  105 ++++++++
 arch/x86/kernel/cpu/common.c                       |   13 +
 arch/x86/kernel/nmi.c                              |    6 
 arch/x86/kernel/traps.c                            |    9 
 arch/x86/kvm/cpuid.c                               |    3 
 drivers/base/cpu.c                                 |    8 
 include/linux/cpu.h                                |    2 
 24 files changed, 762 insertions(+), 22 deletions(-)

diff --git a/Documentation/x86/mds.rst b/Documentation/x86/mds.rst
index 0c0d802367e6..ce3dbddbd3b8 100644
--- a/Documentation/x86/mds.rst
+++ b/Documentation/x86/mds.rst
@@ -1,7 +1,12 @@
 Microarchitecural Data Sampling (MDS) mitigation
 ================================================
 
-Microarchitectural Data Sampling (MDS) is a class of side channel attacks
+.. _mds:
+
+Overview
+--------
+
+Microarchitectural Data Sampling (MDS) is a family of side channel attacks
 on internal buffers in Intel CPUs. The variants are:
 
  - Microarchitectural Store Buffer Data Sampling (MSBDS) (CVE-2018-12126)
@@ -33,6 +38,7 @@ faulting or assisting loads under certain conditions, which again can be
 exploited eventually. Load ports are shared between Hyper-Threads so cross
 thread leakage is possible.
 
+
 Exposure assumptions
 --------------------
 
@@ -48,7 +54,7 @@ needed for exploiting MDS requires:
  - to control the pointer through which the disclosure gadget exposes the
    data
 
-The existance of such a construct cannot be excluded with 100% certainty,
+The existence of such a construct cannot be excluded with 100% certainty,
 but the complexity involved makes it extremly unlikely.
 
 There is one exception, which is untrusted BPF. The functionality of
@@ -91,13 +97,37 @@ the invocation can be enforced or conditional.
 As a special quirk to address virtualization scenarios where the host has
 the microcode updated, but the hypervisor does not (yet) expose the
 MD_CLEAR CPUID bit to guests, the kernel issues the VERW instruction in the
-hope that it might work. The state is reflected accordingly.
+hope that it might actually clear the buffers. The state is reflected
+accordingly.
 
 According to current knowledge additional mitigations inside the kernel
 itself are not required because the necessary gadgets to expose the leaked
 data cannot be controlled in a way which allows exploitation from malicious
 user space or VM guests.
 
+
+Kernel internal mitigation modes
+--------------------------------
+
+ ======= ===========================================================
+ off     Mitigation is disabled. Either the CPU is not affected or
+         mds=off is supplied on the kernel command line
+
+ full    Mitigation is eanbled. CPU is affected and MD_CLEAR is
+         advertised in CPUID.
+
+ vmwerv	 Mitigation is enabled. CPU is affected and MD_CLEAR is not
+         advertised in CPUID. That is mainly for virtualization
+	 scenarios where the host has the updated microcode but the
+	 hypervisor does not expose MD_CLEAR in CPUID. It's a best
+	 effort approach without guarantee.
+ ======= ===========================================================
+
+If the CPU is affected and mds=off is not supplied on the kernel
+command line then the kernel selects the appropriate mitigation mode
+depending on the availability of the MD_CLEAR CPUID bit.
+
+
 Mitigation points
 -----------------
 
@@ -128,8 +158,16 @@ Mitigation points
    coverage.
 
    There is one non maskable exception which returns through paranoid exit
-   and is not mitigated: #DF. If user space is able to trigger a double
-   fault the possible MDS leakage is the least problem to worry about.
+   and is to some extent controllable from user space through
+   modify_ldt(2): #DF. So mitigation is required in the double fault
+   handler as well.
+
+   Another corner case is a #MC which hits between the buffer clear and the
+   actual return to user. As this still is in kernel space it takes the
+   paranoid exit path which does not clear the CPU buffers. So the #MC
+   handler repopulates the buffers to some extent. Machine checks are not
+   reliably controllable and the window is extremly small so mitigation
+   would just tick a checkbox that this theoretical corner case is covered.
 
 
 2. C-State transition
diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h
index 8be9158d848e..3e27ccd6d5c5 100644
--- a/arch/x86/include/asm/nospec-branch.h
+++ b/arch/x86/include/asm/nospec-branch.h
@@ -338,6 +338,8 @@ static inline void mds_clear_cpu_buffers(void)
 	 * Has to be the memory-operand variant because only that
 	 * guarantees the CPU buffer flush functionality according to
 	 * documentation. The register-operand variant does not.
+	 * Works with any segment selector, but a valid writable
+	 * data segment is the fastest variant.
 	 *
 	 * "cc" clobber is required because VERW modifies ZF.
 	 */
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 0fb241a78de3..83b19bb54093 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -68,6 +68,7 @@ DEFINE_STATIC_KEY_FALSE(switch_mm_always_ibpb);
 DEFINE_STATIC_KEY_FALSE(mds_user_clear);
 /* Control MDS CPU buffer clear before idling (halt, mwait) */
 DEFINE_STATIC_KEY_FALSE(mds_idle_clear);
+EXPORT_SYMBOL_GPL(mds_idle_clear);
 
 void __init check_bugs(void)
 {
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index 9b7c4ca8f0a7..d2779f4730f5 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -366,6 +366,15 @@ dotraplinkage void do_double_fault(struct pt_regs *regs, long error_code)
 		regs->ip = (unsigned long)general_protection;
 		regs->sp = (unsigned long)&gpregs->orig_ax;
 
+		/*
+		 * This situation can be triggered by userspace via
+		 * modify_ldt(2) and the return does not take the regular
+		 * user space exit, so a CPU buffer clear is required when
+		 * MDS mitigation is enabled.
+		 */
+		if (static_branch_unlikely(&mds_user_clear))
+			mds_clear_cpu_buffers();
+
 		return;
 	}
 #endif

^ permalink raw reply related	[flat|nested] 89+ messages in thread
* [patch V3 0/9] MDS basics 0
@ 2019-02-21 23:44 Thomas Gleixner
  2019-02-21 23:44 ` [patch V3 4/9] MDS basics 4 Thomas Gleixner
  0 siblings, 1 reply; 89+ messages in thread
From: Thomas Gleixner @ 2019-02-21 23:44 UTC (permalink / raw)
  To: speck

Hi!

Thanks for the valuable feedback to everyone!

Changes since V2:

 - Added the NMI mitigation and added an explanation. Thanks Andi and
   Kees.

 - Fixed the VERW asm magic as pointed out by Andrew and added
   more explanation as requested by Borislav and Andrew.

 - Adopted Peter's static branch suggestions

 - Renamed the _HOPE mode to _VMWERV along with an explanation of the
   acronym in the changelog. Thanks Mark for the inspiration.

 - Updated documentation. The return to user section has changed a
   lot. Added some explanation about assumptions and hopefully fixed all
   issues mentioned by Borislav, Andrew, Greg....

 - Cleaned up the bitmask issues in the speculation MSR defines as
   pointed out by Greg.

 - Got the Copy & Paste in the sysfs code right this time.

 - Dropped the conditional mode stuff for now. Needs more thought on
   all ends and I wish we just don't need it at all :)

 - Collected a few Reviewed-by tags, but not for the patches which
   have significant changes.

The admin documentation is still WIP, so not included.

It's also available through the git repository in the force updated
branch: WIP.mds

Thanks,

	tglx


 

^ permalink raw reply	[flat|nested] 89+ messages in thread
* [patch V2 00/10] MDS basics+ 0
@ 2019-02-20 15:07 Thomas Gleixner
  2019-02-20 15:07 ` [patch V2 04/10] MDS basics+ 4 Thomas Gleixner
  0 siblings, 1 reply; 89+ messages in thread
From: Thomas Gleixner @ 2019-02-20 15:07 UTC (permalink / raw)
  To: speck

Hi!

This is an update to yesterdays series with the following changes:

   - Addressed review comments (on/off list)

   - Changed the approach with static keys slightly

   - Added "cc" clobber to the VERW asm magic (spotted by Peterz)

   - Added x86 specific documentation which explains the mitigation methods
     and details on why particular code pathes are excluded.

   - Added an internal 'HOPE' mitigation mode to address the VMWare wish.

   - Added the basic infrastructure for conditional mode

Dropped the documentation patch for now as I'm not done with updating it
and I have to run now and attend my grandson's birthday party.

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 89+ messages in thread
* [patch 0/8] MDS basics 0
@ 2019-02-19 12:44 Thomas Gleixner
  2019-02-21 16:14 ` [MODERATED] Encrypted Message Jon Masters
  0 siblings, 1 reply; 89+ messages in thread
From: Thomas Gleixner @ 2019-02-19 12:44 UTC (permalink / raw)
  To: speck

Subject: [patch 0/8] MDS basics
From: Thomas Gleixner <tglx@linutronix.de>

Hi!

I got the following information yesterday night:

  "All - FYI.  There has been some chatter/ discussion on the subject.
   Hopefully this note will help clarify.  We received a report from a
   researcher who independently identified what we formerly referred to as
   PSF (aka Microarchitectural Store Buffer Data Sampling).  There were
   some initial indications (this week) this researcher would elect to
   release a paper publicly PRIOR to the May 14 embargo was lifted.

   We have been working closely with them, and it appears for now that will
   NOT be the case.  Were that to happen however, we DID begin prepping
   materials to disclose PSF ONLY.  I.e. we would disclose only that
   particular issue after having consulted with this team.  This includes a
   modified/ reduced section of the existing whitepaper, press statement
   and standard security advisory language.  We are finalizing this
   material and will then hold it in reserve.

   As we have done in the past, we would convene a meeting of reps from
   this group before activating those assets.  I will keep you apprised of
   any change in the situation, and can provide those assets for your use/
   adaptation once finalized."

This was posted on that keybase io chat on friday night and of course not
made available to those who are not part of that. Even people who are
subscribed there missed the message because it scrolled away due to
other chit/chat.

Now we maybe got lucky this time, but I wouldn't hold my breath as the
propability that other people will figure that out as well is surely way
larger than 0.

If that happens, then it makes exactly ZERO sense to expose only the
MSBDS part as everything else is lumped together with this. But why am
I still trying to make sense of all this?

So while being grumpy about this communication fail, I'm even more
grumpy about the fact, that we don't have even the minimal full/off
mitigation in place in a workable form. I asked specifically for this
weeks ago just for the case that the embargo breaks early so we don't
stand there with pants down.

So being grumpy as hell made me sit down and write the basic
mitigation implementation myself (again).

It reuses a single patch from that Intel pile which is defining the
bug and MSR bits. Guess what, it took me less than 4 hours to do so
and another 2 hours in the morning to write at least the basic admin
documentation. The latter surely needs some work still, but I wanted
to get the patches out. There is also another TODO mentioned further
down.

The series comes with:

  - A consistent command line interface

  - A consistent sysfs interface

  - Static key based control for the exit to user and idle invocations

  - Dynamic update of the idle invocation key according to the actual SMT
    state similar to the STIPB update.

  - Idle invocations are inside the halt/mwait inlines and not randomly
    sprinkled all over the kernel tree.

It builds and boots and while I was able to emit the VERW instruction by
hacking the mitigation selection to omit the MD_CLEAR supported check, I
have no access to real hardware with updated micro code.

This is how it should have looked from the very beginning and the extra
bits and pieces (cond mode) can be built on top of it. Please review and
give it a testride when you have a machine with updated microcode
available.

The lot is also available from the speck git tree in the WIP.mds
branch.

Note, that I moved the L!TF document to a separate folder so the hw
vulnerabilities are not showing up at the top level index of the admin
guide as separate items. Should have thought about that back then
already...

TODO: 

For CPUs which are not affected by L1TF but are affected by MDS there
needs to be CPU buffer clear mitigation at VMENTER.  That applies at
least to XEON PHI, SILVERMONT and AIRMONT and probably to some of the
newer models which have RDCL_NO set.

Thanks,

	tglx

8<-----------------------
 Documentation/ABI/testing/sysfs-devices-system-cpu |    1 
 Documentation/admin-guide/hw-vuln/index.rst        |   13 +
 Documentation/admin-guide/hw-vuln/l1tf.rst         |    1 
 Documentation/admin-guide/hw-vuln/mds.rst          |  230 +++++++++++++++++++++
 Documentation/admin-guide/index.rst                |    6 
 Documentation/admin-guide/kernel-parameters.txt    |   27 ++
 arch/x86/entry/common.c                            |    3 
 arch/x86/include/asm/cpufeatures.h                 |    2 
 arch/x86/include/asm/irqflags.h                    |    4 
 arch/x86/include/asm/msr-index.h                   |    5 
 arch/x86/include/asm/mwait.h                       |    7 
 arch/x86/include/asm/nospec-branch.h               |   22 ++
 arch/x86/include/asm/processor.h                   |    6 
 arch/x86/kernel/cpu/bugs.c                         |  102 +++++++++
 arch/x86/kernel/cpu/common.c                       |   13 +
 drivers/base/cpu.c                                 |    6 
 include/linux/cpu.h                                |    2 
 17 files changed, 443 insertions(+), 7 deletions(-)

^ permalink raw reply	[flat|nested] 89+ messages in thread
* [MODERATED] [PATCH v3 0/6] PERFv3
@ 2019-02-07 23:41 Andi Kleen
  2019-02-07 23:41 ` [MODERATED] [PATCH v3 2/6] PERFv3 Andi Kleen
  0 siblings, 1 reply; 89+ messages in thread
From: Andi Kleen @ 2019-02-07 23:41 UTC (permalink / raw)
  To: speck; +Cc: Andi Kleen

Walnut is an functional (not security) issue with TSX. The upcoming
microcode updates on Skylake may corrupt perfmon counter 3
when RTM transactions are used.

There is a new MSR that allows to force abort RTM, and free
counter 3.

The following patchkit adds the support to perf to avoid
using counter 3, or disabling TSX when counter 3 is needed
for perf.

There are per perf event and global options to set the
default.

This patch sets the default to TSX enabled, but
that could be easily changed.

We can have a discussion on the trade offs of the default
setting. I suspect it's a decision that should be made by Linus,
as it may impact user programs either way.

The trade offs for setting the option default are:
    
Using 4 (or 8 with HT off) events in perf versus
allowing RTM usage while perf is active.
    
- Existing programs that use perf groups with 4 counters
  may not retrieve perfmon data anymore. Perf usages
  that use less than four (or 7 with HT off) counters
  are not impacted. Perf usages that don't use group
  will still work, but will see increase multiplexing.
    
- TSX programs should not functionally break from
  forcing RTM to abort because they always need a valid
  fall back path. However they will see significantly
  lower performance if they rely on TSX for performance
  (all RTM transactions will run and only abort at the end),
  potentially slowing them down so much that it is
  equivalent to functional breakage.

Patches are against tip/perf/core as of 
commit ca3bb3d027f69ac3ab1dafb32bde2f5a3a44439c (tip/perf/core)
Author: Elena Reshetova <elena.reshetova@intel.com>

-Andi

v1: Initial post

v2: Minor updates in code (see individual patches)
Removed optimization to not change MSR for update. This caused missing
MSR updates in some cases. 
Redid KVM code to always intercept MSR and pass correct flag
to host perf.

v3: Use Peter's scheduling patch, with some changes and cleanups.
Dropped some obsolete patches.
KVM now always forces the guest state and doesn't rely on the host state.

Andi Kleen (6):
  x86/pmu/intel: Export number of counters in caps
  x86/pmu/intel: Handle TSX with counter 3 on Skylake
  x86/pmu/intel: Add perf event attribute to control RTM
  perf stat: Make all existing groups weak
  perf stat: Don't count EL for --transaction with three counters
  kvm: vmx: Support TSX_FORCE_ABORT in KVM guests

 arch/x86/events/core.c             | 24 ++++++++
 arch/x86/events/intel/core.c       | 94 +++++++++++++++++++++++++++++-
 arch/x86/events/perf_event.h       | 13 ++++-
 arch/x86/include/asm/cpufeatures.h |  1 +
 arch/x86/include/asm/kvm_host.h    |  1 +
 arch/x86/include/asm/msr-index.h   |  5 ++
 arch/x86/kvm/cpuid.c               |  3 +-
 arch/x86/kvm/pmu.c                 | 19 +++---
 arch/x86/kvm/pmu.h                 |  6 +-
 arch/x86/kvm/pmu_amd.c             |  2 +-
 arch/x86/kvm/vmx/pmu_intel.c       | 20 ++++++-
 tools/perf/builtin-stat.c          | 38 ++++++++----
 tools/perf/util/pmu.c              | 10 ++++
 tools/perf/util/pmu.h              |  1 +
 14 files changed, 211 insertions(+), 26 deletions(-)

-- 
2.17.2

^ permalink raw reply	[flat|nested] 89+ messages in thread
* [MODERATED] [PATCH v4 00/28] MDSv4 2
@ 2019-01-12  1:29 Andi Kleen
  2019-01-12  1:29 ` [MODERATED] [PATCH v4 05/28] MDSv4 10 Andi Kleen
  2019-01-12  1:29 ` [MODERATED] [PATCH v4 10/28] MDSv4 24 Andi Kleen
  0 siblings, 2 replies; 89+ messages in thread
From: Andi Kleen @ 2019-01-12  1:29 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.

Andi Kleen (28):
  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: Clear CPU buffers on entering idle
  x86/speculation/mds: Add sysfs reporting
  x86/speculation/mds: Support mds=full for NMIs
  x86/speculation/mds: Support mds=full for 32bit NMI
  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                    | 173 ++++++++++++++++++
 arch/Kconfig                                  |   3 +
 arch/x86/Kconfig                              |   1 +
 arch/x86/entry/common.c                       |  13 +-
 arch/x86/entry/entry_32.S                     |   6 +
 arch/x86/entry/entry_64.S                     |  12 ++
 arch/x86/include/asm/clearbpf.h               |  29 +++
 arch/x86/include/asm/clearcpu.h               |  92 ++++++++++
 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                    |  46 +++++
 arch/x86/kernel/cpu/common.c                  |  14 ++
 arch/x86/kernel/kvm.c                         |   3 +
 arch/x86/kernel/process.c                     |   5 +
 arch/x86/kernel/process.h                     |  27 +++
 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                           |   7 +-
 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 +-
 65 files changed, 869 insertions(+), 61 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] 89+ messages in thread
* [MODERATED] FYI - Reading uncached memory
@ 2018-06-12 17:29 Jon Masters
  2018-06-14 16:59 ` [MODERATED] Encrypted Message Tim Chen
  0 siblings, 1 reply; 89+ messages in thread
From: Jon Masters @ 2018-06-12 17:29 UTC (permalink / raw)
  To: speck

FYI Graz have been able to prove the Intel processors will allow
speculative reads of /explicitly/ UC memory (e.g. marked in MTRR). I
believe they actually use the QPI SAD table to determine what memory is
speculation safe and what memory has side effects (i.e. if it's HA'able
memory then it's deemed ok to rampantly speculate from it).

Just in case anyone thought UC was safe against attacks.

Jon.

-- 
Computer Architect | Sent from my Fedora powered laptop

^ permalink raw reply	[flat|nested] 89+ messages in thread
* [MODERATED] [PATCH 0/2] L1TF KVM 0
@ 2018-05-29 19:42 Paolo Bonzini
       [not found] ` <20180529194240.7F1336110A@crypto-ml.lab.linutronix.de>
  0 siblings, 1 reply; 89+ messages in thread
From: Paolo Bonzini @ 2018-05-29 19:42 UTC (permalink / raw)
  To: speck

Here is the first version of the L1 terminal fault KVM mitigation patches,
adding a TLB flush on vmentry.

Thanks,

Paolo

^ permalink raw reply	[flat|nested] 89+ messages in thread
* SSB status - V18 pushed out
@ 2018-05-17 20:53 Thomas Gleixner
  2018-05-18 13:54 ` [MODERATED] Is: Sleep states ?Was:Re: " Konrad Rzeszutek Wilk
  0 siblings, 1 reply; 89+ messages in thread
From: Thomas Gleixner @ 2018-05-17 20:53 UTC (permalink / raw)
  To: speck

[-- Attachment #1: Type: text/plain, Size: 473 bytes --]

Folks,

we finally reached a stable state with the SSB patches. I've updated all 3
branches master/linux-4.16.y/linux-4.14.y in the repo and attached the
resulting git bundles. They merge cleanly on top of the current HEADs of
the relevant trees.

The lot survived light testing on my side and it would be great if everyone
involved could expose it to their test scenarios.

Thanks to everyone who participated in that effort (patches, review,
testing ...)!

Thanks,

	tglx

[-- Attachment #2: Type: application/octet-stream, Size: 79102 bytes --]

[-- Attachment #3: Type: application/octet-stream, Size: 75724 bytes --]

[-- Attachment #4: Type: application/octet-stream, Size: 75835 bytes --]

^ permalink raw reply	[flat|nested] 89+ messages in thread
* [patch V11 00/16] SSB 0
@ 2018-05-02 21:51 Thomas Gleixner
  2018-05-03  4:27 ` [MODERATED] Encrypted Message Tim Chen
  0 siblings, 1 reply; 89+ messages in thread
From: Thomas Gleixner @ 2018-05-02 21:51 UTC (permalink / raw)
  To: speck

Changes since V10:

  - Addressed Ingos review feedback

  - Picked up Reviewed-bys

Delta patch below. Bundle is coming in separate mail. Git repo branches are
updated as well. The master branch contains also the fix for the lost IBRS
issue Tim was seeing.

If there are no further issues and nitpicks, I'm going to make the
changes immutable and changes need to go incremental on top.

Thanks,

	tglx

8<--------------------
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 29984fd3dd18..a8d2ae1e335b 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -4051,11 +4051,12 @@
 
 			on     - Unconditionally disable Speculative Store Bypass
 			off    - Unconditionally enable Speculative Store Bypass
-			auto   - Kernel detects whether the CPU model contains a
+			auto   - Kernel detects whether the CPU model contains an
 				 implementation of Speculative Store Bypass and
-				 picks the most appropriate mitigation
-			prctl  - Control Speculative Store Bypass for a thread
-				 via prctl. By default it is enabled. The state
+				 picks the most appropriate mitigation.
+			prctl  - Control Speculative Store Bypass per thread
+				 via prctl. Speculative Store Bypass is enabled
+				 for a process by default. The state of the control
 				 is inherited on fork.
 
 			Not specifying this option is equivalent to
diff --git a/Documentation/userspace-api/spec_ctrl.rst b/Documentation/userspace-api/spec_ctrl.rst
index 8ff39a26a992..ddbebcd01208 100644
--- a/Documentation/userspace-api/spec_ctrl.rst
+++ b/Documentation/userspace-api/spec_ctrl.rst
@@ -10,7 +10,7 @@ The kernel provides mitigation for such vulnerabilities in various
 forms. Some of these mitigations are compile time configurable and some on
 the kernel command line.
 
-There is also a class of mitigations which is very expensive, but they can
+There is also a class of mitigations which are very expensive, but they can
 be restricted to a certain set of processes or tasks in controlled
 environments. The mechanism to control these mitigations is via
 :manpage:`prctl(2)`.
@@ -25,7 +25,7 @@ PR_GET_SPECULATION_CTRL
 -----------------------
 
 PR_GET_SPECULATION_CTRL returns the state of the speculation misfeature
-which is selected with arg2 of prctl(2). The return value uses bit 0-2 with
+which is selected with arg2 of prctl(2). The return value uses bits 0-2 with
 the following meaning:
 
 ==== ================ ===================================================
diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
index 5bee7a2ca4ff..810f50bb338d 100644
--- a/arch/x86/include/asm/msr-index.h
+++ b/arch/x86/include/asm/msr-index.h
@@ -70,7 +70,11 @@
 #define MSR_IA32_ARCH_CAPABILITIES	0x0000010a
 #define ARCH_CAP_RDCL_NO		(1 << 0)   /* Not susceptible to Meltdown */
 #define ARCH_CAP_IBRS_ALL		(1 << 1)   /* Enhanced IBRS support */
-#define ARCH_CAP_RDS_NO			(1 << 4)   /* Not susceptible to speculative store bypass */
+#define ARCH_CAP_RDS_NO			(1 << 4)   /*
+						    * Not susceptible to Speculative Store Bypass
+						    * attack, so no Reduced Data Speculation control
+						    * required.
+						    */
 
 #define MSR_IA32_BBL_CR_CTL		0x00000119
 #define MSR_IA32_BBL_CR_CTL3		0x0000011e
diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h
index 023e2edc0f3c..71ad01422655 100644
--- a/arch/x86/include/asm/nospec-branch.h
+++ b/arch/x86/include/asm/nospec-branch.h
@@ -225,8 +225,8 @@ enum spectre_v2_mitigation {
  * ourselves and always use this as the base for SPEC_CTRL.
  * We also use this when handling guest entry/exit as below.
  */
-extern void x86_set_spec_ctrl(u64);
-extern u64 x86_get_default_spec_ctrl(void);
+extern void x86_spec_ctrl_set(u64);
+extern u64 x86_spec_ctrl_get_default(void);
 
 /* The Speculative Store Bypass disable variants */
 enum ssb_mitigation {
@@ -285,7 +285,7 @@ static inline void indirect_branch_prediction_barrier(void)
  */
 #define firmware_restrict_branch_speculation_start()			\
 do {									\
-	u64 val = x86_get_default_spec_ctrl() | SPEC_CTRL_IBRS;		\
+	u64 val = x86_spec_ctrl_get_default() | SPEC_CTRL_IBRS;		\
 									\
 	preempt_disable();						\
 	alternative_msr_write(MSR_IA32_SPEC_CTRL, val,			\
@@ -294,7 +294,7 @@ do {									\
 
 #define firmware_restrict_branch_speculation_end()			\
 do {									\
-	u64 val = x86_get_default_spec_ctrl();				\
+	u64 val = x86_spec_ctrl_get_default();				\
 									\
 	alternative_msr_write(MSR_IA32_SPEC_CTRL, val,			\
 			      X86_FEATURE_USE_IBRS_FW);			\
diff --git a/arch/x86/include/asm/spec-ctrl.h b/arch/x86/include/asm/spec-ctrl.h
index 607236af4008..45ef00ad5105 100644
--- a/arch/x86/include/asm/spec-ctrl.h
+++ b/arch/x86/include/asm/spec-ctrl.h
@@ -12,8 +12,8 @@
  * shadowable for guests but this is not (currently) the case.
  * Takes the guest view of SPEC_CTRL MSR as a parameter.
  */
-extern void x86_set_guest_spec_ctrl(u64);
-extern void x86_restore_host_spec_ctrl(u64);
+extern void x86_spec_ctrl_set_guest(u64);
+extern void x86_spec_ctrl_restore_host(u64);
 
 /* AMD specific Speculative Store Bypass MSR data */
 extern u64 x86_amd_ls_cfg_base;
@@ -30,7 +30,7 @@ static inline u64 rds_tif_to_spec_ctrl(u64 tifn)
 
 static inline u64 rds_tif_to_amd_ls_cfg(u64 tifn)
 {
-	return tifn & _TIF_RDS ? x86_amd_ls_cfg_rds_mask : 0ULL;
+	return (tifn & _TIF_RDS) ? x86_amd_ls_cfg_rds_mask : 0ULL;
 }
 
 extern void speculative_store_bypass_update(void);
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 50c6ba6d031b..18efc33a8d2e 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -572,7 +572,7 @@ static void bsp_init_amd(struct cpuinfo_x86 *c)
 		if (!rdmsrl_safe(MSR_AMD64_LS_CFG, &x86_amd_ls_cfg_base)) {
 			setup_force_cpu_cap(X86_FEATURE_RDS);
 			setup_force_cpu_cap(X86_FEATURE_AMD_RDS);
-			x86_amd_ls_cfg_rds_mask = (1ULL << bit);
+			x86_amd_ls_cfg_rds_mask = 1ULL << bit;
 		}
 	}
 }
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index c28856e475c8..15f77d4518c7 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -32,7 +32,7 @@ static void __init spectre_v2_select_mitigation(void);
 static void __init ssb_select_mitigation(void);
 
 /*
- * Our boot-time value of SPEC_CTRL MSR. We read it once so that any
+ * Our boot-time value of the SPEC_CTRL MSR. We read it once so that any
  * writes to SPEC_CTRL contain whatever reserved bits have been set.
  */
 u64 __ro_after_init x86_spec_ctrl_base;
@@ -41,11 +41,11 @@ u64 __ro_after_init x86_spec_ctrl_base;
  * The vendor and possibly platform specific bits which can be modified in
  * x86_spec_ctrl_base.
  */
-static u64 __ro_after_init x86_spec_ctrl_mask = ~(SPEC_CTRL_IBRS);
+static u64 __ro_after_init x86_spec_ctrl_mask = ~SPEC_CTRL_IBRS;
 
 /*
- * AMD specific MSR info for Store Bypass control.  x86_amd_ls_cfg_rds_mask
- * is initialized in identify_boot_cpu().
+ * AMD specific MSR info for Speculative Store Bypass control.
+ * x86_amd_ls_cfg_rds_mask is initialized in identify_boot_cpu().
  */
 u64 __ro_after_init x86_amd_ls_cfg_base;
 u64 __ro_after_init x86_amd_ls_cfg_rds_mask;
@@ -61,7 +61,7 @@ void __init check_bugs(void)
 
 	/*
 	 * Read the SPEC_CTRL MSR to account for reserved bits which may
-	 * have unknown values. AMD64_LS_CFG msr is cached in the early AMD
+	 * have unknown values. AMD64_LS_CFG MSR is cached in the early AMD
 	 * init code as it is not enumerated and depends on the family.
 	 */
 	if (boot_cpu_has(X86_FEATURE_IBRS))
@@ -131,22 +131,22 @@ static const char *spectre_v2_strings[] = {
 
 static enum spectre_v2_mitigation spectre_v2_enabled = SPECTRE_V2_NONE;
 
-void x86_set_spec_ctrl(u64 val)
+void x86_spec_ctrl_set(u64 val)
 {
 	if (val & x86_spec_ctrl_mask)
 		WARN_ONCE(1, "SPEC_CTRL MSR value 0x%16llx is unknown.\n", val);
 	else
 		wrmsrl(MSR_IA32_SPEC_CTRL, x86_spec_ctrl_base | val);
 }
-EXPORT_SYMBOL_GPL(x86_set_spec_ctrl);
+EXPORT_SYMBOL_GPL(x86_spec_ctrl_set);
 
-u64 x86_get_default_spec_ctrl(void)
+u64 x86_spec_ctrl_get_default(void)
 {
 	return x86_spec_ctrl_base;
 }
-EXPORT_SYMBOL_GPL(x86_get_default_spec_ctrl);
+EXPORT_SYMBOL_GPL(x86_spec_ctrl_get_default);
 
-void x86_set_guest_spec_ctrl(u64 guest_spec_ctrl)
+void x86_spec_ctrl_set_guest(u64 guest_spec_ctrl)
 {
 	u64 host = x86_spec_ctrl_base;
 
@@ -159,9 +159,9 @@ void x86_set_guest_spec_ctrl(u64 guest_spec_ctrl)
 	if (host != guest_spec_ctrl)
 		wrmsrl(MSR_IA32_SPEC_CTRL, guest_spec_ctrl);
 }
-EXPORT_SYMBOL_GPL(x86_set_guest_spec_ctrl);
+EXPORT_SYMBOL_GPL(x86_spec_ctrl_set_guest);
 
-void x86_restore_host_spec_ctrl(u64 guest_spec_ctrl)
+void x86_spec_ctrl_restore_host(u64 guest_spec_ctrl)
 {
 	u64 host = x86_spec_ctrl_base;
 
@@ -174,7 +174,7 @@ void x86_restore_host_spec_ctrl(u64 guest_spec_ctrl)
 	if (host != guest_spec_ctrl)
 		wrmsrl(MSR_IA32_SPEC_CTRL, host);
 }
-EXPORT_SYMBOL_GPL(x86_restore_host_spec_ctrl);
+EXPORT_SYMBOL_GPL(x86_spec_ctrl_restore_host);
 
 static void x86_amd_rds_enable(void)
 {
@@ -504,8 +504,8 @@ static enum ssb_mitigation_cmd __init __ssb_select_mitigation(void)
 		switch (boot_cpu_data.x86_vendor) {
 		case X86_VENDOR_INTEL:
 			x86_spec_ctrl_base |= SPEC_CTRL_RDS;
-			x86_spec_ctrl_mask &= ~(SPEC_CTRL_RDS);
-			x86_set_spec_ctrl(SPEC_CTRL_RDS);
+			x86_spec_ctrl_mask &= ~SPEC_CTRL_RDS;
+			x86_spec_ctrl_set(SPEC_CTRL_RDS);
 			break;
 		case X86_VENDOR_AMD:
 			x86_amd_rds_enable();
@@ -560,7 +560,7 @@ static int ssb_prctl_get(void)
 	}
 }
 
-int arch_prctl_set_spec_ctrl(unsigned long which, unsigned long ctrl)
+int arch_prctl_spec_ctrl_set(unsigned long which, unsigned long ctrl)
 {
 	if (ctrl != PR_SPEC_ENABLE && ctrl != PR_SPEC_DISABLE)
 		return -ERANGE;
@@ -573,7 +573,7 @@ int arch_prctl_set_spec_ctrl(unsigned long which, unsigned long ctrl)
 	}
 }
 
-int arch_prctl_get_spec_ctrl(unsigned long which)
+int arch_prctl_spec_ctrl_get(unsigned long which)
 {
 	switch (which) {
 	case PR_SPEC_STORE_BYPASS:
@@ -583,10 +583,10 @@ int arch_prctl_get_spec_ctrl(unsigned long which)
 	}
 }
 
-void x86_setup_ap_spec_ctrl(void)
+void x86_spec_ctrl_setup_ap(void)
 {
 	if (boot_cpu_has(X86_FEATURE_IBRS))
-		x86_set_spec_ctrl(x86_spec_ctrl_base & ~x86_spec_ctrl_mask);
+		x86_spec_ctrl_set(x86_spec_ctrl_base & ~x86_spec_ctrl_mask);
 
 	if (ssb_mode == SPEC_STORE_BYPASS_DISABLE)
 		x86_amd_rds_enable();
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index f3dbdde978a4..e0517bcee446 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -848,6 +848,11 @@ void get_cpu_cap(struct cpuinfo_x86 *c)
 		c->x86_power = edx;
 	}
 
+	if (c->extended_cpuid_level >= 0x80000008) {
+		cpuid(0x80000008, &eax, &ebx, &ecx, &edx);
+		c->x86_capability[CPUID_8000_0008_EBX] = ebx;
+	}
+
 	if (c->extended_cpuid_level >= 0x8000000a)
 		c->x86_capability[CPUID_8000_000A_EDX] = cpuid_edx(0x8000000a);
 
@@ -871,7 +876,6 @@ static void get_cpu_address_sizes(struct cpuinfo_x86 *c)
 
 		c->x86_virt_bits = (eax >> 8) & 0xff;
 		c->x86_phys_bits = eax & 0xff;
-		c->x86_capability[CPUID_8000_0008_EBX] = ebx;
 	}
 #ifdef CONFIG_X86_32
 	else if (cpu_has(c, X86_FEATURE_PAE) || cpu_has(c, X86_FEATURE_PSE36))
@@ -924,26 +928,26 @@ static const __initconst struct x86_cpu_id cpu_no_meltdown[] = {
 };
 
 static const __initconst struct x86_cpu_id cpu_no_spec_store_bypass[] = {
-	{ X86_VENDOR_INTEL,     6, INTEL_FAM6_ATOM_PINEVIEW },
-	{ X86_VENDOR_INTEL,     6, INTEL_FAM6_ATOM_LINCROFT },
-	{ X86_VENDOR_INTEL,     6, INTEL_FAM6_ATOM_PENWELL },
-	{ X86_VENDOR_INTEL,     6, INTEL_FAM6_ATOM_CLOVERVIEW },
-	{ X86_VENDOR_INTEL,     6, INTEL_FAM6_ATOM_CEDARVIEW },
-	{ X86_VENDOR_INTEL,     6, INTEL_FAM6_ATOM_SILVERMONT1 },
-	{ X86_VENDOR_INTEL,     6, INTEL_FAM6_ATOM_AIRMONT },
-	{ X86_VENDOR_INTEL,     6, INTEL_FAM6_ATOM_SILVERMONT2 },
-	{ X86_VENDOR_INTEL,     6, INTEL_FAM6_ATOM_MERRIFIELD },
-	{ X86_VENDOR_INTEL,     6, INTEL_FAM6_CORE_YONAH },
-	{ X86_VENDOR_INTEL,     6, INTEL_FAM6_XEON_PHI_KNL },
-	{ X86_VENDOR_INTEL,     6, INTEL_FAM6_XEON_PHI_KNM },
-	{ X86_VENDOR_CENTAUR,	5 },
-	{ X86_VENDOR_INTEL,	5 },
-	{ X86_VENDOR_NSC,	5 },
-	{ X86_VENDOR_AMD,	0xf },
-	{ X86_VENDOR_AMD,	0x10 },
-	{ X86_VENDOR_AMD,	0x11 },
-	{ X86_VENDOR_AMD,	0x12 },
-	{ X86_VENDOR_ANY,	4 },
+	{ X86_VENDOR_INTEL,	6,	INTEL_FAM6_ATOM_PINEVIEW	},
+	{ X86_VENDOR_INTEL,	6,	INTEL_FAM6_ATOM_LINCROFT	},
+	{ X86_VENDOR_INTEL,	6,	INTEL_FAM6_ATOM_PENWELL		},
+	{ X86_VENDOR_INTEL,	6,	INTEL_FAM6_ATOM_CLOVERVIEW	},
+	{ X86_VENDOR_INTEL,	6,	INTEL_FAM6_ATOM_CEDARVIEW	},
+	{ X86_VENDOR_INTEL,	6,	INTEL_FAM6_ATOM_SILVERMONT1	},
+	{ X86_VENDOR_INTEL,	6,	INTEL_FAM6_ATOM_AIRMONT		},
+	{ X86_VENDOR_INTEL,	6,	INTEL_FAM6_ATOM_SILVERMONT2	},
+	{ X86_VENDOR_INTEL,	6,	INTEL_FAM6_ATOM_MERRIFIELD	},
+	{ X86_VENDOR_INTEL,	6,	INTEL_FAM6_CORE_YONAH		},
+	{ X86_VENDOR_INTEL,	6,	INTEL_FAM6_XEON_PHI_KNL		},
+	{ X86_VENDOR_INTEL,	6,	INTEL_FAM6_XEON_PHI_KNM		},
+	{ X86_VENDOR_CENTAUR,	5,					},
+	{ X86_VENDOR_INTEL,	5,					},
+	{ X86_VENDOR_NSC,	5,					},
+	{ X86_VENDOR_AMD,	0x12,					},
+	{ X86_VENDOR_AMD,	0x11,					},
+	{ X86_VENDOR_AMD,	0x10,					},
+	{ X86_VENDOR_AMD,	0xf,					},
+	{ X86_VENDOR_ANY,	4,					},
 	{}
 };
 
@@ -1384,7 +1388,7 @@ void identify_secondary_cpu(struct cpuinfo_x86 *c)
 #endif
 	mtrr_ap_init();
 	validate_apic_and_package_id(c);
-	x86_setup_ap_spec_ctrl();
+	x86_spec_ctrl_setup_ap();
 }
 
 static __init int setup_noclflush(char *arg)
diff --git a/arch/x86/kernel/cpu/cpu.h b/arch/x86/kernel/cpu/cpu.h
index faaabc160293..37672d299e35 100644
--- a/arch/x86/kernel/cpu/cpu.h
+++ b/arch/x86/kernel/cpu/cpu.h
@@ -50,6 +50,6 @@ extern void cpu_detect_cache_sizes(struct cpuinfo_x86 *c);
 
 unsigned int aperfmperf_get_khz(int cpu);
 
-extern void x86_setup_ap_spec_ctrl(void);
+extern void x86_spec_ctrl_setup_ap(void);
 
 #endif /* ARCH_X86_CPU_H */
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index ba4763e9a285..437c1b371129 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -5557,7 +5557,7 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
 	 * is no need to worry about the conditional branch over the wrmsr
 	 * being speculatively taken.
 	 */
-	x86_set_guest_spec_ctrl(svm->spec_ctrl);
+	x86_spec_ctrl_set_guest(svm->spec_ctrl);
 
 	asm volatile (
 		"push %%" _ASM_BP "; \n\t"
@@ -5669,7 +5669,7 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
 	if (unlikely(!msr_write_intercepted(vcpu, MSR_IA32_SPEC_CTRL)))
 		svm->spec_ctrl = native_read_msr(MSR_IA32_SPEC_CTRL);
 
-	x86_restore_host_spec_ctrl(svm->spec_ctrl);
+	x86_spec_ctrl_restore_host(svm->spec_ctrl);
 
 	/* Eliminate branch target predictions from guest mode */
 	vmexit_fill_RSB();
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 9744e48457d6..16a111e44691 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -9722,7 +9722,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
 	 * is no need to worry about the conditional branch over the wrmsr
 	 * being speculatively taken.
 	 */
-	x86_set_guest_spec_ctrl(vmx->spec_ctrl);
+	x86_spec_ctrl_set_guest(vmx->spec_ctrl);
 
 	vmx->__launched = vmx->loaded_vmcs->launched;
 
@@ -9870,7 +9870,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
 	if (unlikely(!msr_write_intercepted(vcpu, MSR_IA32_SPEC_CTRL)))
 		vmx->spec_ctrl = native_read_msr(MSR_IA32_SPEC_CTRL);
 
-	x86_restore_host_spec_ctrl(vmx->spec_ctrl);
+	x86_spec_ctrl_restore_host(vmx->spec_ctrl);
 
 	/* Eliminate branch target predictions from guest mode */
 	vmexit_fill_RSB();
diff --git a/include/linux/nospec.h b/include/linux/nospec.h
index 1e63a0a90e96..700bb8a4e4ea 100644
--- a/include/linux/nospec.h
+++ b/include/linux/nospec.h
@@ -57,7 +57,7 @@ static inline unsigned long array_index_mask_nospec(unsigned long index,
 })
 
 /* Speculation control prctl */
-int arch_prctl_set_spec_ctrl(unsigned long which, unsigned long ctrl);
-int arch_prctl_get_spec_ctrl(unsigned long which);
+int arch_prctl_spec_ctrl_get(unsigned long which);
+int arch_prctl_spec_ctrl_set(unsigned long which, unsigned long ctrl);
 
 #endif /* _LINUX_NOSPEC_H */
diff --git a/include/uapi/linux/prctl.h b/include/uapi/linux/prctl.h
index 4e7a160d3b28..ebf057ac1346 100644
--- a/include/uapi/linux/prctl.h
+++ b/include/uapi/linux/prctl.h
@@ -208,8 +208,8 @@ struct prctl_mm_map {
 # define PR_SVE_VL_INHERIT		(1 << 17) /* inherit across exec */
 
 /* Per task speculation control */
-#define PR_SET_SPECULATION_CTRL		52
-#define PR_GET_SPECULATION_CTRL		53
+#define PR_GET_SPECULATION_CTRL		52
+#define PR_SET_SPECULATION_CTRL		53
 /* Speculation control variants */
 # define PR_SPEC_STORE_BYPASS		0
 /* Return and control values for PR_SET/GET_SPECULATION_CTRL */
diff --git a/kernel/sys.c b/kernel/sys.c
index d7afe29319f1..b76dee23bdc9 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -2244,12 +2244,12 @@ static int propagate_has_child_subreaper(struct task_struct *p, void *data)
 	return 1;
 }
 
-int __weak arch_prctl_set_spec_ctrl(unsigned long which, unsigned long ctrl)
+int __weak arch_prctl_spec_ctrl_get(unsigned long which)
 {
 	return -EINVAL;
 }
 
-int __weak arch_prctl_get_spec_ctrl(unsigned long which)
+int __weak arch_prctl_spec_ctrl_set(unsigned long which, unsigned long ctrl)
 {
 	return -EINVAL;
 }
@@ -2462,15 +2462,15 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
 	case PR_SVE_GET_VL:
 		error = SVE_GET_VL();
 		break;
-	case PR_SET_SPECULATION_CTRL:
-		if (arg4 || arg5)
-			return -EINVAL;
-		error = arch_prctl_set_spec_ctrl(arg2, arg3);
-		break;
 	case PR_GET_SPECULATION_CTRL:
 		if (arg3 || arg4 || arg5)
 			return -EINVAL;
-		error = arch_prctl_get_spec_ctrl(arg2);
+		error = arch_prctl_spec_ctrl_get(arg2);
+		break;
+	case PR_SET_SPECULATION_CTRL:
+		if (arg4 || arg5)
+			return -EINVAL;
+		error = arch_prctl_spec_ctrl_set(arg2, arg3);
 		break;
 	default:
 		error = -EINVAL;

^ permalink raw reply related	[flat|nested] 89+ messages in thread
* [MODERATED] L1D-Fault KVM mitigation
@ 2018-04-24  9:06 Joerg Roedel
  2018-04-24  9:35 ` [MODERATED] " Peter Zijlstra
  0 siblings, 1 reply; 89+ messages in thread
From: Joerg Roedel @ 2018-04-24  9:06 UTC (permalink / raw)
  To: speck

Hey,

I've been looking into the mitigation for the L1D fault issue in KVM,
and since the hardware seems to speculate with the GPA as an HPA, it
seems we have to disable SMT to be fully secure here because otherwise
two different guests running on HT siblings could spy on each other.

I'd like to discuss how we mitigate this, the big hammer would be not
initializing the HT siblings at boot on affected machines, but that is
probably a bit too eager as it also penalizes people not using KVM.

Another option is to just print a fat warning and/or refuse to load the
KVM modules on affected machines when HT is enabled.

So what are the opinions on how we should best mitigate this issue?


Regards,

	Joerg

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

end of thread, other threads:[~2019-03-08  6:37 UTC | newest]

Thread overview: 89+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-01 21:47 [patch V6 00/14] MDS basics 0 Thomas Gleixner
2019-03-01 21:47 ` [patch V6 01/14] MDS basics 1 Thomas Gleixner
2019-03-02  0:06   ` [MODERATED] " Frederic Weisbecker
2019-03-01 21:47 ` [patch V6 02/14] MDS basics 2 Thomas Gleixner
2019-03-02  0:34   ` [MODERATED] " Frederic Weisbecker
2019-03-02  8:34   ` Greg KH
2019-03-05 17:54   ` Borislav Petkov
2019-03-01 21:47 ` [patch V6 03/14] MDS basics 3 Thomas Gleixner
2019-03-02  1:12   ` [MODERATED] " Frederic Weisbecker
2019-03-01 21:47 ` [patch V6 04/14] MDS basics 4 Thomas Gleixner
2019-03-02  1:28   ` [MODERATED] " Frederic Weisbecker
2019-03-05 14:52     ` Thomas Gleixner
2019-03-06 20:00   ` [MODERATED] " Andrew Cooper
2019-03-06 20:32     ` Thomas Gleixner
2019-03-07 23:56   ` [MODERATED] " Andi Kleen
2019-03-08  0:36     ` Linus Torvalds
2019-03-01 21:47 ` [patch V6 05/14] MDS basics 5 Thomas Gleixner
2019-03-02  1:37   ` [MODERATED] " Frederic Weisbecker
2019-03-07 23:59   ` Andi Kleen
2019-03-08  6:37     ` Thomas Gleixner
2019-03-01 21:47 ` [patch V6 06/14] MDS basics 6 Thomas Gleixner
2019-03-04  6:28   ` [MODERATED] Encrypted Message Jon Masters
2019-03-05 14:55     ` Thomas Gleixner
2019-03-01 21:47 ` [patch V6 07/14] MDS basics 7 Thomas Gleixner
2019-03-02  2:22   ` [MODERATED] " Frederic Weisbecker
2019-03-05 15:30     ` Thomas Gleixner
2019-03-06 15:49       ` [MODERATED] " Frederic Weisbecker
2019-03-06  5:21   ` Borislav Petkov
2019-03-01 21:47 ` [patch V6 08/14] MDS basics 8 Thomas Gleixner
2019-03-03  2:54   ` [MODERATED] " Frederic Weisbecker
2019-03-04  6:57   ` [MODERATED] Encrypted Message Jon Masters
2019-03-04  7:06     ` Jon Masters
2019-03-04  8:12       ` Jon Masters
2019-03-05 15:34     ` Thomas Gleixner
2019-03-06 16:21       ` [MODERATED] " Jon Masters
2019-03-06 14:11   ` [MODERATED] Re: [patch V6 08/14] MDS basics 8 Borislav Petkov
2019-03-01 21:47 ` [patch V6 09/14] MDS basics 9 Thomas Gleixner
2019-03-06 16:14   ` [MODERATED] " Frederic Weisbecker
2019-03-01 21:47 ` [patch V6 10/14] MDS basics 10 Thomas Gleixner
2019-03-04  6:45   ` [MODERATED] Encrypted Message Jon Masters
2019-03-05 18:42   ` [MODERATED] Re: [patch V6 10/14] MDS basics 10 Andrea Arcangeli
2019-03-06 19:15     ` Thomas Gleixner
2019-03-06 14:31   ` [MODERATED] " Borislav Petkov
2019-03-06 15:30     ` Thomas Gleixner
2019-03-06 18:35       ` Thomas Gleixner
2019-03-06 19:34         ` [MODERATED] Re: " Borislav Petkov
2019-03-01 21:47 ` [patch V6 11/14] MDS basics 11 Thomas Gleixner
2019-03-01 21:47 ` [patch V6 12/14] MDS basics 12 Thomas Gleixner
2019-03-04  5:47   ` [MODERATED] Encrypted Message Jon Masters
2019-03-05 16:04     ` Thomas Gleixner
2019-03-05 16:40   ` [MODERATED] Re: [patch V6 12/14] MDS basics 12 mark gross
2019-03-06 14:42   ` Borislav Petkov
2019-03-01 21:47 ` [patch V6 13/14] MDS basics 13 Thomas Gleixner
2019-03-03  4:01   ` [MODERATED] " Josh Poimboeuf
2019-03-05 16:04     ` Thomas Gleixner
2019-03-05 16:43   ` [MODERATED] " mark gross
2019-03-01 21:47 ` [patch V6 14/14] MDS basics 14 Thomas Gleixner
2019-03-01 23:48 ` [patch V6 00/14] MDS basics 0 Thomas Gleixner
2019-03-04  5:30 ` [MODERATED] Encrypted Message Jon Masters
  -- strict thread matches above, loose matches on Subject: below --
2019-03-05 16:43 [MODERATED] Starting to go public? Linus Torvalds
2019-03-05 17:02 ` [MODERATED] " Andrew Cooper
2019-03-05 20:36   ` Jiri Kosina
2019-03-05 22:31     ` Andrew Cooper
2019-03-06 16:18       ` [MODERATED] Encrypted Message Jon Masters
2019-03-05 17:10 ` Jon Masters
2019-03-04  1:21 [MODERATED] [PATCH RFC 0/4] Proposed cmdline improvements Josh Poimboeuf
2019-03-04  1:23 ` [MODERATED] [PATCH RFC 1/4] 1 Josh Poimboeuf
2019-03-04  3:55   ` [MODERATED] Encrypted Message Jon Masters
2019-03-04  7:30   ` [MODERATED] Re: [PATCH RFC 1/4] 1 Greg KH
2019-03-04  7:45     ` [MODERATED] Encrypted Message Jon Masters
2019-03-04  1:24 ` [MODERATED] [PATCH RFC 3/4] 3 Josh Poimboeuf
2019-03-04  3:58   ` [MODERATED] Encrypted Message Jon Masters
2019-03-04 17:17     ` [MODERATED] " Josh Poimboeuf
2019-03-06 16:22       ` [MODERATED] " Jon Masters
2019-03-04  1:25 ` [MODERATED] [PATCH RFC 4/4] 4 Josh Poimboeuf
2019-03-04  4:07   ` [MODERATED] Encrypted Message Jon Masters
2019-02-24 15:07 [MODERATED] [PATCH v6 00/43] MDSv6 Andi Kleen
2019-02-24 15:07 ` [MODERATED] [PATCH v6 10/43] MDSv6 Andi Kleen
2019-02-25 16:30   ` [MODERATED] " Greg KH
2019-02-25 16:41     ` [MODERATED] Encrypted Message Jon Masters
2019-02-24 15:07 ` [MODERATED] [PATCH v6 31/43] MDSv6 Andi Kleen
2019-02-25 15:19   ` [MODERATED] " Greg KH
2019-02-25 15:34     ` Andi Kleen
2019-02-25 15:49       ` Greg KH
2019-02-25 15:52         ` [MODERATED] Encrypted Message Jon Masters
2019-02-25 16:00           ` [MODERATED] " Greg KH
2019-02-25 16:19             ` [MODERATED] " Jon Masters
2019-02-22 22:24 [patch V4 00/11] MDS basics Thomas Gleixner
2019-02-22 22:24 ` [patch V4 04/11] x86/speculation/mds: Add mds_clear_cpu_buffer() Thomas Gleixner
2019-02-26 14:19   ` [MODERATED] " Josh Poimboeuf
2019-03-01 20:58     ` [MODERATED] Encrypted Message Jon Masters
2019-03-01 22:14       ` Jon Masters
2019-02-21 23:44 [patch V3 0/9] MDS basics 0 Thomas Gleixner
2019-02-21 23:44 ` [patch V3 4/9] MDS basics 4 Thomas Gleixner
2019-02-22  7:45   ` [MODERATED] Encrypted Message Jon Masters
2019-02-20 15:07 [patch V2 00/10] MDS basics+ 0 Thomas Gleixner
2019-02-20 15:07 ` [patch V2 04/10] MDS basics+ 4 Thomas Gleixner
2019-02-20 17:10   ` [MODERATED] " mark gross
2019-02-21 19:26     ` [MODERATED] Encrypted Message Tim Chen
2019-02-19 12:44 [patch 0/8] MDS basics 0 Thomas Gleixner
2019-02-21 16:14 ` [MODERATED] Encrypted Message Jon Masters
2019-02-07 23:41 [MODERATED] [PATCH v3 0/6] PERFv3 Andi Kleen
2019-02-07 23:41 ` [MODERATED] [PATCH v3 2/6] PERFv3 Andi Kleen
2019-02-08  0:51   ` [MODERATED] Re: [SUSPECTED SPAM][PATCH " Andrew Cooper
2019-02-08  9:01     ` Peter Zijlstra
2019-02-08  9:39       ` Peter Zijlstra
2019-02-08 10:53         ` [MODERATED] [RFC][PATCH] performance walnuts Peter Zijlstra
2019-02-15 23:45           ` [MODERATED] Encrypted Message Jon Masters
2019-01-12  1:29 [MODERATED] [PATCH v4 00/28] MDSv4 2 Andi Kleen
2019-01-12  1:29 ` [MODERATED] [PATCH v4 05/28] MDSv4 10 Andi Kleen
2019-01-14 19:20   ` [MODERATED] " Dave Hansen
2019-01-18  7:33     ` [MODERATED] Encrypted Message Jon Masters
2019-01-14 23:39   ` Tim Chen
2019-01-12  1:29 ` [MODERATED] [PATCH v4 10/28] MDSv4 24 Andi Kleen
2019-01-15  1:05   ` [MODERATED] Encrypted Message Tim Chen
2018-06-12 17:29 [MODERATED] FYI - Reading uncached memory Jon Masters
2018-06-14 16:59 ` [MODERATED] Encrypted Message Tim Chen
2018-05-29 19:42 [MODERATED] [PATCH 0/2] L1TF KVM 0 Paolo Bonzini
     [not found] ` <20180529194240.7F1336110A@crypto-ml.lab.linutronix.de>
2018-05-29 22:49   ` [PATCH 1/2] L1TF KVM 1 Thomas Gleixner
2018-05-29 23:54     ` [MODERATED] " Andrew Cooper
2018-05-30  9:01       ` Paolo Bonzini
2018-06-04  8:24         ` [MODERATED] " Martin Pohlack
2018-06-04 13:11           ` [MODERATED] Is: Tim, Q to you. Was:Re: " Konrad Rzeszutek Wilk
2018-06-04 17:59             ` [MODERATED] Encrypted Message Tim Chen
2018-06-05 23:34             ` Tim Chen
2018-06-05 23:37               ` Tim Chen
2018-06-07 19:11                 ` Tim Chen
2018-05-17 20:53 SSB status - V18 pushed out Thomas Gleixner
2018-05-18 13:54 ` [MODERATED] Is: Sleep states ?Was:Re: " Konrad Rzeszutek Wilk
2018-05-18 14:29   ` Thomas Gleixner
2018-05-18 19:50     ` [MODERATED] Encrypted Message Tim Chen
2018-05-02 21:51 [patch V11 00/16] SSB 0 Thomas Gleixner
2018-05-03  4:27 ` [MODERATED] Encrypted Message Tim Chen
2018-04-24  9:06 [MODERATED] L1D-Fault KVM mitigation Joerg Roedel
2018-04-24  9:35 ` [MODERATED] " Peter Zijlstra
2018-04-24  9:48   ` David Woodhouse
2018-04-24 11:04     ` Peter Zijlstra
2018-05-23  9:45       ` David Woodhouse
2018-05-24  9:45         ` Peter Zijlstra
2018-05-24 15:04           ` Thomas Gleixner
2018-05-24 15:33             ` Thomas Gleixner
2018-05-24 23:18               ` [MODERATED] Encrypted Message Tim Chen
2018-05-25 18:22                 ` Tim Chen
2018-05-26 19:14                 ` L1D-Fault KVM mitigation Thomas Gleixner
2018-05-29 19:29                   ` [MODERATED] Encrypted Message Tim Chen
2018-05-29 21:14                     ` L1D-Fault KVM mitigation Thomas Gleixner
2018-05-30 16:38                       ` [MODERATED] Encrypted Message Tim Chen

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.