public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: "Christophe Leroy (CS GROUP)" <chleroy@kernel.org>
To: adubey@linux.ibm.com, bpf@vger.kernel.org,
	linuxppc-dev@lists.ozlabs.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: hbathini@linux.ibm.com, sachinpb@linux.ibm.com,
	venkat88@linux.ibm.com, andrii@kernel.org, eddyz87@gmail.com,
	mykolal@fb.com, ast@kernel.org, daniel@iogearbox.net,
	martin.lau@linux.dev, song@kernel.org, yonghong.song@linux.dev,
	john.fastabend@gmail.com, kpsingh@kernel.org, sdf@fomichev.me,
	haoluo@google.com, jolsa@kernel.org, naveen@kernel.org,
	maddy@linux.ibm.com, mpe@ellerman.id.au, npiggin@gmail.com,
	memxor@gmail.com, iii@linux.ibm.com, shuah@kernel.org
Subject: Re: [PATCH v2 4/6] powerpc64/bpf: Add arch_bpf_stack_walk() for BPF JIT
Date: Wed, 14 Jan 2026 13:37:50 +0100	[thread overview]
Message-ID: <18dacad3-ec1d-4c91-adfb-2ee8d592de29@kernel.org> (raw)
In-Reply-To: <20260114114450.30405-5-adubey@linux.ibm.com>



Le 14/01/2026 à 12:44, adubey@linux.ibm.com a écrit :
> From: Abhishek Dubey <adubey@linux.ibm.com>
> 
> This function is used by bpf_throw() to unwind the stack
> until frame of exception-boundary during BPF exception
> handling.
> 
> This function is necessary to support BPF exceptions on
> PowerPC.
> 
> Signed-off-by: Abhishek Dubey <adubey@linux.ibm.com>
> ---
>   arch/powerpc/net/bpf_jit_comp64.c | 28 ++++++++++++++++++++++++++++
>   1 file changed, 28 insertions(+)
> 
> diff --git a/arch/powerpc/net/bpf_jit_comp64.c b/arch/powerpc/net/bpf_jit_comp64.c
> index cebf81fbd59f..ec58395f74f7 100644
> --- a/arch/powerpc/net/bpf_jit_comp64.c
> +++ b/arch/powerpc/net/bpf_jit_comp64.c
> @@ -247,6 +247,34 @@ void bpf_jit_build_epilogue(u32 *image, struct codegen_context *ctx)
>   	bpf_jit_build_fentry_stubs(image, ctx);
>   }
>   
> +void arch_bpf_stack_walk(bool (*consume_fn)(void *, u64, u64, u64), void *cookie)
> +{
> +	// callback processing always in current context
> +	unsigned long fp = current_stack_frame();
> +
> +	for (;;) {
> +		unsigned long *frame = (unsigned long *) fp;
> +		unsigned long ip;
> +
> +		if (!validate_sp(fp, current))
> +			return;
> +
> +		ip = frame[STACK_FRAME_LR_SAVE];
> +		if (!ip)
> +			break;
> +
> +		/*
> +		 * consume_fn common code expects stack pointer(sp) in third
> +		 * argument. There is no sp in ppc64, rather pass frame
> +		 * pointer.
> +		 */
> +		if (ip && !consume_fn(cookie, ip, fp, fp))
> +			break;
> +
> +		fp = frame[0];
> +	}
> +}
> +

This fonction looks very close to arch_stack_walk(). Would it be 
possible to refactor and have a common part used by both functions, like 
ARM64 for instance ?

>   int bpf_jit_emit_func_call_rel(u32 *image, u32 *fimage, struct codegen_context *ctx, u64 func)
>   {
>   	unsigned long func_addr = func ? ppc_function_entry((void *)func) : 0;


  reply	other threads:[~2026-01-14 12:37 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-14 11:44 [PATCH v2 0/6] powerpc64/bpf: Support tailcalls with subprogs & BPF exceptions adubey
2026-01-14 11:44 ` [PATCH v2 1/6] powerpc64/bpf: Move tail_call_cnt to bottom of stack frame adubey
2026-01-14 12:25   ` bot+bpf-ci
2026-01-15  8:29   ` Christophe Leroy (CS GROUP)
2026-01-17 10:11   ` Hari Bathini
     [not found]     ` <3e1c5930518113f349625cfa80ce82f5@imap.linux.ibm.com>
2026-01-17 10:59       ` Hari Bathini
2026-01-14 11:44 ` [PATCH v2 2/6] powerpc64/bpf: Support tailcalls with subprogs adubey
2026-01-14 12:27   ` Christophe Leroy (CS GROUP)
     [not found]     ` <2d242f4476b61373da236d24272b0ec3@imap.linux.ibm.com>
2026-01-16  4:50       ` Hari Bathini
2026-01-16  7:49         ` Christophe Leroy (CS GROUP)
2026-01-16 13:59           ` Hari Bathini
2026-01-17 10:23   ` Hari Bathini
2026-01-14 11:44 ` [PATCH v2 3/6] powerpc64/bpf: Tailcall handling with trampolines adubey
2026-01-14 12:25   ` bot+bpf-ci
2026-01-14 19:39   ` kernel test robot
2026-01-17 10:39   ` Hari Bathini
2026-01-17 10:41     ` Hari Bathini
2026-01-14 11:44 ` [PATCH v2 4/6] powerpc64/bpf: Add arch_bpf_stack_walk() for BPF JIT adubey
2026-01-14 12:37   ` Christophe Leroy (CS GROUP) [this message]
     [not found]     ` <bec1dfbacced0198fa76bc59e73811c6@imap.linux.ibm.com>
2026-01-16  5:38       ` Hari Bathini
2026-01-14 11:44 ` [PATCH v2 5/6] powerpc64/bpf: Support exceptions adubey
2026-01-16  6:27   ` Hari Bathini
     [not found]     ` <77a6a07add66189fbc9b68a410911e3c@imap.linux.ibm.com>
     [not found]       ` <cf1aea1601d03d42b3afde367c29d26b@imap.linux.ibm.com>
2026-01-16  7:48         ` Hari Bathini
2026-01-14 11:44 ` [PATCH v2 6/6] powerpc64/bpf: Additional NVR handling for bpf_throw adubey
2026-01-14 12:35   ` bot+bpf-ci
2026-01-17 10:51   ` Hari Bathini
2026-01-14 12:28 ` [PATCH v2 0/6] powerpc64/bpf: Support tailcalls with subprogs & BPF exceptions Christophe Leroy (CS GROUP)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=18dacad3-ec1d-4c91-adfb-2ee8d592de29@kernel.org \
    --to=chleroy@kernel.org \
    --cc=adubey@linux.ibm.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=hbathini@linux.ibm.com \
    --cc=iii@linux.ibm.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=mpe@ellerman.id.au \
    --cc=mykolal@fb.com \
    --cc=naveen@kernel.org \
    --cc=npiggin@gmail.com \
    --cc=sachinpb@linux.ibm.com \
    --cc=sdf@fomichev.me \
    --cc=shuah@kernel.org \
    --cc=song@kernel.org \
    --cc=venkat88@linux.ibm.com \
    --cc=yonghong.song@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox