[SRU][Xenial][PATCH v2 2/4] UBUNTU: SAUCE: x86/speculation: Cleanup IBRS runtime control handling
Juerg Haefliger
juerg.haefliger at canonical.com
Thu Jan 10 13:12:16 UTC 2019
> > +int set_ibrs_enabled(unsigned int val)
> > +{
> > + int error = 0;
> > + unsigned int cpu;
> > + unsigned int prev = ibrs_enabled;
> > +
> > + mutex_lock(&spec_ctrl_mutex);
> > +
> > + /* Only enable/disable IBRS if the CPU supports it */
> > + if (boot_cpu_has(X86_FEATURE_USE_IBRS_FW)) {
> > + ibrs_enabled = val;
> > + if (ibrs_enabled != prev)
> > + pr_info("Spectre V2 : Spectre v2 mitigation: %s "
> > + "Indirect Branch Restricted Speculation%s\n",
> > + ibrs_enabled ? "Enabling" : "Disabling",
> > + ibrs_enabled == 2 ? " (user space)" : "");
> > +
> > + if (ibrs_enabled == 0) {
> > + /* Always disable IBRS */
> > + u64 val = x86_spec_ctrl_base;
> > +
> > + for_each_online_cpu(cpu)
> > + wrmsrl_on_cpu(cpu, MSR_IA32_SPEC_CTRL, val);
>
> We don't need to handle here the case ibrs_enabled == 1?
No. == 1 means IBRS is temporarily turned on when we enter the kernel and turned
back off again when we leave it, so it's not sticky. Whereas == 0 means always
off (sticky) and == 2 is always on (also sticky).
...Juerg
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.ubuntu.com/archives/kernel-team/attachments/20190110/863870d1/attachment.sig>
More information about the kernel-team
mailing list