aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sparc')
-rw-r--r--arch/sparc/net/bpf_jit_comp.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/arch/sparc/net/bpf_jit_comp.c b/arch/sparc/net/bpf_jit_comp.c
index 218b6b23c378..01fe9946d388 100644
--- a/arch/sparc/net/bpf_jit_comp.c
+++ b/arch/sparc/net/bpf_jit_comp.c
@@ -497,9 +497,20 @@ void bpf_jit_compile(struct sk_filter *fp)
497 case BPF_S_ALU_MUL_K: /* A *= K */ 497 case BPF_S_ALU_MUL_K: /* A *= K */
498 emit_alu_K(MUL, K); 498 emit_alu_K(MUL, K);
499 break; 499 break;
500 case BPF_S_ALU_DIV_K: /* A /= K */ 500 case BPF_S_ALU_DIV_K: /* A /= K with K != 0*/
501 emit_alu_K(MUL, K); 501 if (K == 1)
502 emit_read_y(r_A); 502 break;
503 emit_write_y(G0);
504#ifdef CONFIG_SPARC32
505 /* The Sparc v8 architecture requires
506 * three instructions between a %y
507 * register write and the first use.
508 */
509 emit_nop();
510 emit_nop();
511 emit_nop();
512#endif
513 emit_alu_K(DIV, K);
503 break; 514 break;
504 case BPF_S_ALU_DIV_X: /* A /= X; */ 515 case BPF_S_ALU_DIV_X: /* A /= X; */
505 emit_cmpi(r_X, 0); 516 emit_cmpi(r_X, 0);