-
Notifications
You must be signed in to change notification settings - Fork 128
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
Add support for BPF_LD_MAP_FD pseudo instruction #53
Conversation
BPF_LD_MAP_FD pseudo instruction is a LD IMM64 with register SRC == BPF_PSEUDO_MAP_FD(1) Behavior is to resolve the map file descriptor and replace it with the address of the map.
This should have an interpreter implementation and some tests, including a test with one program using multiple maps. I also think that the callback should accept the |
Agreed about making the map resolver jitter aware. Modified both the register and the callback to accept void * context so that consumers have the choice of how to implement maps. |
Added tests for BPF_LD_MAP_FD pseudo instruction for both positive and negative (invalid FD) cases. |
Note: The goal is to allow consumer of ubpf to add support for maps by implementing the BPF syscall. This change allows the consumer to implement fd -> address mapping. |
Any reason why this was closed? |
Short versionThis overlaps with functionality in another library we are using and is redundant. BackgroundMy team is building a runtime + execution context (environment) that permits eBPF programs to be hosted in either user mode, kernel mode or an enclave. The runtime invokes the prevail eBPF verifier to parse and verify the eBPF program. As part of verification, callbacks are made to create maps. Net result is that ubpf is agnostic of maps in this model. Post verification, the runtime then does:
Note: |
BPF_LD_MAP_FD pseudo instruction is a LD IMM64 with register SRC == BPF_PSEUDO_MAP_FD(1)
Behavior is to resolve the map file descriptor and replace it with the address of the map.
Add new function ubpf_register_map_resolver to allow caller to provide callback to resolve map FD to address.
Resolves #45