[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180115172212.nw5dqjrztqtfyist@treble>
Date: Mon, 15 Jan 2018 11:22:12 -0600
From: Josh Poimboeuf <jpoimboe@...hat.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: David Woodhouse <dwmw2@...radead.org>,
linux-kernel@...r.kernel.org, Dave Hansen <dave.hansen@...el.com>,
Ashok Raj <ashok.raj@...el.com>,
Thomas Gleixner <tglx@...utronix.de>,
Tim Chen <tim.c.chen@...ux.intel.com>,
Andy Lutomirski <luto@...nel.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Greg KH <gregkh@...uxfoundation.org>,
Andrea Arcangeli <aarcange@...hat.com>,
Andi Kleen <ak@...ux.intel.com>,
Arjan Van De Ven <arjan.van.de.ven@...el.com>,
Dan Williams <dan.j.williams@...el.com>,
Paolo Bonzini <pbonzini@...hat.com>,
Jun Nakajima <jun.nakajima@...el.com>,
Asit Mallick <asit.k.mallick@...el.com>,
Borislav Petkov <bp@...en8.de>
Subject: Re: [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@...hat.com>
> Cc: Thomas Gleixner <tglx@...utronix.de>
> Cc: Borislav Petkov <bp@...en8.de>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.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"
> + _ASM_ALIGN "\n\t"
> + _ASM_PTR "1b \n\t"
> + ".popsection \n\t");
> +}
> +
This needs a nice comment about what exactly it asserts.
And also, people without objtool enabled (i.e., no ORC or livepatch)
won't see the assertion. Do we care about those people? :-)
--
Josh
Powered by blists - more mailing lists