fix a bug in emitting the 16-bit immediate operand of AND
Subsystems (5)
PATCH 1/1 fix a bug in emitting the 16-bit immediate operand of AND
When K >= 0xFFFF0000, AND needs the two least significant bytes of K as its operand, but EMIT2() gives it the least significant byte of K and 0x2. EMIT() should be used here to replace EMIT2().
--- arch/x86/net/bpf_jit_comp.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/net/bpf_jit_comp.c +1 -1
@@ -289,7 +289,7 @@ void bpf_jit_compile(struct sk_filter *fp)EMIT2 (0x24 ,K &0xFF );/* and imm8,%al */ }else if (K >=0xFFFF0000 ) {EMIT2 (0x66 ,0x25 );/* and imm16,%ax */ -EMIT2 (K ,2 ); +EMIT (K ,2 ); }else {EMIT1_off32 (0x25 ,K );/* and imm32,%eax */ }
Signature · 1 line
1.7.5.4
Quoted 14 lines · Le jeudi 29 mars 2012 à 17:27 +0800, [email protected] a écrit :
When K >=
0xFFFF0000, AND needs the two least significant bytes of K as its operand, butEMIT2()gives it the least significant byte of K and0x2.EMIT()should be used here to replaceEMIT2().Signed-off-by Feiran Zhuang <[email protected]>--- arch/x86/net/bpf_jit_comp.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)arch/x86/net/bpf_jit_comp.c +0
-0
arch/x86/net/bpf_jit_comp.c void bpf_jit_compile(struct sk_filter *fp) · line 295
Quoted 8 lines
arch/x86/net/bpf_jit_comp.c +1
-1@@ -289,7 +289,7 @@ void bpf_jit_compile(struct sk_filter *fp)EMIT2 (0x24 ,K &0xFF );/* and imm8,%al */ }else if (K >=0xFFFF0000 ) {EMIT2 (0x66 ,0x25 );/* and imm16,%ax */ -EMIT2 (K ,2 ); +EMIT (K ,2 ); }else {EMIT1_off32 (0x25 ,K );/* and imm32,%eax */ }
Good catch, thanks !
From: Eric Dumazet <[email protected]>
Date: Thu, 29 Mar 2012 13:45:25 +0200
Quoted 26 lines · Le jeudi 29 mars 2012 à 17:27 +0800, [email protected] a écrit :
Quoted 14 lines
When K >=
0xFFFF0000, AND needs the two least significant bytes of K as its operand, butEMIT2()gives it the least significant byte of K and0x2.EMIT()should be used here to replaceEMIT2().Signed-off-by Feiran Zhuang <[email protected]>--- arch/x86/net/bpf_jit_comp.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)arch/x86/net/bpf_jit_comp.c +0
-0arch/x86/net/bpf_jit_comp.c void bpf_jit_compile(struct sk_filter *fp) · line 295
Quoted 8 lines
arch/x86/net/bpf_jit_comp.c +1
-1@@ -289,7 +289,7 @@ void bpf_jit_compile(struct sk_filter *fp)EMIT2 (0x24 ,K &0xFF );/* and imm8,%al */ }else if (K >=0xFFFF0000 ) {EMIT2 (0x66 ,0x25 );/* and imm16,%ax */ -EMIT2 (K ,2 ); +EMIT (K ,2 ); }else {EMIT1_off32 (0x25 ,K );/* and imm32,%eax */ }Good catch, thanks !
Quoted 1 line
Acked-by Eric Dumazet <[email protected]>
Applied.