Skip to content
Snippets Groups Projects
Commit 04147a20 authored by Waiman Long's avatar Waiman Long
Browse files

bpf,x86: Respect X86_FEATURE_RETPOLINE*

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2090231


Conflicts: X86_FEATURE_RETPOLINE_AMD is replaced by
	   X86_FEATURE_RETPOLINE_LFENCE due to the presence of a later
	   upstream commit d45476d9 ("x86/speculation: Rename
	   RETPOLINE_AMD to RETPOLINE_LFENCE").

commit 87c87ecd
Author: Peter Zijlstra <peterz@infradead.org>
Date:   Tue, 26 Oct 2021 14:01:48 +0200

    bpf,x86: Respect X86_FEATURE_RETPOLINE*

    Current BPF codegen doesn't respect X86_FEATURE_RETPOLINE* flags and
    unconditionally emits a thunk call, this is sub-optimal and doesn't
    match the regular, compiler generated, code.

    Update the i386 JIT to emit code equal to what the compiler emits for
    the regular kernel text (IOW. a plain THUNK call).

    Update the x86_64 JIT to emit code similar to the result of compiler
    and kernel rewrites as according to X86_FEATURE_RETPOLINE* flags.
    Inlining RETPOLINE_AMD (lfence; jmp *%reg) and !RETPOLINE (jmp *%reg),
    while doing a THUNK call for RETPOLINE.

    This removes the hard-coded retpoline thunks and shrinks the generated
    code. Leaving a single retpoline thunk definition in the kernel.

Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: default avatarBorislav Petkov <bp@suse.de>
Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
Acked-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
Tested-by: default avatarAlexei Starovoitov <ast@kernel.org>
    Link: https://lore.kernel.org/r/20211026120310.614772675@infradead.org



Signed-off-by: default avatarWaiman Long <longman@redhat.com>
parent da732c7d
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment