dev.dpdk.org archive mirror
 help / color / mirror / Atom feed
From: "Ananyev, Konstantin" <konstantin.ananyev@intel.com>
To: Jerin Jacob Kollanukkaran <jerinj@marvell.com>,
	"dev@dpdk.org" <dev@dpdk.org>
Cc: "thomas@monjalon.net" <thomas@monjalon.net>,
	"stable@dpdk.org" <stable@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH] bpf: fix to allow ptr stack program type
Date: Mon, 12 Aug 2019 11:37:49 +0000	[thread overview]
Message-ID: <2601191342CEEE43887BDE71AB977258018115D7C8@irsmsx105.ger.corp.intel.com> (raw)
In-Reply-To: <BYAPR18MB24242AAFCC765811613B9F9CC8D30@BYAPR18MB2424.namprd18.prod.outlook.com>


> > Hi Jerin,
> 
> Hi Konstantin,
> 
> >
> > >
> > > bpf_validate does not allow to execute RTE_BPF_ARG_PTR_STACK for no
> > > reason.
> >
> > I believe there is a reason,
> > ARG_PTR_STACK is reserved for memory within BPF program internal stack
> > only.
> > User that calls BPF program should never pass parameter with that type.
> 
> OK.
> Shouldn't we remove that from public header file
> (lib/librte_bpf/rte_bpf.h) then ?

Probably... or might be just put extra comments to mark it as internal?
The reason I left it here, so we can add new public values for enum here,
before RTE_BPF_ARG_PTR_STACK.
Of course in theory we can use for RTE_BPF_ARG_PTR_STACK some reserved
value instead.

> 
> > If the user allocates parameter for bpf function on the stack, he can still use
> > RTE_BPF_ARG_PTR for it.
> 
> I see the _stack_ is only allocated under RTE_BPF_ARG_PTR_STACK checks in bpf_validate.c.
> Can you check? I agree that stack should be allocated for RTE_BPF_ARG_PTR as well.

Not sure I understand your query here...
Each BPF program can use up to MAX_BPF_STACK_SIZE bytes for stack.
Though to avoid JIT to allocate unused space for the stack, in bpf_validate.c
we figure out does given BPF program really allocate things on the stack and if yes,
how many bytes is needed.
This info is stored in rte_bpf.stack_sz and can be used later by the JIT.
Let say for x86 jit is used in  emit_prolog().

> 
> I am writing the arm64 JIT support now, I see always stack of size of 0. I did not spend  much
> Time on the generic piece of ebpf code(Focusing only on JIT side now).
> 
> Can you share more detail the stack allocation scheme, Is validate code parse the eBPF opcode and
> Figure out the stack depth it by its own and pass to JIT function where Arch code can allocate
> enough stack.

Yep, see above.
Konstantin


> 
> 
> >
> > > Fix it by enhancing the prog_arg.type check.
> > >
> > > Fixes: 6e12ec4c4d6d ("bpf: add more checks")
> > > Cc: stable@dpdk.org
> > >
> > > Signed-off-by: Jerin Jacob <jerinj@marvell.com>
> > > ---
> > >  lib/librte_bpf/bpf_validate.c | 1 +
> > >  1 file changed, 1 insertion(+)
> > >
> > > diff --git a/lib/librte_bpf/bpf_validate.c
> > > b/lib/librte_bpf/bpf_validate.c index 0cf41fa27..c75777b6d 100644
> > > --- a/lib/librte_bpf/bpf_validate.c
> > > +++ b/lib/librte_bpf/bpf_validate.c
> > > @@ -2216,6 +2216,7 @@ bpf_validate(struct rte_bpf *bpf)
> > >
> > >  	/* check input argument type, don't allow mbuf ptr on 32-bit */
> > >  	if (bpf->prm.prog_arg.type != RTE_BPF_ARG_RAW &&
> > > +			bpf->prm.prog_arg.type !=
> > RTE_BPF_ARG_PTR_STACK &&
> > >  			bpf->prm.prog_arg.type != RTE_BPF_ARG_PTR &&
> > >  			(sizeof(uint64_t) != sizeof(uintptr_t) ||
> > >  			bpf->prm.prog_arg.type !=
> > RTE_BPF_ARG_PTR_MBUF)) {
> > > --
> > > 2.22.0


  reply	other threads:[~2019-08-12 11:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-09 16:29 [dpdk-dev] [PATCH] bpf: fix to allow ptr stack program type jerinj
2019-08-12  8:49 ` Ananyev, Konstantin
2019-08-12 10:34   ` Jerin Jacob Kollanukkaran
2019-08-12 11:37     ` Ananyev, Konstantin [this message]
2019-08-13  3:31       ` Jerin Jacob Kollanukkaran
2019-08-13  6:50         ` Ananyev, Konstantin

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=2601191342CEEE43887BDE71AB977258018115D7C8@irsmsx105.ger.corp.intel.com \
    --to=konstantin.ananyev@intel.com \
    --cc=dev@dpdk.org \
    --cc=jerinj@marvell.com \
    --cc=stable@dpdk.org \
    --cc=thomas@monjalon.net \
    /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;
as well as URLs for NNTP newsgroup(s).