[Bug bpf/24528] New: bpf-next housekeeping: bpf-translate.cxx should distinguish codegen for kernel/userspace targets

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug bpf/24528] New: bpf-next housekeeping: bpf-translate.cxx should distinguish codegen for kernel/userspace targets

fweimer at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=24528

            Bug ID: 24528
           Summary: bpf-next housekeeping: bpf-translate.cxx should
                    distinguish codegen for kernel/userspace targets
           Product: systemtap
           Version: unspecified
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: bpf
          Assignee: systemtap at sourceware dot org
          Reporter: me at serhei dot io
  Target Milestone: ---

bpf_unparser should have a flag bpf_target() which distinguishes whether code
is being generated for userspace-interpreter (no restrictions) or BPF
kernel-interpreter (many restrictions).

First this will enable better/simpler error checking logic.

Down the line, this will allow adding more values to bpf_target() and
generating certain constructs differently depending on whether they're
targeting different versions of BPF (with different restrictions).

--
You are receiving this mail because:
You are the assignee for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug bpf/24528] bpf-next housekeeping: bpf-translate.cxx should distinguish codegen for kernel/userspace targets

fweimer at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=24528

Serhei Makarov <me at serhei dot io> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|                            |22312


Referenced Bugs:

https://sourceware.org/bugzilla/show_bug.cgi?id=22312
[Bug 22312] bpf: global variable and statistics aggregate locking
--
You are receiving this mail because:
You are the assignee for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug bpf/24528] stapbpf-next housekeeping: bpf-translate.cxx should distinguish codegen for kernel/userspace targets

fweimer at redhat dot com
In reply to this post by fweimer at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=24528

Serhei Makarov <me at serhei dot io> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|bpf-next housekeeping:      |stapbpf-next housekeeping:
                   |bpf-translate.cxx should    |bpf-translate.cxx should
                   |distinguish codegen for     |distinguish codegen for
                   |kernel/userspace targets    |kernel/userspace targets

--
You are receiving this mail because:
You are the assignee for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug bpf/24528] stapbpf-next housekeeping: bpf-translate.cxx should distinguish codegen for kernel/userspace targets

fweimer at redhat dot com
In reply to this post by fweimer at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=24528

--- Comment #1 from Serhei Makarov <me at serhei dot io> ---
Added a 'target' field to struct program.

Next step is to go through bpf-translate.cxx and spot all the places where we
should be checking that 'target' field and signalling an error (or possibly
generating different code) instead of crossing our fingers that the user knows
which stap language constructs are and aren't supported by kernel bpf.

That way, if we use the wrong construct in the wrong code, we won't be getting
this type of cryptic madness anymore:

$ sudo ~/stap-install/bin/stap --bpf -e 'global g probe
kernel.function("vfs_read") { g["foo"] = "bar" foreach(k in g) { println(k) }
}'
Error loading /tmp/stapoSgfxZ/stap_25366.bo: bpf program load failed: Invalid
argument
back-edge from insn 1051 to 92

WARNING: /home/serhei/stap-install/bin/stapbpf exited with status: 1
Pass 5: run failed.  [man error::pass5]

Once the error messages work well (exist), I'll close this PR. But in general,
this work should also allow the userspace interpreter's constraints to be
relaxed (e.g. stack size or hard-register file could be increased) if or when
that proves necessary down the line.

--
You are receiving this mail because:
You are the assignee for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug bpf/24528] stapbpf-next housekeeping: bpf-translate.cxx should distinguish codegen for kernel/userspace targets

fweimer at redhat dot com
In reply to this post by fweimer at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=24528

--- Comment #2 from Serhei Makarov <me at serhei dot io> ---
Added some basic checking and error messages. Keeping PR open since we also
want to do a pass over tapset functions in case some are userspace-only. We
could mark this with a /* bpf_userspace */ annotation (bikeshed colour choice
pending).

--
You are receiving this mail because:
You are the assignee for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug bpf/24528] stapbpf-next housekeeping: bpf-translate.cxx should distinguish codegen for kernel/userspace targets

fweimer at redhat dot com
In reply to this post by fweimer at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=24528

Serhei Makarov <me at serhei dot io> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from Serhei Makarov <me at serhei dot io> ---
Added a /* userspace */ annotation to all embeddedcode tapset functions that
call a userspace-only helper.

--
You are receiving this mail because:
You are the assignee for the bug.