On Tue, Nov 10, 2020 at 9:00 AM Amir Naseredini via Gcc-help < gcc-help@xxxxxxxxxxx> wrote: > I was looking over the internet and am a bit confused about the > mitigations that are provided by the gcc compiler for different variants of > Spectre attack. So, I was wondering if there are any mitigations > implemented for Specter v1 (Spectre-PHT), v2 (Spectre-BTB), v4 > (Spectre-STL) and v5 (Spectre-RSB) at the compiler level for gcc? > Looking forward to hearing from you. > We have a builtin function __builtin_speculation_safe_value that you can use to protect from some of these attacks. Support varies depending on the target, but most of the popular targets will emit a special instruction sequence when this is used. The docs are in this page https://gcc.gnu.org/onlinedocs/gcc-10.2.0/gcc/Other-Builtins.html#Other-Builtins about 1/5 of the way down. Jim