From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: speck@linutronix.de
Subject: [MODERATED] Re: [PATCH v2 5/8] MDSv2 7
Date: Wed, 12 Dec 2018 16:41:48 -0500 [thread overview]
Message-ID: <20181212214148.GS9077@char.us.oracle.com> (raw)
In-Reply-To: <86f7d711109a095f09a0a9cfd9ca5efeba04cb23.1544464266.git.ak@linux.intel.com>
On Mon, Dec 10, 2018 at 09:53:37AM -0800, speck for Andi Kleen wrote:
> From: Andi Kleen <ak@linux.intel.com>
> Subject: x86/speculation/mds: Add software sequences for older
> CPUs.
>
> On older CPUs before Broadwell clearing the CPU buffer with VERW is not
> available, so we implement software sequences. These can then be
> automatically patched in as needed.
>
> Support mitigation for Nehalem upto Broadwell. Broadwell strictly doesn't
> need it because it should have the microcode update for VERW, which
> is preferred.
>
> We add command line options to force the two different sequences,
> mainly for regression testing and if someone wants to test
> on pre Nehalem CPUs.
>
> Note to backporters: this patch requires eager FPU support.
>
> Note there is no Xeon Phi support so far.
>
> Signed-off-by: Andi Kleen <ak@linux.intel.com>
> ---
> .../admin-guide/kernel-parameters.txt | 10 ++
> arch/x86/include/asm/cpufeatures.h | 2 +
> arch/x86/kernel/cpu/bugs.c | 59 +++++++++-
> arch/x86/lib/Makefile | 1 +
> arch/x86/lib/clear_cpu.S | 107 ++++++++++++++++++
> 5 files changed, 176 insertions(+), 3 deletions(-)
> create mode 100644 arch/x86/lib/clear_cpu.S
>
> diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
> index 48891572e825..16e10f92f8dd 100644
> --- a/Documentation/admin-guide/kernel-parameters.txt
> +++ b/Documentation/admin-guide/kernel-parameters.txt
> @@ -2344,6 +2344,16 @@
> mds_disable [X86]
> Disable workarounds for Micro-architectural Data Sampling.
>
> + mds=swclear [X86]
> + Force using software sequence for clearing data that
> + could be exploited by Micro-architectural Data Sampling.
> + Normally automatically enabled when needed.
s/Normally//?
> +
> + mds=swclearhsw [X86]
> + Use Haswell/Broadwell specific sequence for clearing
> + data that could be exploited by Micro-architectural Data
> + Sampling. Normally automatically enabled when needed.
s/Normally//?
> +
> mem=nn[KMG] [KNL,BOOT] Force usage of a specific amount of memory
> Amount of memory to be used when the kernel is not able
> to see the whole system memory or for test.
> diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
> index 93fab3a1e046..110759334c88 100644
> --- a/arch/x86/include/asm/cpufeatures.h
> +++ b/arch/x86/include/asm/cpufeatures.h
> @@ -381,5 +381,7 @@
> #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_MDS_CLEAR_CPU X86_BUG(20) /* CPU needs call to clear_cpu on kernel exit/idle for MDS */
> +#define X86_BUG_MDS_CLEAR_CPU_HSW X86_BUG(21) /* CPU needs Haswell version of clear cpu */
Why do we want to expose these instead of just having 'MDS' be exposed as bug?
>
> #endif /* _ASM_X86_CPUFEATURES_H */
> diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
> index accab3279068..91619f7d90be 100644
> --- a/arch/x86/kernel/cpu/bugs.c
> +++ b/arch/x86/kernel/cpu/bugs.c
> @@ -31,6 +31,8 @@
> #include <asm/intel-family.h>
> #include <asm/e820/api.h>
> #include <asm/hypervisor.h>
> +#include <asm/hypervisor.h>
> +#include <asm/cpu_device_id.h>
>
> static void __init spectre_v2_select_mitigation(void);
> static void __init ssb_select_mitigation(void);
> @@ -1044,11 +1046,55 @@ early_param("l1tf", l1tf_cmdline);
>
> #undef pr_fmt
>
> +static const __initconst struct x86_cpu_id cpu_mds_clear_cpu[] = {
> + { X86_VENDOR_INTEL, 6, INTEL_FAM6_NEHALEM },
> + { X86_VENDOR_INTEL, 6, INTEL_FAM6_NEHALEM_G },
> + { X86_VENDOR_INTEL, 6, INTEL_FAM6_NEHALEM_EP },
> + { X86_VENDOR_INTEL, 6, INTEL_FAM6_NEHALEM_EX },
> + { X86_VENDOR_INTEL, 6, INTEL_FAM6_WESTMERE },
> + { X86_VENDOR_INTEL, 6, INTEL_FAM6_WESTMERE_EP },
> + { X86_VENDOR_INTEL, 6, INTEL_FAM6_WESTMERE_EX },
> + { X86_VENDOR_INTEL, 6, INTEL_FAM6_SANDYBRIDGE },
> + { X86_VENDOR_INTEL, 6, INTEL_FAM6_SANDYBRIDGE_X },
> + { X86_VENDOR_INTEL, 6, INTEL_FAM6_IVYBRIDGE },
> + { X86_VENDOR_INTEL, 6, INTEL_FAM6_IVYBRIDGE_X },
> + {}
> +};
> +
> +static const __initconst struct x86_cpu_id cpu_mds_clear_cpu_hsw[] = {
> + { X86_VENDOR_INTEL, 6, INTEL_FAM6_HASWELL_CORE },
> + { X86_VENDOR_INTEL, 6, INTEL_FAM6_HASWELL_X },
> + { X86_VENDOR_INTEL, 6, INTEL_FAM6_HASWELL_ULT },
> + { X86_VENDOR_INTEL, 6, INTEL_FAM6_HASWELL_GT3E },
> +
> + /* Have MB_CLEAR with microcode update, but list just in case: */
> + { X86_VENDOR_INTEL, 6, INTEL_FAM6_BROADWELL_CORE },
> + { X86_VENDOR_INTEL, 6, INTEL_FAM6_BROADWELL_GT3E },
> + { X86_VENDOR_INTEL, 6, INTEL_FAM6_BROADWELL_X },
> + { X86_VENDOR_INTEL, 6, INTEL_FAM6_BROADWELL_XEON_D },
> + {}
> +};
> +
> static void mds_select_mitigation(void)
> {
> if (cmdline_find_option_bool(boot_command_line, "mds_disable") ||
> - !boot_cpu_has_bug(X86_BUG_MDS))
> + !boot_cpu_has_bug(X86_BUG_MDS)) {
> setup_clear_cpu_cap(X86_FEATURE_MB_CLEAR);
> + setup_clear_cpu_cap(X86_BUG_MDS_CLEAR_CPU_HSW);
> + setup_clear_cpu_cap(X86_BUG_MDS_CLEAR_CPU);
> + return;
> + }
> +
> + if ((!boot_cpu_has(X86_FEATURE_MB_CLEAR) &&
> + x86_match_cpu(cpu_mds_clear_cpu)) ||
> + cmdline_find_option_bool(boot_command_line, "mds=swclear"))
> + setup_force_cpu_cap(X86_BUG_MDS_CLEAR_CPU);
> + if ((!boot_cpu_has(X86_FEATURE_MB_CLEAR) &&
> + x86_match_cpu(cpu_mds_clear_cpu_hsw)) ||
> + cmdline_find_option_bool(boot_command_line, "mds=swclearhsw")) {
> + setup_force_cpu_cap(X86_BUG_MDS_CLEAR_CPU);
> + setup_force_cpu_cap(X86_BUG_MDS_CLEAR_CPU_HSW);
> + }
This all seems scream using loops and array to probe the 'swclear','swclearhsw,'off', etc?
next prev parent reply other threads:[~2018-12-12 21:41 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-10 17:53 [MODERATED] [PATCH v2 0/8] MDSv2 8 Andi Kleen
2018-12-10 17:53 ` [MODERATED] [PATCH v2 1/8] MDSv2 4 Andi Kleen
2018-12-11 14:14 ` [MODERATED] " Paolo Bonzini
2018-12-12 21:22 ` Konrad Rzeszutek Wilk
2018-12-12 21:28 ` Andi Kleen
2018-12-12 21:25 ` Konrad Rzeszutek Wilk
2018-12-10 17:53 ` [MODERATED] [PATCH v2 2/8] MDSv2 1 Andi Kleen
2018-12-10 22:49 ` [MODERATED] " Jiri Kosina
2018-12-11 0:03 ` Andi Kleen
2018-12-11 0:13 ` Kanth Ghatraju
2018-12-11 2:00 ` Andi Kleen
2018-12-11 5:36 ` Jiri Kosina
2018-12-11 10:03 ` Borislav Petkov
2018-12-12 21:31 ` Konrad Rzeszutek Wilk
2018-12-12 21:43 ` Andi Kleen
2018-12-12 22:17 ` Borislav Petkov
2018-12-12 22:40 ` Konrad Rzeszutek Wilk
2018-12-12 22:45 ` Borislav Petkov
2018-12-13 15:15 ` Andrew Cooper
2018-12-13 16:52 ` Borislav Petkov
2018-12-10 17:53 ` [MODERATED] [PATCH v2 3/8] MDSv2 5 Andi Kleen
2018-12-10 23:00 ` [MODERATED] " Linus Torvalds
2018-12-11 0:03 ` Andi Kleen
2018-12-11 0:43 ` Linus Torvalds
2018-12-11 1:33 ` Linus Torvalds
2018-12-11 2:12 ` Andi Kleen
2018-12-11 2:20 ` Linus Torvalds
2018-12-11 3:25 ` Andi Kleen
2018-12-11 17:55 ` Linus Torvalds
2018-12-11 18:10 ` Borislav Petkov
2018-12-11 18:21 ` Linus Torvalds
2018-12-11 18:26 ` Borislav Petkov
2018-12-11 19:47 ` Andi Kleen
2018-12-11 21:22 ` Thomas Gleixner
2018-12-12 14:02 ` [MODERATED] " Paolo Bonzini
2018-12-12 17:58 ` Andi Kleen
2018-12-12 18:47 ` Linus Torvalds
2018-12-13 19:44 ` Linus Torvalds
2018-12-13 20:48 ` Andi Kleen
2018-12-13 20:56 ` Linus Torvalds
2018-12-15 0:30 ` Andi Kleen
2018-12-11 2:10 ` Andi Kleen
2018-12-11 0:09 ` Andrew Cooper
2018-12-10 17:53 ` [MODERATED] [PATCH v2 4/8] MDSv2 0 Andi Kleen
2018-12-12 21:45 ` [MODERATED] " Konrad Rzeszutek Wilk
2018-12-12 22:09 ` Andi Kleen
2018-12-12 22:36 ` Konrad Rzeszutek Wilk
2018-12-10 17:53 ` [MODERATED] [PATCH v2 5/8] MDSv2 7 Andi Kleen
2018-12-11 0:33 ` [MODERATED] " Andrew Cooper
2018-12-12 18:05 ` Andrew Cooper
2018-12-12 21:41 ` Konrad Rzeszutek Wilk [this message]
2018-12-12 22:12 ` Andi Kleen
2018-12-10 17:53 ` [MODERATED] [PATCH v2 6/8] MDSv2 3 Andi Kleen
2018-12-11 0:37 ` [MODERATED] " Andrew Cooper
2018-12-11 0:46 ` Luck, Tony
2018-12-11 1:02 ` Andrew Cooper
2018-12-11 1:53 ` Andi Kleen
2018-12-10 17:53 ` [MODERATED] [PATCH v2 7/8] MDSv2 6 Andi Kleen
2018-12-10 17:53 ` [MODERATED] [PATCH v2 8/8] MDSv2 2 Andi Kleen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181212214148.GS9077@char.us.oracle.com \
--to=konrad.wilk@oracle.com \
--cc=speck@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.