Skip to content

RFC Variable size jump_label support

Peter Zijlstra live-patching lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest9 patches 3 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9jump_label, x86: Strip ASM jump_label supportarch/x86/entry/calling.h arch/x86/include/asm/jump_label.h+5 -250 replies
2/9jump_label, x86: Factor out the __jump_table generationarch/x86/include/asm/jump_label.h+12 -120 replies
3/9jump_label, x86: Remove init NOP optimizationarch/x86/kernel/jump_label.c+4 -150 replies
4/9jump_label, x86: Improve error when we fail expected textarch/x86/kernel/jump_label.c+10 -130 replies
5/9jump_label, x86: Introduce jump_entry_size()arch/x86/include/asm/jump_label.h arch/x86/kernel/jump_label.c include/linux/jump_label.h +1 more+17 -30 replies
6/9jump_label, x86: Add variable length patching supportarch/x86/include/asm/jump_label.h arch/x86/include/asm/nops.h arch/x86/kernel/jump_label.c+45 -240 replies
7/9jump_label,objtool: Validate variable size jump labelstools/objtool/check.c+25 -10 replies
8/9jump_label,objtool: Generate possible statisticstools/objtool/check.c+41 -20 replies
9/9jump_label, x86: Enable JMP8/NOP2 supportarch/x86/Kconfig arch/x86/include/asm/jump_label.h arch/x86/kernel/jump_label.c+62 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC][PATCH 0/9] Variable size jump_label support

These here patches are something I've been poking at for a while, enabling jump_label to use 2 byte jumps/nops.

It _almost_ works :-/

That is, you can build some kernels with it (x86_64-defconfig for example works just fine).

The problem comes when GCC generates a branch into another section, mostly .text.unlikely. At that point GAS just gives up and throws a fit (more details in the last patch).

Aside from anyone coming up with a really clever GAS trick, I don't see how we can do this other than:

- get binutils/gas 'fixed', for this there's two possible approaches:

* add some extra operators such that something like:

.set disp %[l_yes] ~ 1b ? (%[l_yes] - (1b + 2)) : 128

works, where the new '~' infix operator would indicate left and right hand operands are from the same section, and the ?: conditional operator would be added to make it all work.

* add a 'fake' mnemonic for x86 that directly generates the right NOP:

nojmp{.d8,d32} %target

which would completely mirror how the existing 'jmp{.d8,d32} %target' works, except it would emit single instruction NOP2/NOP5.

- use 'jmp' and get objtool to rewrite the text. Steven has earlier proposed something like that (using recordmcount) and Linus hated that.