Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aya: convert bpf programs to assembly #1000

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Billy99
Copy link
Contributor

@Billy99 Billy99 commented Jul 25, 2024

In aya/src/sys/bpf.rs, there are several simple bpf programs written as byte arrays. Rework these as assembly code and then generate the bytecode.

Copy link

netlify bot commented Jul 25, 2024

Deploy Preview for aya-rs-docs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit f52b574
🔍 Latest deploy log https://app.netlify.com/sites/aya-rs-docs/deploys/66a281327fcb8c0008742e64
😎 Deploy Preview https://deploy-preview-1000--aya-rs-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@mergify mergify bot added aya This is about aya (userspace) test A PR that improves test cases or CI labels Jul 25, 2024
@Billy99 Billy99 force-pushed the billy99-convert-bytecode-assembly branch from 8c5963d to f52b574 Compare July 25, 2024 16:45
In aya/src/sys/bpf.rs, there are several simple bpf programs written as
byte arrays. These need to be adjusted to account for big endian.

Already handled in aya-rs#974.

Signed-off-by: Billy McFall <[email protected]>
In aya/src/sys/bpf.rs, there are several simple bpf programs written as
byte arrays. Rework these as assembly code and then generate the
bytecode.

Signed-off-by: Billy McFall <[email protected]>
@alessandrod
Copy link
Collaborator

Hello!

I don't think we should do this, for two reasons:

  • solana_rbpf implements SBPF - an eBPF dialect which is not compatible with kernel eBPF
  • as it is, the patch assembles at runtime, which incurs in a performance cost. If we could fork the solana_rbpf assembler and make it work at compile time that'd be great, and something I've been (idly) thinking about.

@dave-tucker
Copy link
Member

Hello!

I don't think we should do this, for two reasons:

  • solana_rbpf implements SBPF - an eBPF dialect which is not compatible with kernel eBPF
  • as it is, the patch assembles at runtime, which incurs in a performance cost. If we could fork the solana_rbpf assembler and make it work at compile time that'd be great, and something I've been (idly) thinking about.

The issue here is twofold:

  1. Keeping little and big endian versions of the same programs around isn't nice
  2. Hand-encoding the asm instructions into byte arrays is error prone

If the solana_rbpf assembler is a no-go, that's totally fine.
I can take a pass of doing something in macros a little like what libbpf does: https://github.com/libbpf/libbpf/blob/master/src/features.c#L51-L56

@alessandrod
Copy link
Collaborator

can take a pass of doing something in macros a little like what libbpf does:

something like this works, iirc there's an existing crate for it even

@dave-tucker
Copy link
Member

can take a pass of doing something in macros a little like what libbpf does:

something like this works, iirc there's an existing crate for it even

oh cool! if you find it let me know.

@alessandrod
Copy link
Collaborator

can take a pass of doing something in macros a little like what libbpf does:

something like this works, iirc there's an existing crate for it even

oh cool! if you find it let me know.

it's not the one I saw a while ago but this seems ok https://github.com/arcjustin/bpf-ins

Copy link

mergify bot commented Aug 27, 2024

@Billy99, this pull request is now in conflict and requires a rebase.

@mergify mergify bot added the needs-rebase label Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aya This is about aya (userspace) needs-rebase test A PR that improves test cases or CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants