On Mon, 2018-01-15 at 14:45 +0100, Peter Zijlstra wrote: > On Fri, Jan 12, 2018 at 10:09:08AM +0000, David Woodhouse wrote: > > static_cpu_has() + asm-goto is NOT SUFFICIENT. > > > > It's still *possible* for a missed optimisation in GCC to still leave > > us with a conditional branch around the wrmsr, letting the CPU > > speculate around it too. > > OK, so GCC would have to be bloody retarded to mess this up;
Like *that's* never happened before? In corner cases where it just gets confused and certain optimisations go out the window? > but would something like the below work for you? > > The usage is like: > > if (static_branch_unlikely(key)) { > arch_static_assert(); > stuff(); > } > > And then objtool will fail things if the first instruction into that > branch is not immediately after a NOP/JMP patch site (on either the NOP > or the JMP+disp side of things). That seems reasonable; thanks. Bonus points if you can make the arch_static_assert happen() automatically with vile tricks like #define IF_FEATURE(ftr) if (static_cpu_has(ftr)) arch_static_assert, So then it just becomes IF_FEATURE(key) { stuff(); } There might not be a sane way to do that though. And it's OK to have to manually annotate the call sites where this is for correctness and not purely optimisation.
smime.p7s
Description: S/MIME cryptographic signature