mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
To: Breno Leitao <leitao@debian.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Josh Poimboeuf <jpoimboe@kernel.org>,
	leit@fb.com,
	"open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)" 
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] x86/bugs: Break down mitigations configurations
Date: Tue, 27 Jun 2023 15:30:40 -0700	[thread overview]
Message-ID: <20230627223040.bjacsmaotlderpdu@desk> (raw)
In-Reply-To: <ZJseCvXVKFHu84Sv@gmail.com>

On Tue, Jun 27, 2023 at 10:36:10AM -0700, Breno Leitao wrote:
> Hello Pawan,
> 
> On Wed, Jun 21, 2023 at 12:41:01PM -0700, Pawan Gupta wrote:
> > On Wed, Jun 21, 2023 at 11:36:53AM -0700, Breno Leitao wrote:
> > > If I understand where you want to go, you think we should create a
> > > single patchset that creates a CONFIG_<MITIGATION> for each mitigation,
> > > and move get it under CONFIG_SPECULATION_MITIGATIONS.
> > 
> > Yes, a single series (or a patch) that adds config for each mitigation
> > would be good.
> 
> I've been working on this request, and I may need your help to validate
> the wordings and dependencies (as in architecture/vendors where the
> problem needs to be mitigations) for each entry.

Kconfig text looks fine to me. (Some comments on arch/vendor dependency
are down below).

> Also, I want to make sure I am not missing anything. Here is what I have
> so far. Is it in the right direction?
> 
> --
> Author: Breno Leitao <leitao@debian.org>
> Date:   Thu Jun 15 08:04:16 2023 -0700
> 
>     x86/bugs: Break down mitigations configurations

How about this?

x86/bugs: Add a separate config for each mitigation

>     Create an entry for each CPU mitigation under
>     CONFIG_SPECULATION_MITIGATIONS. This allow users to enable or disable
>     them at compilation time.
>     
>     If a mitigation is disabled at compilation time, it could be enabled at
>     runtime using kernel command line arguments.
>     
>     Signed-off-by: Breno Leitao <leitao@debian.org>
> 
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index 53bab123a8ee..10ea7884eddd 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -2649,6 +2649,100 @@ config SLS
>  	  against straight line speculation. The kernel image might be slightly
>  	  larger.
>  
> +config MITIGATE_MDS
> +	bool "Mitigate Microarchitectural Data Sampling (MDS) hardware bug"
> +	depends on CPU_SUP_INTEL && X86_64

Architecture/vendor dependency is resolved at runtime during bug
enumeration (using CPU family/model). I don't think there is a need to
add explicit dependency here unless it creates runtime issues. And for
these configs it doesn't.

MDS and some of the other mitigations works for 32-bit kernel as well.
Dependency on X86_64 here is not correct, it makes 32-bit systems
vulnerable.

> +	default y
> +	help
> +	  Enable mitigation for Microarchitectural Data Sampling (MDS). MDS is
> +	  a hardware vulnerability which allows unprivileged speculative access
> +	  to data which is available in various CPU internal buffer. Deeper
> +	  technical information is available in the MDS specific x86 architecture
> +	  section: Documentation/arch/x86/mds.rst.
> +
> +config MITIGATE_TAA
> +	bool "Mitigate TSX Asynchronous Abort (TAA) hardware bug"
> +	depends on CPU_SUP_INTEL && X86_64

Ditto.

> +	default y
> +	help
> +	  Enable mitigation for TSX Asynchronous Abort (TAA). TAA is a hardware
> +	  vulnerability that allows unprivileged speculative access to data
> +	  which is available in various CPU internal buffers by using
> +	  asynchronous aborts within an Intel TSX transactional region.
> +
> +config MITIGATE_MMIO_STALE_DATA
> +	bool "Mitigate MMIO Stale Data hardware bug"
> +	depends on CPU_SUP_INTEL && X86_64

Ditto for and all the others.

[...]
> @@ -1286,7 +1316,7 @@ static enum spectre_v2_mitigation_cmd __init spectre_v2_parse_cmdline(void)
>  
>  	ret = cmdline_find_option(boot_command_line, "spectre_v2", arg, sizeof(arg));
>  	if (ret < 0)
> -		return SPECTRE_V2_CMD_AUTO;
> +		return cmd;

In the same function, below code also needs to return the compile time
default:

        if (i >= ARRAY_SIZE(mitigation_options)) {
                pr_err("unknown option (%s). Switching to AUTO select\n", arg);
                return SPECTRE_V2_CMD_AUTO;
        }

[...]
> @@ -2119,7 +2153,12 @@ EXPORT_SYMBOL_GPL(itlb_multihit_kvm_mitigation);
>  #define pr_fmt(fmt)	"L1TF: " fmt
>  
>  /* Default mitigation for L1TF-affected CPUs */
> +

Extra newline.

> +#if IS_ENABLED(CONFIG_MITIGATE_L1TF)
>  enum l1tf_mitigations l1tf_mitigation __ro_after_init = L1TF_MITIGATION_FLUSH;
> +#else
> +enum l1tf_mitigations l1tf_mitigation __ro_after_init = L1TF_MITIGATION_OFF;
> +#endif
>  #if IS_ENABLED(CONFIG_KVM_INTEL)
>  EXPORT_SYMBOL_GPL(l1tf_mitigation);
>  #endif

  reply	other threads:[~2023-06-27 22:30 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-16 16:48 Breno Leitao
2023-06-21  0:13 ` Pawan Gupta
2023-06-21 15:54   ` Breno Leitao
2023-06-21 17:31     ` Pawan Gupta
2023-06-21 18:36       ` Breno Leitao
2023-06-21 19:41         ` Pawan Gupta
2023-06-21 22:35           ` Dave Hansen
2023-06-21 22:52             ` Breno Leitao
2023-06-21 22:58               ` Dave Hansen
2023-06-22 12:42                 ` Borislav Petkov
2023-06-22 13:42                   ` Dave Hansen
2023-06-27 17:36           ` Breno Leitao
2023-06-27 22:30             ` Pawan Gupta [this message]
2023-06-28  9:15               ` Breno Leitao

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=20230627223040.bjacsmaotlderpdu@desk \
    --to=pawan.kumar.gupta@linux.intel.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jpoimboe@kernel.org \
    --cc=leit@fb.com \
    --cc=leitao@debian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®