<div dir="ltr">IBRS in mode 2 (i.e. always leaving it on) results in a 30%+ performance hit to everything, at least on older cpus. This is not a complete mitigation either, it's really just a bad microcode hack by Intel that nobody really wants to have to turn on.<div><br></div><div>IBRS in mode 1 (i.e. just during kernel execution and not during user execution) will significantly impact anything that uses the kernel heavily, such as the network stack. This mode will not protect against the most common like Spectre attack (which is a javascript attack against the browser it is running it).<br><div><br></div><div>RetPoline is only a partial mitigation.</div><div><br></div><div>MMU isolation + IBRS mode 2 increases system call overhead to over 800nS.</div><div><br></div><div>--</div><div><br></div><div>In terms of DragonFlyBSD, MMU isolation is now built into master. IBRS and RetPoline are not, yet. I'm still evaluating them, and in fact for IBRS (aka Spectre Attacks) it isn't just Intel, but AMD is also doing a microcode update and I have no information on their implementation yet. It is possible to run DragonFlyBSD with mode 2 IBRS right now by installing the appropriate microcode update from Intel using cpucontrol, and turn IBRS on with cpucontrol MSR ops. But my recommendation is that people not try to shortcut Specter protections... wait until we finish evaluating it and get something in the system.</div><div><br></div><div>I'll be honest... I personally do not think there is a viable protection against Spectre possible on Intel, even with the microcode IBRS stuff. Turning on the best possible mitigation (IBRS mode 2) destroys the performance of the machine across all applications and use cases. If you want to play with IBRS mode 2:</div><div><br></div><div>* I found a microcode archive at <a href="https://launchpad.net/ubuntu/+source/intel-microcode/3.20171215.1">https://launchpad.net/ubuntu/+source/intel-microcode/3.20171215.1</a> (I don't know if it is the latest one)</div><div><br></div><div>kldload cpuctl</div><div>pkg install devcpu-data</div><div><br></div><div>unpack the tar archive and move the *.fw files into /usr/local/share/cpucontrol/</div><div><br></div><div>See if you can apply the microcode updates:</div><div><br></div><div><div>cpucontrol -u /dev/cpuctl0</div><div>cpucontrol -u /dev/cpuctl1</div><div>cpucontrol -u /dev/cpuctl2</div><div>cpucontrol -u /dev/cpuctl3</div></div><div>... for all cpu cores (hyperthreads will be ignored)</div><div><br></div><div>See if there is IBRS support:</div><div><br></div><div><div>test40# cpucontrol -i 7,0 /dev/cpuctl0 (BEFORE MICROCODE UPDATE)</div><div>cpuid level 0x7, level_type 0x0: 0x00000000 blah 0x00000000 0x00000000</div><div><br></div><div><div>test40# cpucontrol -i 7,0 /dev/cpuctl0 (AFTER MICROCODE UPDATE)</div></div><div>cpuid level 0x7, level_type 0x0: 0x00000000 blah 0x00000000 0x0c000000<br></div></div><div><br></div><div>If you get the 0C in the last word, there is IBRS support. You can try turning it on with cpucontrol.</div><div><br></div><div><br></div><div><div>cpucontrol -m 48=1 /dev/cpuctl0</div></div><div> .... do for all cpus ...</div><div><br></div><div>That is 95% of IBRS mode 2. But be prepared for a performance implosion. Also, Intel might not have a microcode update for whatever cpu you are on yet (or ever).</div><div><br></div><div><div>-Matt</div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jan 7, 2018 at 5:23 AM, my123 (@never_released) <span dir="ltr"><<a href="mailto:securetalk@sbmobilepilot.onmicrosoft.com" target="_blank">securetalk@sbmobilepilot.onmicrosoft.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
The kernel is protected against Spectre with retpoline but application-specific patches are required except when IBPB=2 + STIBP, IBRS=1 + IBPB=1, or IBRS=2 are used.<br>
<br>
IBPB is a branch prediction barrier that solves Spectre on its maximum setting, but it comes with a performance hit. It requires enabling STIBP for full protection too, except when hyperthreading is disabled.<br>
<br>
IBRS is the restricted indirect branch speculation feature, which solves Spectre on its maximum setting, except for VM isolation but requires a performance hit too. In order to protect virtual machines from other virtual machines, ibpb=1 is needed even if ibrs is set to 2..<br>
<br>
IBPB=1 *and* IBRS=1 works too but it causes a performance hit, and IBRS=2 + IBPB=1 is needed for isolation between virtual machines, but isn't required when VMs aren't used.<br>
<br>
AMD implements IBRS and IBPB for CPU families before 17h (Zen), but only IBPB and STIBP for Zen.<br>
<br>
All those features require newer microcode to work... and the impact on performance is not zero.<br>
<br>
The alternative is recompiling every sensitive thing with retpoline... which is what Linux is trying to implement on mainline. On Windows, as convincing developers to update their toolchain is hard there, IBRS and IBPB are used there despite the performance hit.<br>
<br>
Hoping that I made things a bit clearer...<br>
<br>
</blockquote></div><br></div>