Re: [PATCH 2/3] x86: Sanity-check static_cpu_has usage

From: H. Peter Anvin
Date: Mon Apr 29 2013 - 11:39:23 EST


On 04/29/2013 07:04 AM, Borislav Petkov wrote:
> From: Borislav Petkov <bp@xxxxxxx>
>
> static_cpu_has may be used only after alternatives have run. Before that
> it always returns false if constant folding with __builtin_constant_p()
> doesn't happen. And you don't want that.
>
> This patch is the result of me debugging an issue where I overzealously
> put static_cpu_has in code which executed before alternatives have run
> and had to spend some time with scratching head and cursing at the
> monitor.
>
> So add a jump to a warning which screams loudly when we use this
> function too early. The alternatives patch that check away in
> conjunction with patching the rest of the kernel image.
>
> This first JMP the compiler then issues should always be a two-byte JMP
> because its relative offset fits in a byte. This gets replaced by only a
> two-byte NOP => less instruction cache bloat.
>

I still would prefer this to be an option.

-hpa


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/