@@ -510,20 +510,33 @@ int bpf_jit_build_body(struct bpf_prog *fp, u32 *image, u32 *fimage, struct code
510
510
case BPF_ALU | BPF_DIV | BPF_X : /* (u32) dst /= (u32) src */
511
511
case BPF_ALU | BPF_MOD | BPF_X : /* (u32) dst %= (u32) src */
512
512
if (BPF_OP (code ) == BPF_MOD ) {
513
- EMIT (PPC_RAW_DIVWU (tmp1_reg , dst_reg , src_reg ));
513
+ if (off )
514
+ EMIT (PPC_RAW_DIVW (tmp1_reg , dst_reg , src_reg ));
515
+ else
516
+ EMIT (PPC_RAW_DIVWU (tmp1_reg , dst_reg , src_reg ));
517
+
514
518
EMIT (PPC_RAW_MULW (tmp1_reg , src_reg , tmp1_reg ));
515
519
EMIT (PPC_RAW_SUB (dst_reg , dst_reg , tmp1_reg ));
516
520
} else
517
- EMIT (PPC_RAW_DIVWU (dst_reg , dst_reg , src_reg ));
521
+ if (off )
522
+ EMIT (PPC_RAW_DIVW (dst_reg , dst_reg , src_reg ));
523
+ else
524
+ EMIT (PPC_RAW_DIVWU (dst_reg , dst_reg , src_reg ));
518
525
goto bpf_alu32_trunc ;
519
526
case BPF_ALU64 | BPF_DIV | BPF_X : /* dst /= src */
520
527
case BPF_ALU64 | BPF_MOD | BPF_X : /* dst %= src */
521
528
if (BPF_OP (code ) == BPF_MOD ) {
522
- EMIT (PPC_RAW_DIVDU (tmp1_reg , dst_reg , src_reg ));
529
+ if (off )
530
+ EMIT (PPC_RAW_DIVD (tmp1_reg , dst_reg , src_reg ));
531
+ else
532
+ EMIT (PPC_RAW_DIVDU (tmp1_reg , dst_reg , src_reg ));
523
533
EMIT (PPC_RAW_MULD (tmp1_reg , src_reg , tmp1_reg ));
524
534
EMIT (PPC_RAW_SUB (dst_reg , dst_reg , tmp1_reg ));
525
535
} else
526
- EMIT (PPC_RAW_DIVDU (dst_reg , dst_reg , src_reg ));
536
+ if (off )
537
+ EMIT (PPC_RAW_DIVD (dst_reg , dst_reg , src_reg ));
538
+ else
539
+ EMIT (PPC_RAW_DIVDU (dst_reg , dst_reg , src_reg ));
527
540
break ;
528
541
case BPF_ALU | BPF_MOD | BPF_K : /* (u32) dst %= (u32) imm */
529
542
case BPF_ALU | BPF_DIV | BPF_K : /* (u32) dst /= (u32) imm */
@@ -544,19 +557,31 @@ int bpf_jit_build_body(struct bpf_prog *fp, u32 *image, u32 *fimage, struct code
544
557
switch (BPF_CLASS (code )) {
545
558
case BPF_ALU :
546
559
if (BPF_OP (code ) == BPF_MOD ) {
547
- EMIT (PPC_RAW_DIVWU (tmp2_reg , dst_reg , tmp1_reg ));
560
+ if (off )
561
+ EMIT (PPC_RAW_DIVW (tmp2_reg , dst_reg , tmp1_reg ));
562
+ else
563
+ EMIT (PPC_RAW_DIVWU (tmp2_reg , dst_reg , tmp1_reg ));
548
564
EMIT (PPC_RAW_MULW (tmp1_reg , tmp1_reg , tmp2_reg ));
549
565
EMIT (PPC_RAW_SUB (dst_reg , dst_reg , tmp1_reg ));
550
566
} else
551
- EMIT (PPC_RAW_DIVWU (dst_reg , dst_reg , tmp1_reg ));
567
+ if (off )
568
+ EMIT (PPC_RAW_DIVW (dst_reg , dst_reg , tmp1_reg ));
569
+ else
570
+ EMIT (PPC_RAW_DIVWU (dst_reg , dst_reg , tmp1_reg ));
552
571
break ;
553
572
case BPF_ALU64 :
554
573
if (BPF_OP (code ) == BPF_MOD ) {
555
- EMIT (PPC_RAW_DIVDU (tmp2_reg , dst_reg , tmp1_reg ));
574
+ if (off )
575
+ EMIT (PPC_RAW_DIVD (tmp2_reg , dst_reg , tmp1_reg ));
576
+ else
577
+ EMIT (PPC_RAW_DIVDU (tmp2_reg , dst_reg , tmp1_reg ));
556
578
EMIT (PPC_RAW_MULD (tmp1_reg , tmp1_reg , tmp2_reg ));
557
579
EMIT (PPC_RAW_SUB (dst_reg , dst_reg , tmp1_reg ));
558
580
} else
559
- EMIT (PPC_RAW_DIVDU (dst_reg , dst_reg , tmp1_reg ));
581
+ if (off )
582
+ EMIT (PPC_RAW_DIVD (dst_reg , dst_reg , tmp1_reg ));
583
+ else
584
+ EMIT (PPC_RAW_DIVDU (dst_reg , dst_reg , tmp1_reg ));
560
585
break ;
561
586
}
562
587
goto bpf_alu32_trunc ;
0 commit comments