BPF List
 help / color / mirror / Atom feed
From: Yonghong Song <yhs@fb.com>
To: <bpf@vger.kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>, <kernel-team@fb.com>
Subject: [RFC PATCH bpf-next 2/7] bpf: Add struct argument info in btf_func_model
Date: Tue, 26 Jul 2022 10:11:40 -0700	[thread overview]
Message-ID: <20220726171140.710070-1-yhs@fb.com> (raw)
In-Reply-To: <20220726171129.708371-1-yhs@fb.com>

Add struct argument information in btf_func_model and such information
will be used in arch specific function arch_prepare_bpf_trampoline()
to prepare argument access properly in trampoline.

Signed-off-by: Yonghong Song <yhs@fb.com>
---
 include/linux/bpf.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 20c26aed7896..173b42cf3940 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -726,10 +726,19 @@ enum bpf_cgroup_storage_type {
  */
 #define MAX_BPF_FUNC_REG_ARGS 5
 
+/* The maximum number of struct arguments a single function may have. */
+#define MAX_BPF_FUNC_STRUCT_ARGS 2
+
 struct btf_func_model {
 	u8 ret_size;
 	u8 nr_args;
 	u8 arg_size[MAX_BPF_FUNC_ARGS];
+	/* The struct_arg_idx should be in increasing order like (0, 2, ...).
+	 * The struct_arg_bsize encodes the struct field byte size
+	 * for the corresponding struct argument index.
+	 */
+	u8 struct_arg_idx[MAX_BPF_FUNC_STRUCT_ARGS];
+	u8 struct_arg_bsize[MAX_BPF_FUNC_STRUCT_ARGS];
 };
 
 /* Restore arguments before returning from trampoline to let original function
-- 
2.30.2


  parent reply	other threads:[~2022-07-26 17:11 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-26 17:11 [RFC PATCH bpf-next 0/7] bpf: Support struct value argument for trampoline base progs Yonghong Song
2022-07-26 17:11 ` [RFC PATCH bpf-next 1/7] bpf: Always return corresponding btf_type in __get_type_size() Yonghong Song
2022-07-26 17:11 ` Yonghong Song [this message]
2022-08-09  0:02   ` [RFC PATCH bpf-next 2/7] bpf: Add struct argument info in btf_func_model Andrii Nakryiko
2022-08-09 17:38     ` Yonghong Song
2022-08-10  0:25       ` Andrii Nakryiko
2022-08-11  6:24         ` Yonghong Song
2022-07-26 17:11 ` [RFC PATCH bpf-next 3/7] bpf: x86: Rename stack_size to regs_off in {save,restore}_regs() Yonghong Song
2022-07-26 17:11 ` [RFC PATCH bpf-next 4/7] bpf: x86: Support in-register struct arguments Yonghong Song
2022-07-29 11:10   ` Jiri Olsa
2022-07-31 17:00     ` Yonghong Song
2022-07-26 17:11 ` [RFC PATCH bpf-next 5/7] bpf: arm64: No support of struct value argument Yonghong Song
2022-07-26 17:12 ` [RFC PATCH bpf-next 6/7] bpf: Populate struct value info in btf_func_model Yonghong Song
2022-07-26 17:12 ` [RFC PATCH bpf-next 7/7] selftests/bpf: Add struct value tests with fentry programs Yonghong Song
2022-07-28 15:46 ` [RFC PATCH bpf-next 0/7] bpf: Support struct value argument for trampoline base progs Kui-Feng Lee
2022-07-28 17:46   ` Yonghong Song
2022-07-28 19:57     ` Kui-Feng Lee
2022-07-28 23:30       ` Yonghong Song
2022-07-29 18:04         ` Kui-Feng Lee
2022-08-02 23:46           ` Yonghong Song

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=20220726171140.710070-1-yhs@fb.com \
    --to=yhs@fb.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.com \
    /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