Add initial __kconfig support with LINUX_KERNEL_VERSION.#869
Add initial __kconfig support with LINUX_KERNEL_VERSION.#869eiffel-fl wants to merge 2 commits intocilium:masterfrom eiffel-fl:francis/ebpf-kconfig
Conversation
ti-mo
left a comment
There was a problem hiding this comment.
Gave this a first round. Running the tests doesn't work for me.
eiffel-fl
left a comment
There was a problem hiding this comment.
Thank you for the review!
I address almost all of your comments and the code is now better than the first version.
I have nonetheless some questions or points I did not understand:
eiffel-fl
left a comment
There was a problem hiding this comment.
Hi.
I addressed all your comments, expect the one regarding the place of the test (see my comment about it).
Everything is working and thanks to your comments the code is now clearer, as a consequence I mark the PR as ready.
Best regards and thank you.
This permits simplifying function called on elfCode by removing this map from the function argument. Also, it avoids to Lookup on BTF as we can directly use the map. Signed-off-by: Francis Laniel <flaniel@linux.microsoft.com>
This commit is a first step toward __kconfig support. When a .kconfig data section is detected, a .kconfig map is created, its content will be initialized depending on the CONFIG_* values. During relocation, variable inside the .kconfig data section will have their offset changed to reflect their value inside the .kconfig map. For the moment, it only enables using LINUX_KERNEL_VERSION. The .kconfig map will be updated to contain the result of internal.KernelVersion(). Signed-off-by: Francis Laniel <flaniel@linux.microsoft.com>
|
I addressed all of your comments expect the one regarding the test, please take a look at my answer because I am not 100% sure this is possible to add this test to Thank you for the reviews and enjoy this Christmas weekend 🎅🎄🤶🎁🥳🎉! |
|
I've been hacking on this for a few days as well, this might take a bit longer to get right. The tests are passing, but there seems to be a conflict between the freestyle relocations we support (see vs. This makes it so we can't discern between relocations manually declared using asm and the types of relocations emitted for ksyms by clang. We'd like to continue supporting all use cases, but we'll have to get a little creative in doing so. The current proposal has a few issues, mostly around applying relocations, as well as overall strictness. All ksyms are currently being treated as if they were declared with I'd like to take over this work, will report back if there's progress. |
|
Hi.
I am not sure to understand.
I would need to take another look at
I am not sure I understand what you mean. Best regards. |
Sorry Francis, that's some bad communication on my part. You've addressed all my feedback nicely and things are in a good shape! I hadn't taken the time to look at this a bit closer up, so I discovered a few unknown unknowns this week. I was hoping I could collaborate by adding a few patches underneath or on top before merging this, that's all. Sorry for the misunderstanding, I wasn't implying you abandoned the work at all. 😊
Correct, this is an old hack that was relied on by some users to implement static data before the kernel had support for pseudo/frozen maps like .(ro)data. There are still kernels out there that don't support them, so we're not going to drop support for this right now. We have a similar issue for adding kfunc support, since we've always permitted forward declarations in C (see Had a discussion with Lorenz about this, we worked out some of the compatibility concerns I had around
We're still debating whether or not we should expose .kconfig's MapSpec.Contents in the CollectionSpec, or if we'll populate it during map load. |
No problem at all!
Definitely, even if this is some legacy, the two should remain.
So, you mean to put in I will take a look at |
By default, maintainers of a repo are allowed to push to PR branches in forks, unless explicitly disabled. The sidebar of this PR says
No, I mean we wouldn't support both __kconfig and inline asm relocations (like |
It does not seem my branch to be protected, can you please paste the error message you got?
OK, thank you for the clarification! |
|
@eiffel-fl Sorry, on PTO this week. Just gave this another try (this is after Do you have any kind of branch protection set up on your fork? There's a branch protection setting that controls force-pushes, but not sure if it's on or off by default. |
No problem!
I do not have any protection set, but my fork is actually a fork of a fork ( |
|
@eiffel-fl Could you try re-forking from Please close this PR when you've recreated it, thanks! |
|
Closing as superseded by #947. |
Hi.
This PR is a first step toward
__kconfigsupport which is discussed in #698.When a
.kconfigdata section is detected, a.kconfigmap is created, its content will be initialized depending on theCONFIG_*values.During relocation, variable inside the
.kconfigdata section will have their offset changed to reflect their value inside the.kconfigmap.For the moment, it only enables using
LINUX_KERNEL_VERSION. The.kconfigmap will be updated to contain the result ofinternal.KernelVersion().I tested it with some basic eBPF program I wrote:
Sadly, I was not able to make the added
TestLinuxKernelVersion()works because the ELF misses BTF and I needbtfSpecto not benilto check data section.I think I miss some steps in the ELF creation.
If you see any way to improve this PR, feel free to share.
Best regards and thank you in advance.