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

From
Jiri Olsa <hidden>
Date
2026-11-12 18:33:55
Also in
bpf, lkml
Reply to
Peter Zijlstra, 2026-11-12
On Thu, Nov 12, 2026 at 09:39:45AM +0100, Peter Zijlstra wrote:
On Mon, Nov 09, 2026 at 08:49:06PM +0100, Jiri Olsa wrote:
quoted
 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.
nope.. you're right, I'll make it explicit

thanks,
jirka
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