Skip to content

jump_label, objtool, IBRS and IBPB

Peter Zijlstra lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest35 patches 29 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/35jump_label: Add branch hints to static_branch_{un,}likely()include/linux/jump_label.h+2 -20 replies
2/35sched: Optimize ttwu_stat()kernel/sched/core.c kernel/sched/stats.h+10 -80 replies
3/35x86: Reindent _static_cpu_hasarch/x86/include/asm/cpufeature.h+39 -390 replies
4/35x86: Update _static_cpu_has to use all named variablesarch/x86/include/asm/cpufeature.h+5 -40 replies
5/35x86: Add a type field to alt_instrarch/x86/include/asm/alternative-asm.h arch/x86/include/asm/alternative.h arch/x86/include/asm/cpufeature.h +1 more+10 -30 replies
6/35objtool: Implement base jump_assert supporttools/objtool/check.c tools/objtool/check.h+69 -20 replies
7/35x86: Annotate static_cpu_has alternativearch/x86/include/asm/alternative.h arch/x86/include/asm/cpufeature.h+4 -20 replies
8/35objtool: Implement jump_assert for _static_cpu_has()tools/objtool/check.c tools/objtool/special.c tools/objtool/special.h+37 -110 replies
9/35objtool: Introduce special_typetools/objtool/check.c tools/objtool/special.c tools/objtool/special.h+26 -120 replies
10/35x86/jump_label: Implement arch_static_assert()arch/x86/include/asm/jump_label.h+23 -00 replies
11/35objtool: Add retpoline validationscripts/Makefile.build tools/objtool/builtin-check.c tools/objtool/builtin-orc.c +2 more+98 -110 replies
12/35x86/paravirt: Annotate indirect callsarch/x86/include/asm/paravirt.h arch/x86/include/asm/paravirt_types.h+24 -50 replies
13/35x86,nospec: Annotate indirect calls/jumpsarch/x86/include/asm/nospec-branch.h+16 -40 replies
14/35x86: Annotate indirect jump in head_64.Sarch/x86/kernel/head_64.S+2 -00 replies
15/35objtool: More complex static jump implementationtools/objtool/check.c tools/objtool/check.h+42 -10 replies
16/35objtool: Use existing global variables for optionstools/objtool/builtin-check.c tools/objtool/builtin-orc.c tools/objtool/builtin.h +2 more+10 -110 replies
17/35objtool: Even more complex static block checkstools/objtool/check.c tools/objtool/elf.h+61 -210 replies
18/35objtool: Another static block failtools/objtool/check.c tools/objtool/check.h+33 -33 replies
19/35objtool: Skip static assert when KCOV/KASANscripts/Makefile.build tools/objtool/builtin-check.c tools/objtool/builtin.h +1 more+15 -20 replies
20/35x86: Force asm-gotoMakefile arch/x86/Makefile+11 -61 reply
21/35x86: Remove FAST_FEATURE_TESTSarch/x86/Kconfig arch/x86/include/asm/cpufeature.h+0 -190 replies
22/35x86/cpufeatures: Detect Speculation control featurearch/x86/include/asm/cpufeatures.h arch/x86/include/asm/msr-index.h arch/x86/kernel/cpu/scattered.c+7 -00 replies
23/35x86/speculation: Add basic speculation control codeDocumentation/admin-guide/kernel-parameters.txt arch/x86/include/asm/nospec-branch.h arch/x86/kernel/cpu/Makefile +2 more+64 -211 replies
24/35x86/msr: Move native_*msr macros out of microcode.harch/x86/include/asm/microcode.h arch/x86/include/asm/msr.h+18 -140 replies
25/35x86/speculation: Add inlines to control Indirect Branch Speculationarch/x86/include/asm/nospec-branch.h+12 -00 replies
26/35x86/enter: Create macros to stop/restart Indirect Branch Speculationarch/x86/entry/calling.h+73 -01 reply
27/35x86/enter: Use IBRS on syscall and interruptsarch/x86/entry/entry_64.S arch/x86/entry/entry_64_compat.S+53 -30 replies
28/35x86/idle: Control Indirect Branch Speculation in idlearch/x86/include/asm/mwait.h arch/x86/kernel/process.c+28 -01 reply
29/35x86/speculation: Add IPBP supportarch/x86/include/asm/cpufeatures.h arch/x86/include/asm/msr-index.h arch/x86/include/asm/nospec-branch.h +2 more+26 -14 replies
30/35x86/speculation: Use Indirect Branch Prediction Barrier in context switcharch/x86/mm/tlb.c+9 -13 replies
31/35x86/ibrs: Add new helper macros to save/restore MSR_IA32_SPEC_CTRLarch/x86/include/asm/nospec-branch.h+18 -00 replies
32/35x86/vmx: Direct access to MSR_IA32_SPEC_CTRLarch/x86/kvm/cpuid.c arch/x86/kvm/vmx.c arch/x86/kvm/x86.c+28 -10 replies
33/35x86/svm: Direct access to MSR_IA32_SPEC_CTRLarch/x86/kvm/svm.c+13 -00 replies
34/35x86/kvm: Add IBPB supportarch/x86/kvm/svm.c arch/x86/kvm/vmx.c+16 -05 replies
35/35x86/nospec: Add static assertionsarch/x86/include/asm/nospec-branch.h+15 -40 replies

Reviews trailers per patch

1 of 35 patches has a Reviewed-by or Acked-by.

PatchBorislav PetkovDavid WoodhouseJosh PoimboeufTim Chen
1/35
2/35
3/35R-b
4/35Requested-by
5/35
6/35
7/35
8/35
9/35
10/35
11/35Requested-by
12/35
13/35
14/35
15/35
16/35
17/35
18/35
19/35
20/35
21/35
22/35
23/35
24/35
25/35
26/35
27/35
28/35Originally-by
29/35
30/35
31/35
32/35
33/35
34/35
35/35

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v1 thread

Cover letter [PATCH 00/35] jump_label, objtool, IBRS and IBPB

Lots of patches..

They include:

- objtool validation of jump_label/static_cpu_has

Allows asserting that the code block following a jump_label/static_cpu_has is indeed unconditional. Ensures GCC doesn't generate particularly stupid code which would re-insert a dynamic test.

- objtool validation of retpoline

Looks for indirect JMP/CALL sites when build with a retpoline enabled compiler. Has already spotted a bunch of sites that need fixing, see below.

- makes x86 hard rely on asm-goto to ensure we can indeed use static_cpu_has to avoid dynamic branches (and thus speculation).

- The IBRS/IBPB patches from Thomas that use static_cpu_has()

These hard rely on the above; we must not speculate across the IBRS/IBPB MSR writes otherwise that would totally defeat the point. Prior patches had LFENCE crud in the else-clause, which then makes the primitives unconditionally expensive.

- Rebased the IBRS/IBPB-KVM patches from Ashok on top

- Random odd fixes for various things encountered while doing the above.

Please have a look and sorry for this many patches.

---

Output of a x86_64-allmodconfig -KCOV -KASAN build:

arch/x86/entry/.tmp_entry_64.o: warning: objtool: .entry.text+0x1cb2: indirect call found in RETPOLINE build arch/x86/entry/.tmp_entry_64.o: warning: objtool: .entry.text+0x1cc7: indirect call found in RETPOLINE build arch/x86/hyperv/.tmp_mmu.o: warning: objtool: hyperv_flush_tlb_others()+0x30c: indirect call found in RETPOLINE build arch/x86/hyperv/.tmp_mmu.o: warning: objtool: hyperv_flush_tlb_others()+0x3b0: indirect call found in RETPOLINE build arch/x86/hyperv/.tmp_mmu.o: warning: objtool: hyperv_flush_tlb_others_ex()+0x3a1: indirect call found in RETPOLINE build arch/x86/hyperv/.tmp_mmu.o: warning: objtool: hyperv_flush_tlb_others_ex()+0x45c: indirect call found in RETPOLINE build arch/x86/xen/.tmp_multicalls.o: warning: objtool: xen_mc_flush()+0x1da: indirect call found in RETPOLINE build arch/x86/kvm/.tmp_emulate.o: warning: objtool: fastop()+0x54: indirect call found in RETPOLINE build arch/x86/kvm/.tmp_emulate.o: warning: objtool: em_loop()+0xcc: indirect call found in RETPOLINE build arch/x86/kvm/.tmp_emulate.o: warning: objtool: x86_emulate_insn()+0xbd6: indirect call found in RETPOLINE build arch/x86/kvm/.tmp_emulate.o: warning: objtool: x86_emulate_insn()+0xc1a: indirect call found in RETPOLINE build arch/x86/kvm/.tmp_emulate.o: warning: objtool: x86_emulate_insn()+0xc66: indirect call found in RETPOLINE build arch/x86/kvm/.tmp_vmx.o: warning: objtool: vmx_handle_external_intr()+0x50: indirect call found in RETPOLINE build arch/x86/mm/.tmp_mem_encrypt_boot.o: warning: objtool: sme_encrypt_execute()+0x48: indirect call found in RETPOLINE build drivers/hv/.tmp_hv.o: warning: objtool: hv_post_message()+0x72: indirect call found in RETPOLINE build drivers/hv/.tmp_connection.o: warning: objtool: vmbus_set_event()+0x33: indirect call found in RETPOLINE build drivers/pci/host/.tmp_pci-hyperv.o: warning: objtool: hv_irq_unmask()+0x22b: indirect call found in RETPOLINE build drivers/xen/.tmp_privcmd.o: warning: objtool: privcmd_ioctl()+0xcf: indirect call found in RETPOLINE build drivers/watchdog/.tmp_hpwdt.o: warning: objtool: .text+0x24: indirect call found in RETPOLINE build