Skip to content

Commit 44cf43c

Browse files
Jiong WangAlexei Starovoitov
authored andcommitted
ppc: bpf: implement jitting of BPF_ALU | BPF_ARSH | BPF_*
This patch implements code-gen for BPF_ALU | BPF_ARSH | BPF_*. Cc: Naveen N. Rao <naveen.n.rao@linux.ibm.com> Cc: Sandipan Das <sandipan@linux.ibm.com> Signed-off-by: Jiong Wang <jiong.wang@netronome.com> Reviewed-by: Sandipan Das <sandipan@linux.ibm.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent ee94b90 commit 44cf43c

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

arch/powerpc/include/asm/ppc-opcode.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,8 @@
342342
#define PPC_INST_SLW 0x7c000030
343343
#define PPC_INST_SLD 0x7c000036
344344
#define PPC_INST_SRW 0x7c000430
345+
#define PPC_INST_SRAW 0x7c000630
346+
#define PPC_INST_SRAWI 0x7c000670
345347
#define PPC_INST_SRD 0x7c000436
346348
#define PPC_INST_SRAD 0x7c000634
347349
#define PPC_INST_SRADI 0x7c000674

arch/powerpc/net/bpf_jit.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@
152152
___PPC_RS(a) | ___PPC_RB(s))
153153
#define PPC_SRW(d, a, s) EMIT(PPC_INST_SRW | ___PPC_RA(d) | \
154154
___PPC_RS(a) | ___PPC_RB(s))
155+
#define PPC_SRAW(d, a, s) EMIT(PPC_INST_SRAW | ___PPC_RA(d) | \
156+
___PPC_RS(a) | ___PPC_RB(s))
157+
#define PPC_SRAWI(d, a, i) EMIT(PPC_INST_SRAWI | ___PPC_RA(d) | \
158+
___PPC_RS(a) | __PPC_SH(i))
155159
#define PPC_SRD(d, a, s) EMIT(PPC_INST_SRD | ___PPC_RA(d) | \
156160
___PPC_RS(a) | ___PPC_RB(s))
157161
#define PPC_SRAD(d, a, s) EMIT(PPC_INST_SRAD | ___PPC_RA(d) | \

arch/powerpc/net/bpf_jit_comp64.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,9 +529,15 @@ static int bpf_jit_build_body(struct bpf_prog *fp, u32 *image,
529529
if (imm != 0)
530530
PPC_SRDI(dst_reg, dst_reg, imm);
531531
break;
532+
case BPF_ALU | BPF_ARSH | BPF_X: /* (s32) dst >>= src */
533+
PPC_SRAW(dst_reg, dst_reg, src_reg);
534+
goto bpf_alu32_trunc;
532535
case BPF_ALU64 | BPF_ARSH | BPF_X: /* (s64) dst >>= src */
533536
PPC_SRAD(dst_reg, dst_reg, src_reg);
534537
break;
538+
case BPF_ALU | BPF_ARSH | BPF_K: /* (s32) dst >>= imm */
539+
PPC_SRAWI(dst_reg, dst_reg, imm);
540+
goto bpf_alu32_trunc;
535541
case BPF_ALU64 | BPF_ARSH | BPF_K: /* (s64) dst >>= imm */
536542
if (imm != 0)
537543
PPC_SRADI(dst_reg, dst_reg, imm);

0 commit comments

Comments
 (0)