Re: [PATCH 3/5] x86/ibrs: Add direct access support for MSR_IA32_SPEC_CTRL

From: Peter Zijlstra
Date: Mon Jan 15 2018 - 09:46:08 EST


On Mon, Jan 15, 2018 at 02:59:22PM +0100, David Woodhouse wrote:
> #define IF_FEATURE(ftr) if (static_cpu_has(ftr)) arch_static_assert, 
>
>    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.

Something like:

#define if_static_likely(_key) \
if (static_branch_likely(_key) && (arch_static_assert(), true))

should work I think. The thing about static_cpu_has() is that it doesn't
use jump_labels but alternatives. I could of course also construct an
assert for that, but it needs different things.