@@ -204,6 +204,8 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp)
204204
205205 /* Make sure that the stack is quadword aligned. */
206206 cgctx .stack_size = round_up (fp -> aux -> stack_depth , 16 );
207+ cgctx .arena_vm_start = bpf_arena_get_kern_vm_start (fp -> aux -> arena );
208+ cgctx .user_vm_start = bpf_arena_get_user_vm_start (fp -> aux -> arena );
207209
208210 /* Scouting faux-generate pass 0 */
209211 if (bpf_jit_build_body (fp , NULL , NULL , & cgctx , addrs , 0 , false)) {
@@ -326,7 +328,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp)
326328 */
327329int bpf_add_extable_entry (struct bpf_prog * fp , u32 * image , u32 * fimage , int pass ,
328330 struct codegen_context * ctx , int insn_idx , int jmp_off ,
329- int dst_reg )
331+ int dst_reg , u32 code )
330332{
331333 off_t offset ;
332334 unsigned long pc ;
@@ -355,6 +357,9 @@ int bpf_add_extable_entry(struct bpf_prog *fp, u32 *image, u32 *fimage, int pass
355357 (ctx -> exentry_idx * BPF_FIXUP_LEN * 4 );
356358
357359 fixup [0 ] = PPC_RAW_LI (dst_reg , 0 );
360+ if (BPF_CLASS (code ) == BPF_ST || BPF_CLASS (code ) == BPF_STX )
361+ fixup [0 ] = PPC_RAW_NOP ();
362+
358363 if (IS_ENABLED (CONFIG_PPC32 ))
359364 fixup [1 ] = PPC_RAW_LI (dst_reg - 1 , 0 ); /* clear higher 32-bit register too */
360365
@@ -435,11 +440,32 @@ bool bpf_jit_supports_kfunc_call(void)
435440 return true;
436441}
437442
443+ bool bpf_jit_supports_arena (void )
444+ {
445+ return IS_ENABLED (CONFIG_PPC64 );
446+ }
447+
438448bool bpf_jit_supports_far_kfunc_call (void )
439449{
440450 return IS_ENABLED (CONFIG_PPC64 );
441451}
442452
453+ bool bpf_jit_supports_insn (struct bpf_insn * insn , bool in_arena )
454+ {
455+ if (!in_arena )
456+ return true;
457+ switch (insn -> code ) {
458+ case BPF_STX | BPF_ATOMIC | BPF_H :
459+ case BPF_STX | BPF_ATOMIC | BPF_B :
460+ case BPF_STX | BPF_ATOMIC | BPF_W :
461+ case BPF_STX | BPF_ATOMIC | BPF_DW :
462+ if (bpf_atomic_is_load_store (insn ))
463+ return false;
464+ return IS_ENABLED (CONFIG_PPC64 );
465+ }
466+ return true;
467+ }
468+
443469void * arch_alloc_bpf_trampoline (unsigned int size )
444470{
445471 return bpf_prog_pack_alloc (size , bpf_jit_fill_ill_insns );
@@ -579,7 +605,7 @@ static void bpf_trampoline_setup_tail_call_cnt(u32 *image, struct codegen_contex
579605{
580606 if (IS_ENABLED (CONFIG_PPC64 )) {
581607 /* See bpf_jit_stack_tailcallcnt() */
582- int tailcallcnt_offset = 6 * 8 ;
608+ int tailcallcnt_offset = 7 * 8 ;
583609
584610 EMIT (PPC_RAW_LL (_R3 , _R1 , func_frame_offset - tailcallcnt_offset ));
585611 EMIT (PPC_RAW_STL (_R3 , _R1 , - tailcallcnt_offset ));
@@ -594,7 +620,7 @@ static void bpf_trampoline_restore_tail_call_cnt(u32 *image, struct codegen_cont
594620{
595621 if (IS_ENABLED (CONFIG_PPC64 )) {
596622 /* See bpf_jit_stack_tailcallcnt() */
597- int tailcallcnt_offset = 6 * 8 ;
623+ int tailcallcnt_offset = 7 * 8 ;
598624
599625 EMIT (PPC_RAW_LL (_R3 , _R1 , - tailcallcnt_offset ));
600626 EMIT (PPC_RAW_STL (_R3 , _R1 , func_frame_offset - tailcallcnt_offset ));
0 commit comments