From: Song Liu <song@kernel.org>
To: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Song Liu <songliubraving@fb.com>,
Daniel Borkmann <daniel@iogearbox.net>,
Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
"Naveen N. Rao" <naveen.n.rao@linux.ibm.com>,
"bpf@vger.kernel.org" <bpf@vger.kernel.org>,
linuxppc-dev <linuxppc-dev@lists.ozlabs.org>,
Hari Bathini <hbathini@linux.ibm.com>
Subject: Re: [RFC PATCH 0/3] enable bpf_prog_pack allocator for powerpc
Date: Fri, 18 Nov 2022 09:28:37 -0800 [thread overview]
Message-ID: <CAPhsuW7uytWgsrv+y5qjqbxri-AgvrP9-EMnWyR48z6GhfHgfQ@mail.gmail.com> (raw)
In-Reply-To: <b2a8589d-3272-4c82-8481-9fcb6d8f9bfc@csgroup.eu>
On Fri, Nov 18, 2022 at 3:47 AM Christophe Leroy
<christophe.leroy@csgroup.eu> wrote:
>
>
>
> Le 18/11/2022 à 10:39, Hari Bathini a écrit :
> >
> >
> > On 18/11/22 2:21 pm, Christophe Leroy wrote: >>>>>
> >>>>> I had the same config but hit this problem:
> >>>>>
> >>>>> # echo 1 > /proc/sys/net/core/bpf_jit_enable; modprobe test_bpf
> >>>>> test_bpf: #0 TAX
> >>>>> ------------[ cut here ]------------
> >>>>> WARNING: CPU: 0 PID: 96 at arch/powerpc/net/bpf_jit_comp.c:367
> >>>>> bpf_int_jit_compile+0x8a0/0x9f8
> >>>>
> >>>> I get no such problem, on QEMU, and I checked the .config has:
> >>>
> >>>> CONFIG_STRICT_KERNEL_RWX=y
> >>>> CONFIG_STRICT_MODULE_RWX=y
> >>>
> >>> Yeah. That did the trick.
> >>
> >> Interesting. I guess we have to find out why it fails when those config
> >> are missing.
> >>
> >> Maybe module code plays with RO and NX flags even if
> >> CONFIG_STRICT_MODULE_RWX is not selected ?
> >
> > Need to look at the code closely but fwiw, observing same failure on
> > 64-bit as well with !STRICT_RWX...
>
> The problem is in bpf_prog_pack_alloc() and in alloc_new_pack() : They
> do set_memory_ro() and set_memory_x() without taking into account
> CONFIG_STRICT_MODULE_RWX.
>
> When CONFIG_STRICT_MODULE_RWX is selected, powerpc module_alloc()
> allocates PAGE_KERNEL memory, that is RW memory, and expects the user to
> call do set_memory_ro() and set_memory_x().
>
> But when CONFIG_STRICT_MODULE_RWX is not selected, powerpc
> module_alloc() allocates PAGE_KERNEL_TEXT memory, that is RWX memory,
> and expects to be able to always write into it.
Ah, I see. x86_64 requires CONFIG_STRICT_MODULE_RWX, so this hasn't
been a problem yet.
Thanks,
Song
next prev parent reply other threads:[~2022-11-18 17:29 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-10 18:43 [RFC PATCH 0/3] enable bpf_prog_pack allocator for powerpc Hari Bathini
2022-11-10 18:43 ` [RFC PATCH 1/3] powerpc/bpf: implement bpf_arch_text_copy Hari Bathini
2022-11-13 13:17 ` Christophe Leroy
2022-11-14 14:54 ` Hari Bathini
2022-11-10 18:43 ` [RFC PATCH 2/3] powerpc/bpf: implement bpf_arch_text_invalidate for bpf_prog_pack Hari Bathini
2022-11-13 18:00 ` Christophe Leroy
2022-11-10 18:43 ` [RFC PATCH 3/3] powerpc/bpf: use bpf_jit_binary_pack_[alloc|finalize|free] Hari Bathini
2022-11-13 18:36 ` Christophe Leroy
2022-11-11 11:25 ` [RFC PATCH 0/3] enable bpf_prog_pack allocator for powerpc Christophe Leroy
2022-11-14 14:47 ` Hari Bathini
2022-11-14 17:27 ` Christophe Leroy
2022-11-15 18:44 ` Christophe Leroy
2022-11-16 17:01 ` Hari Bathini
2022-11-16 17:16 ` Christophe Leroy
2022-11-17 6:59 ` Christophe Leroy
2022-11-18 8:39 ` Hari Bathini
2022-11-18 8:51 ` Christophe Leroy
2022-11-18 9:39 ` Hari Bathini
2022-11-18 11:46 ` Christophe Leroy
2022-11-18 17:28 ` Song Liu [this message]
2022-11-18 18:05 ` Christophe Leroy
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=CAPhsuW7uytWgsrv+y5qjqbxri-AgvrP9-EMnWyR48z6GhfHgfQ@mail.gmail.com \
--to=song@kernel.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=christophe.leroy@csgroup.eu \
--cc=daniel@iogearbox.net \
--cc=hbathini@linux.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=naveen.n.rao@linux.ibm.com \
--cc=songliubraving@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;
as well as URLs for NNTP newsgroup(s).