Replies: 4 comments 1 reply
-
Thanks for bringing this up @lmb. Someone from the eBPF maintainers group will look into the presentation and reply back to this discussion. |
Beta Was this translation helpful? Give feedback.
-
@Alan-Jowett one thought I had: instead of relying on MSVC to lower C to assembly, use the JIT you already have and embed its output as inline assembly in the driver. That removes compiler level reordering from the picture. You still have to worry about the JIT, but that's probably easier to tackle. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the suggestion. This is something we looked into when we originally developed this solution, but this approach would require a lot of additional work.
In addition, there was a strong pushback from internal folks that we should be using MSVC for native generation so that we would automatically pick-up the latest security mitigations from the compiler. In short, MSVC gets us machine code with all the latest compiler enhancements and protections that we would need to go and build for the JIT path. This is one of the primary reasons why we are moving towards a native only approach. |
Beta Was this translation helpful? Give feedback.
-
Bearing in mind that both compiler and CPU can re-order instructions, I am not sure anything short of explicit memory barriers really make senses long term, especially on architectures like ARM64 which have an even weaker memory model. There is an ongoing discussion in the BPF mailing list for a proposal for load/acquire and store/release semantics, which I think would be better as it would prevent compiler re-ordering around those instructions. |
Beta Was this translation helpful? Give feedback.
-
I recently attended a talk by Paul McKenney on the work on a BPF memory model. This exists so that programs accessing memory concurrently have meaningful semantics.
If I understand
bpf2c
correctly it works by translating a BPF instruction into an equivalent C statement. All statements are then compiled via MSVC, resulting in x64 assembly in a native .sys file. In terms of memory models we get the following:How do you ensure that this transformation of BPF to C preserves BPF memory model semantics in the final assembly?
See https://datatracker.ietf.org/meeting/118/materials/slides-118-bpf-bpf-memory-model-00 for some context.
Beta Was this translation helpful? Give feedback.
All reactions