Skip to contentSkip to conversation

x86: bpf_jit: support negative offsets

PATCH In review Alexei Starovoitov 4 participants 4 messages Mar 10, 2014 – Mar 12, 2014

Subsystems (5)
Networking Network drivers x86 BPF +1 more subsystems
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: bpf_jit: support negative offsets

Commit a998d4342337 claimed to introduce negative offset support to x86 jit, but it couldn't be working, since at the time of the execution of LD+ABS or LD+IND instructions via call into bpf_internal_load_pointer_neg_helper() the %edx (3rd argument of this func) had junk value instead of access size in bytes (1 or 2 or 4).

Store size into %edx instead of %ecx (what original commit intended to do)

Fixes a998d4342337 ("bpf jit: Let the x86 jit handle negative offsets")
Cc Jan Seiffert <[email protected]>
Cc Eric Dumazet <[email protected]>

--
This is a single bit patch. Is there a leaderboard of shortest patches? ;)

 arch/x86/net/bpf_jit.S |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/net/bpf_jit.S +1 -1
index 877b9a1..0149575 100644
@@ -140,7 +140,7 @@ bpf_slow_path_byte_msh:
 	push	%r9;						\
 	push	SKBDATA;					\
 /* rsi already has offset */					\
-	mov	$SIZE,%ecx;	/* size */			\
+	mov	$SIZE,%edx;	/* size */			\
 	call	bpf_internal_load_pointer_neg_helper;		\
 	test	%rax,%rax;					\
 	pop	SKBDATA;					\
Signature · 1 line
1.7.9.5
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Alexei Starovoitov

Commit a998d4342337 claimed to introduce negative offset support to x86 jit, but it couldn't be working, since at the time of the execution of LD+ABS or LD+IND instructions via call into bpf_internal_load_pointer_neg_helper() the %edx (3rd argument of this func) had junk value instead of access size in bytes (1 or 2 or 4).

Quoted 8 lines

Store size into %edx instead of %ecx (what original commit intended to do)

Fixes a998d4342337 ("bpf jit: Let the x86 jit handle negative offsets")
Cc Jan Seiffert <[email protected]>
Cc Eric Dumazet <[email protected]>

--
This is a single bit patch. Is there a leaderboard of shortest patches? ;)

Its actually a 1 byte or 3-bit patch ;)

'c' is 0x63, and 'd' is 0x64 ;)

#2 lore raw
In reply to Alexei Starovoitov

From: Alexei Starovoitov

Quoted 1 line

This is a single bit patch. Is there a leaderboard of shortest patches? ;)

The shortest patches will be the ones that invert a conditional branch. Unless the compiler reorders the code they will be 1-bit (on most archs). Since that is a common error, there will be a few of them.

Now a 1/2bit patch would be a challenge:-)

David

maintainer
#3 lore raw
In reply to Alexei Starovoitov

From: Alexei Starovoitov <[email protected]>
Date: Mon, 10 Mar 2014 15:56:51 -0700

Quoted 6 lines

Commit a998d4342337 claimed to introduce negative offset support to x86 jit, but it couldn't be working, since at the time of the execution of LD+ABS or LD+IND instructions via call into bpf_internal_load_pointer_neg_helper() the %edx (3rd argument of this func) had junk value instead of access size in bytes (1 or 2 or 4).

Quoted 6 lines

Store size into %edx instead of %ecx (what original commit intended to do)

Fixes a998d4342337 ("bpf jit: Let the x86 jit handle negative offsets")
Cc Jan Seiffert <[email protected]>
Cc Eric Dumazet <[email protected]>

Applied and queued up for -stable, thanks.