Change to kcompat system#92
Merged
Merged
Conversation
Signed-off-by: Vlad-Gabriel Serbu <Vlad-Gabriel.Serbu@amd.com>
Collaborator
|
@amd-vserbu could you please make sure all files have license headers? |
Signed-off-by: Vlad-Gabriel Serbu <Vlad-Gabriel.Serbu@amd.com>
Collaborator
Author
|
I've added the missing license headers. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace the
LINUX_VERSION_CODEgates in the SLASH kernel module with a small build-time feature-probe system. The driver Makefile now runsdriver/kcompat/probe.shagainst$(KDIR), which compiles one conftest.cper feature against the target kernel and printsSLASH_HAVE_<FEAT>=y|n. The results are passed back into the kbuild recursion as bothmakevariables and-DSLASH_HAVE_<FEAT>ccflags, anddriver/slash_compat.hselects the modern or legacy API form based on those defines.Why
This replaces the existing
LINUX_VERSION_CODE >= KERNEL_VERSION(...)checks in the driver, which is brittle on distro kernels that backport features from newer upstreams (e.g. RHEL 9.x) and breaks the moment a new LTS picks up another behavior change. Conftest probes give us the actual ground truth for the kernel we are building against.Feature flags
Two features are probed today:
SLASH_HAVE_VM_FLAGS_SET--vm_flags_set()was added in 6.3. Old kernels fall back tovma->vm_flags |= flags. New kernels cannot use the old form becausevma->vm_flagsis now const/read-only.SLASH_HAVE_MODULE_IMPORT_NS_TOKEN--MODULE_IMPORT_NS()switched from bare-token to string-literal in 6.13. The probe checks the token form directly, so the result is precise across the cutover (the string form silently produces the wrong namespace on older kernels and is not safe to probe).