Skip to content

Change to kcompat system#92

Merged
quetric merged 2 commits into
Xilinx:devfrom
amd-vserbu:fix/kcompat
May 20, 2026
Merged

Change to kcompat system#92
quetric merged 2 commits into
Xilinx:devfrom
amd-vserbu:fix/kcompat

Conversation

@amd-vserbu
Copy link
Copy Markdown
Collaborator

Summary

Replace the LINUX_VERSION_CODE gates in the SLASH kernel module with a small build-time feature-probe system. The driver Makefile now runs driver/kcompat/probe.sh against $(KDIR), which compiles one conftest .c per feature against the target kernel and prints SLASH_HAVE_<FEAT>=y|n. The results are passed back into the kbuild recursion as both make variables and -DSLASH_HAVE_<FEAT> ccflags, and driver/slash_compat.h selects 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 to vma->vm_flags |= flags. New kernels cannot use the old form because vma->vm_flags is 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).

Signed-off-by: Vlad-Gabriel Serbu <Vlad-Gabriel.Serbu@amd.com>
Copy link
Copy Markdown
Collaborator

@hpc-aulmamei hpc-aulmamei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@quetric
Copy link
Copy Markdown
Collaborator

quetric commented May 20, 2026

@amd-vserbu could you please make sure all files have license headers?

Signed-off-by: Vlad-Gabriel Serbu <Vlad-Gabriel.Serbu@amd.com>
@amd-vserbu
Copy link
Copy Markdown
Collaborator Author

I've added the missing license headers.

@quetric quetric merged commit cb1ef56 into Xilinx:dev May 20, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants