-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Centralize the kernel and module metadata types #1394
base: main
Are you sure you want to change the base?
Conversation
Fixed some style warnings |
I'll take a look. @kostikbel and @kevans91 should take a look too. |
My opinion is that this is an enormous churn. Regardless of it, I think even the approach is not taken to the logical completion. All "elf kernel" literals must be replaced by the global const string which is used by reference, both in loader and in kernel. Ideally, we would have some enumeration value used to identify type, instead of free-typed string, but for this change at least replacing all individual strings with the same reference to constant string is the least required step. |
Yes, but it centralizes where we get the metadata at least. It also removes a bunch of unnecessary checks where kmdp can't be NULL. IMO most of the changes are trivial.
You're right, they should be. But for the kernel, after this patch, I believe the only reference to "elf kernel" would be in preload_initkmdp. |
I'll take a closer look at this. It's basically OK, but I think I have some misgivings I need to put into an actionable form. |
Looking more into what @kostikbel said, I've decided to move "elf kernel" and friends to sys/linker.h as macros. The reason they're macros an no longer globals is so that they can be easily shared across both the loader and kernel code. Other Also, I noticed that we also check for "elfN module" and "elfN obj module", so I removed those too. |
Alright, settled on modinfo.c at the end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am fine with the patch series, modulo two small identical comments
The way we got the kernel metadata pointer was by calling preload_search_by_type with one of the following three: "elf kernel", "elf32 kernel" and "elf64 kernel". Which one(s) we used wasn't consistent though. Sometimes we would only try "elf kernel", and other times we would try one of the latter two if the first failed. However, the loader only ever sets "elf kernel" as the kernel type. Now, the kmdp is a global, preload_kmdp, and it's initialized using preload_initkmdp in machdep.c (or machdep_boot.c on arm/64). preload_initkmdp takes a single boolean argument that tells us whether not finding the kmdp is fatal or not.
We never set the kernel type to either "elf64 kernel" nor "elf32 kernel".
Initialize the globals with macros so we can use the same values in the loader. Also remove unnecessary "elfN module" checks.
Currently, the way we get the kernel metadata pointer is by calling
preload_search_by_type with one of the following three: "elf kernel",
"elf32 kernel" and "elf64 kernel". Which one(s) we use isn't consistent
though. Sometimes we would only try "elf kernel", and other times we
would try one of the latter two if the first failed. However, the loader
only ever sets "elf kernel" as the kernel type.
See:
freebsd-src/stand/common/load_elf.c
Line 92 in 8afae0c
Instead, make the kmdp a global, preload_kmdp, and initialize it using
preload_initkmdp in machdep.c (or machdep_boot.c on arm/64).
preload_initkmdp takes a single boolean argument that tells us whether
not finding kmdp is fatal or not.
Also, feel free to critique my commit message. I feel like it's not great,
but that's the best I could word it.