Re: [PATCH 03/13] jump_label/x86: Avoid decoding instructions for jump entry size

From
Peter Zijlstra <peterz@infradead.org>
Date
2026-11-12 08:39:50
Also in
bpf, lkml
Reply to
Jiri Olsa, 2026-11-09
On Mon, Nov 09, 2026 at 08:49:06PM +0100, Jiri Olsa wrote:
quoted hunk ↗ jump to hunk
 int arch_jump_entry_size(struct jump_entry *entry)
 {
+	const u8 *code = (void *)jump_entry_code(entry);
 
+	if (code[0] == JMP8_INSN_OPCODE ||
+	    !memcmp(code, x86_nops[JMP8_INSN_SIZE], JMP8_INSN_SIZE))
+		return JMP8_INSN_SIZE;
 
+	if (code[0] == JMP32_INSN_OPCODE ||
+	    !memcmp(code, x86_nops[JMP32_INSN_SIZE], JMP32_INSN_SIZE))
+		return JMP32_INSN_SIZE;
+
+	BUG();
 }
Does this actually generate sane code and checks code[0] first for both
values before it goes and does memcmp() ? The naive translation would
suggest it does not.
Thread (34 messages) 34 messages, 6 authors, last reply 4d ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help