[MODERATED] Re: [patch V6 10/14] MDS basics 10
Borislav Petkov <[email protected]>
| Newsgroups | org.kernel.lore.historical-speck |
|---|---|
| Message-ID | <[email protected]> |
On Fri, Mar 01, 2019 at 10:47:48PM +0100, speck for Thomas Gleixner wrote: > Subject: [patch V6 10/14] x86/speculation/mds: Add mitigation control for MDS > From: Thomas Gleixner <[email protected]> > > Now that the mitigations are in place, add a command line parameter to > control the mitigation, a mitigation selector function and a SMT update > mechanism. > > This is the minimal straight forward initial implementation which just > provides an always on/off mode. The command line parameter is: > > mds=[full|off] > > This is consistent with the existing mitigations for other speculative > hardware vulnerabilities. > > The idle invocation is dynamically updated according to the SMT state of > the system similar to the dynamic update of the STIBP mitigation. The idle > mitigation is limited to CPUs which are only affected by MSBDS and not any > other variant, because the other variants cannot be mitigated on SMT > enabled systems. > > Signed-off-by: Thomas Gleixner <[email protected]> > --- > V5 --> V6: Make idle clearing depend on BUG_MSBDS_ONLY > V4 --> V5: Remove 'auto' > --- ... > @@ -617,6 +664,24 @@ static void update_indir_branch_cond(voi > static_branch_disable(&switch_to_cond_stibp); > } > > +/* 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, ... but we're not enabling the key when SMT on those is disabled, AFAICT. Or is that coming later? > so clearing the buffers on > + * idle would be a window dressing exercise. > + */ > + if (!boot_cpu_has(X86_BUG_MSBDS_ONLY)) if (!boot_cpu_has_bug > + return; > + > + if (sched_smt_active()) > + static_branch_enable(&mds_idle_clear); > + else > + static_branch_disable(&mds_idle_clear); > +} > + > void arch_smt_update(void) > { > /* Enhanced IBRS implies STIBP. No update required. */ > @@ -638,6 +703,9 @@ void arch_smt_update(void) > break; > } > > + if (mds_mitigation == MDS_MITIGATION_FULL) > + update_mds_branch_idle(); > + > mutex_unlock(&spec_ctrl_mutex); > } > > -- Regards/Gruss, Boris. SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) --