From: Yonghong Song <yhs@fb.com>
To: Jiri Olsa <olsajiri@gmail.com>
Cc: bpf@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
kernel-team@fb.com
Subject: Re: [PATCH bpf-next v2 3/6] bpf: x86: Support in-register struct arguments
Date: Mon, 15 Aug 2022 08:25:38 -0700 [thread overview]
Message-ID: <6ed1689c-1d59-1683-485d-31200ea7f0a6@fb.com> (raw)
In-Reply-To: <Yvn1vWwU/TMGHjRo@krava>
On 8/15/22 12:29 AM, Jiri Olsa wrote:
> On Sun, Aug 14, 2022 at 10:29:11PM -0700, Yonghong Song wrote:
>>
>>
>> On 8/14/22 1:24 PM, Jiri Olsa wrote:
>>> On Thu, Aug 11, 2022 at 10:24:35PM -0700, Yonghong Song wrote:
>>>
>>> SNIP
>>>
>>>> }
>>>> static int invoke_bpf_prog(const struct btf_func_model *m, u8 **pprog,
>>>> @@ -2020,6 +2081,7 @@ int arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *image, void *i
>>>> struct bpf_tramp_links *fentry = &tlinks[BPF_TRAMP_FENTRY];
>>>> struct bpf_tramp_links *fexit = &tlinks[BPF_TRAMP_FEXIT];
>>>> struct bpf_tramp_links *fmod_ret = &tlinks[BPF_TRAMP_MODIFY_RETURN];
>>>> + int struct_val_off, extra_nregs = 0;
>>>> u8 **branches = NULL;
>>>> u8 *prog;
>>>> bool save_ret;
>>>> @@ -2028,6 +2090,20 @@ int arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *image, void *i
>>>> if (nr_args > 6)
>>>> return -ENOTSUPP;
>>>> + for (i = 0; i < MAX_BPF_FUNC_ARGS; i++) {
>>>> + if (m->arg_flags[i] & BTF_FMODEL_STRUCT_ARG) {
>>>> + /* Only support up to 16 bytes struct which should keep
>>>> + * values in registers.
>>>> + */
>>>
>>> it seems that if the struct contains 'double' field, it's passed in
>>> SSE register, which we don't support is save/restore
>>
>> That is right.
>>
>>>
>>> we should probably check struct's BTF in btf_distill_func_proto and
>>> fail if we found anything else than regular regs types?
>>
>> The reason I didn't add float/double checking is that I didn't actually
>> find any float/double struct members in either vmlinux.h or in
>> arch/x86 directory. Could you help double check as well?
>
> ok I checked on fedora's BTF and could not find any
>
> still the check might be good or at least mention
> that in comment
I will mention in the comment. thanks!
>
>>
>>>
>>>> + if (m->arg_size[i] > 16)
>>>> + return -ENOTSUPP;
>>>> +
>>>> + extra_nregs += (m->arg_size[i] + 7) / 8 - 1;
>>>> + }
>>>> + }
>>>> + if (nr_args + extra_nregs > 6)
>>>
>>> should this value be minus the number of actually found struct arguments?
>>
>> In the above we have
>> extra_nregs += (m->arg_size[i] + 7) / 8 - 1;
>> already did the 'minus' part.
>
> there it is ;-) ok
>
> jirka
>
[...]
next prev parent reply other threads:[~2022-08-15 15:26 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-12 5:24 [PATCH bpf-next v2 0/6] bpf: Support struct argument for trampoline base progs Yonghong Song
2022-08-12 5:24 ` [PATCH bpf-next v2 1/6] bpf: Add struct argument info in btf_func_model Yonghong Song
2022-08-12 5:24 ` [PATCH bpf-next v2 2/6] bpf: x86: Rename stack_size to regs_off in {save,restore}_regs() Yonghong Song
2022-08-12 5:24 ` [PATCH bpf-next v2 3/6] bpf: x86: Support in-register struct arguments Yonghong Song
2022-08-14 20:24 ` Jiri Olsa
2022-08-15 5:29 ` Yonghong Song
2022-08-15 7:29 ` Jiri Olsa
2022-08-15 15:25 ` Yonghong Song [this message]
2022-08-15 22:44 ` Alexei Starovoitov
2022-08-18 4:56 ` Yonghong Song
2022-08-18 20:44 ` Alexei Starovoitov
2022-08-24 19:04 ` Yonghong Song
2022-08-24 22:35 ` Alexei Starovoitov
2022-08-25 4:10 ` Yonghong Song
2022-08-24 19:05 ` Andrii Nakryiko
2022-08-25 4:04 ` Yonghong Song
2022-08-12 5:24 ` [PATCH bpf-next v2 4/6] bpf: arm64: No support of struct argument Yonghong Song
2022-08-12 5:24 ` [PATCH bpf-next v2 5/6] bpf: Populate struct argument info in btf_func_model Yonghong Song
2022-08-12 5:24 ` [PATCH bpf-next v2 6/6] selftests/bpf: Add struct argument tests with fentry/fexit programs 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=6ed1689c-1d59-1683-485d-31200ea7f0a6@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 \
--cc=olsajiri@gmail.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;
as well as URLs for NNTP newsgroup(s).