lkml.org 
[lkml]   [2018]   [Jan]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 3/4] x86/jump_label: Implement arch_static_assert()
On Mon, Jan 15, 2018 at 05:44:31PM +0100, Peter Zijlstra wrote:
> Implement the static (branch) assertion. It simply emits the address
> of the next instruction into a special section which objtool will read
> and validate against either __jump_table or .altinstructions.
>
> Use like:
>
> if (static_branch_likely(_key)) {
> arch_static_assert();
> /* do stuff */
> }
>
> Or
>
> if (static_cpu_has(_feat)) {
> arch_static_assert();
> /* do stuff */
> }
>
> Cc: Josh Poimboeuf <jpoimboe@redhat.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Borislav Petkov <bp@alien8.de>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> ---
> arch/x86/include/asm/jump_label.h | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> --- a/arch/x86/include/asm/jump_label.h
> +++ b/arch/x86/include/asm/jump_label.h
> @@ -62,6 +62,15 @@ static __always_inline bool arch_static_
> return true;
> }
>
> +static __always_inline void arch_static_assert(void)
> +{
> + asm volatile ("1:\n\t"
> + ".pushsection .discard.jump_assert, \"aw\" \n\t"

The "aw" flags aren't needed, the section is neither allocatable nor
writable.

--
Josh

\
 
 \ /
  Last update: 2018-01-15 19:29    [W:0.094 / U:0.516 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site