From c87c294234fc6edb60d482e42ca1dcafc50d9cea Mon Sep 17 00:00:00 2001 From: Elaheh Dehghani Date: Mon, 22 Jun 2026 16:37:27 +0000 Subject: [PATCH] feat(kmod-mlnx-ofa_kernel): add mlnx-ofa_kernel kernel module --- base/comps/kernel/kernel.comp.toml | 92 ++++++- base/comps/kernel/kmod-mlnx-ofa_kernel.inc | 284 +++++++++++++++++++++ locks/kernel.lock | 2 +- specs/k/kernel/kernel.azl.macros | 5 +- specs/k/kernel/kernel.spec | 30 +++ specs/k/kernel/kmod-mlnx-ofa_kernel.inc | 284 +++++++++++++++++++++ specs/k/kernel/sources | 1 + 7 files changed, 695 insertions(+), 3 deletions(-) create mode 100644 base/comps/kernel/kmod-mlnx-ofa_kernel.inc create mode 100644 specs/k/kernel/kmod-mlnx-ofa_kernel.inc diff --git a/base/comps/kernel/kernel.comp.toml b/base/comps/kernel/kernel.comp.toml index 9f568dc9314..d289855c087 100644 --- a/base/comps/kernel/kernel.comp.toml +++ b/base/comps/kernel/kernel.comp.toml @@ -14,12 +14,15 @@ without = [ [components.kernel.build.defines] # RPM release number for the Azure Linux kernel package -azl_pkgrelease = "5" +azl_pkgrelease = "6" # 4th version component from the AZL kernel source (6.18.31.1). Included in specrelease so it appears # in the RPM Release tag, uname -r, and /lib/modules/ path (e.g. 6.18.31-1.1.azl4.aarch64). kextraversion = "1" # NVIDIA open GPU kernel module version (built as a subpackage of the kernel) nvidia_open_version = "595.58.03" +mlnx_ofa_version = "26.04" +mlnx_ofa_release = "OFED.26.04.0.8.5.1" +mlnx_ofa_bundle_release = "0.8.5.0" # Download the source tarball from the AzureLinux kernel repo [[components.kernel.source-files]] @@ -35,6 +38,15 @@ hash = "a422b6935209d590f57fa6766f59bb207d9130f8a6777af9245c4ff8cd0f4c4ccef4602a hash-type = "SHA512" origin = { type = "download", uri = "https://github.com/NVIDIA/open-gpu-kernel-modules/archive/refs/tags/595.58.03.tar.gz" } +# Download the NVIDIA MLNX_OFED source bundle. We don't need the entire bundle +# — only the mlnx-ofa_kernel SRPM (and its inner tarball) inside it — but NVIDIA +# does not host mlnx-ofa_kernel as a standalone download. +[[components.kernel.source-files]] +filename = "MLNX_OFED_SRC-26.04-0.8.5.0.tgz" +hash = "1829d190f84f6d54597b98c40e162afa64939e608f7eaf494ac626c454e4d0310e14dedb7108326e9c9a667634eb27cf751dae806249f1783a66c8fc07aacd13" +hash-type = "SHA512" +origin = { type = "download", uri = "https://linux.mellanox.com/public/repo/doca/3.4.0/SOURCES/mlnx_ofed/MLNX_OFED_SRC-26.04-0.8.5.0.tgz" } + # Insert version and release information from the component defines into the spec file, and update the source URL to match the AzureLinux kernel source structure [[components.kernel.overlays]] description = "Set specrpmversion to 6.18.31" @@ -340,6 +352,81 @@ replacement = """# AZL: kmod subpackage file lists and scriptlets (nvidia-open) # AZL-KMOD-FILES-ANCHOR""" +# --- kmod-mlnx-ofa_kernel: source file registration --- +[[components.kernel.overlays]] +description = "Add kmod-mlnx-ofa_kernel.inc subpackage definition to sources" +type = "file-add" +file = "kmod-mlnx-ofa_kernel.inc" +source = "kmod-mlnx-ofa_kernel.inc" + +[[components.kernel.overlays]] +description = "Register MLNX_OFED_SRC bundle as Source6100. The inner mlnx-ofa_kernel tarball is extracted from the bundle's SRPM in the kmod-mlnx-ofa 'prep' phase — see kmod-mlnx-ofa_kernel.inc." +type = "spec-insert-tag" +tag = "Source6100" +value = "MLNX_OFED_SRC-%{mlnx_ofa_version}-%{mlnx_ofa_bundle_release}.tgz" + +[[components.kernel.overlays]] +description = "Register kmod-mlnx-ofa_kernel.inc as Source6101" +type = "spec-insert-tag" +tag = "Source6101" +value = "kmod-mlnx-ofa_kernel.inc" + +# --- kmod-mlnx-ofa_kernel: phase injection --- +[[components.kernel.overlays]] +description = "Run mlnx-ofa_kernel kmod 'package' phase — declares the kmod-mlnx-ofa_kernel subpackage" +type = "spec-search-replace" +regex = '# AZL-KMOD-PACKAGE-ANCHOR' +replacement = """# AZL: kmod subpackage declarations (mlnx-ofa_kernel) +%global _kmod_phase package +%global _kmod_name mlnx-ofa_kernel +%include %{_sourcedir}/kmod-mlnx-ofa_kernel.inc + +# AZL-KMOD-PACKAGE-ANCHOR""" + +[[components.kernel.overlays]] +description = "Run mlnx-ofa_kernel kmod 'prep' phase — extracts the mlnx-ofa_kernel tarball" +type = "spec-search-replace" +regex = '# AZL-KMOD-PREP-ANCHOR' +replacement = """# AZL: Prepare kmod subpackage sources (mlnx-ofa_kernel) +%global _kmod_phase prep +%global _kmod_name mlnx-ofa_kernel +%include %{_sourcedir}/kmod-mlnx-ofa_kernel.inc + +# AZL-KMOD-PREP-ANCHOR""" + +[[components.kernel.overlays]] +description = "Run mlnx-ofa_kernel kmod 'build' phase — runs ./configure + make kernel modules against the just-built kernel tree" +type = "spec-search-replace" +regex = '# AZL-KMOD-BUILD-ANCHOR' +replacement = """# AZL: Build kmod subpackage modules (mlnx-ofa_kernel) +%global _kmod_phase build +%global _kmod_name mlnx-ofa_kernel +%include %{_sourcedir}/kmod-mlnx-ofa_kernel.inc + +# AZL-KMOD-BUILD-ANCHOR""" + +[[components.kernel.overlays]] +description = "Run mlnx-ofa_kernel kmod 'install' phase — make install_modules into /lib/modules//extra/mlnx-ofa" +type = "spec-search-replace" +regex = '# AZL-KMOD-INSTALL-ANCHOR' +replacement = """# AZL: Install kmod subpackage files (mlnx-ofa_kernel) +%global _kmod_phase install +%global _kmod_name mlnx-ofa_kernel +%include %{_sourcedir}/kmod-mlnx-ofa_kernel.inc + +# AZL-KMOD-INSTALL-ANCHOR""" + +[[components.kernel.overlays]] +description = "Run mlnx-ofa_kernel kmod 'files' phase — adds %post/%postun/%files for the mlnx-ofa_kernel kmod subpackage" +type = "spec-search-replace" +regex = '# AZL-KMOD-FILES-ANCHOR' +replacement = """# AZL: kmod subpackage file lists and scriptlets (mlnx-ofa_kernel) +%global _kmod_phase files +%global _kmod_name mlnx-ofa_kernel +%include %{_sourcedir}/kmod-mlnx-ofa_kernel.inc + +# AZL-KMOD-FILES-ANCHOR""" + # Prepend AZL changelog entries to the top of %changelog. The kernel uses # `release.calculation = "manual"` (no rpmautospec), so changelog entries are # hand-curated here rather than derived from `git log`. Convention: one entry @@ -360,6 +447,9 @@ description = "Prepend AZL changelog entries (one per lock-fingerprint change) a type = "spec-prepend-lines" section = "%changelog" lines = [ + "* Wed Jun 10 2026 Elaheh Dehghani - 6.18.31-1.6", + "- feat(kernel): add kmod-mlnx-ofa_kernel subpackage (mlnx-ofa_kernel 26.04, NIC+RDMA+IPoIB)", + "", "* Wed May 27 2026 Daniel McIlvaney - 6.18.31-1.5", "- feat(kernel): add hand-curated changelog entry", "", diff --git a/base/comps/kernel/kmod-mlnx-ofa_kernel.inc b/base/comps/kernel/kmod-mlnx-ofa_kernel.inc new file mode 100644 index 00000000000..eb53f980c94 --- /dev/null +++ b/base/comps/kernel/kmod-mlnx-ofa_kernel.inc @@ -0,0 +1,284 @@ +# kmod-mlnx-ofa_kernel.inc — NVIDIA / Mellanox OFED kernel modules (mlnx-ofa_kernel) +# +# Phases: package, prep, build, install, files +# Activated by: setting _kmod_phase + _kmod_name globals and including this +# file from kernel.comp.toml overlays. +# +# Requires these defines/sources in kernel.spec (injected via comp.toml overlays): +# mlnx_ofa_version — driver tag (e.g. 26.04) +# mlnx_ofa_release — vendor release stamp (e.g. OFED.26.04.0.8.5.1) +# SOURCE6100 — MLNX_OFED_SRC-%{mlnx_ofa_version}-%{mlnx_ofa_bundle_release}.tgz bundle +# + +# ========================================================================= +# Phase: package — subpackage declaration +# ========================================================================= +%if "%{_kmod_phase}" == "package" && %{with_up_base} + +%ifarch x86_64 aarch64 +%package -n kmod-%{_kmod_name}-%{mlnx_ofa_version} +Summary: Mellanox OFED kernel modules (mlnx-ofa_kernel %{mlnx_ofa_version}) +AutoReq: no +Provides: mlnx-ofa-kmod-version = %{mlnx_ofa_version} +Provides: mlnx-ofa-kmod-release = %{mlnx_ofa_release} +Provides: kmod-%{_kmod_name} = %{version}-%{release} +Provides: kmod-mlnx-ofa = %{version}-%{release} +Obsoletes: kmod-mlnx-ofa < %{version}-%{release} +Provides: installonlypkg(kernel-module) +Requires: %{name}-core-uname-r = %{KVERREL} +Requires(post): kmod +Requires(postun): kmod + +%description -n kmod-%{_kmod_name}-%{mlnx_ofa_version} +NVIDIA / Mellanox InfiniBand and Ethernet (mlx5) kernel modules built from +mlnx-ofa_kernel %{mlnx_ofa_version} (%{mlnx_ofa_release}) against kernel +%{KVERREL}. + +# ------------------------------------------------------------------------- +# -devel: headers + Module.symvers + helper scripts for building out-of-tree +# kernel modules (e.g. nv-peer-mem, GPUDirect) against this kmod. Lives in +# the kmod (not the userspace comp) because the symvers + backport-shim +# headers are produced by *this* build and are tied to this exact kernel. +# ------------------------------------------------------------------------- +%package -n kmod-%{_kmod_name}-devel-%{mlnx_ofa_version} +Summary: Development files for kmod-%{_kmod_name}-%{mlnx_ofa_version} +AutoReq: no +Requires: kmod-%{_kmod_name}-%{mlnx_ofa_version} = %{version}-%{release} +Requires: coreutils +Requires: pciutils +Provides: mlnx-ofa-kmod-devel-version = %{mlnx_ofa_version} +Provides: mlnx-ofa-kmod-devel-release = %{mlnx_ofa_release} +Provides: kmod-%{_kmod_name}-devel = %{version}-%{release} + +%description -n kmod-%{_kmod_name}-devel-%{mlnx_ofa_version} +Development files for kmod-%{_kmod_name}-%{mlnx_ofa_version}: backport +headers, compat layer, Module.symvers, and the ofed_scripts helpers used +by out-of-tree modules (e.g. nv-peer-mem) that link against the mlnx-ofa +NIC/RDMA stack rather than the in-tree mlx5/RDMA drivers. + +Files install under /usr/src/ofa_kernel/%{_arch}/%{KVERREL}/ and are tied +to the kernel build that produced them. Multiple kernel versions can +coexist (one devel tree per kernel build). +%endif + +%endif + +# ========================================================================= +# Phase: prep — extract mlnx-ofa_kernel tarball from MLNX_OFED_SRC bundle +# ========================================================================= +%if "%{_kmod_phase}" == "prep" && %{with_up_base} + +%ifarch x86_64 aarch64 +# %{SOURCE6100} is the MLNX_OFED_SRC bundle (a tar of every Mellanox OFED +# SRPM). We don't need the whole bundle — just the mlnx-ofa_kernel SRPM — +# and from that SRPM we only need the mlnx-ofa_kernel-.tgz source tarball. +pushd %{_builddir} +%{log_msg "Extracting MLNX_OFED_SRC bundle to fetch mlnx-ofa_kernel sources"} +tar -xf %{SOURCE6100} +_mofa_srpm=$(find MLNX_OFED_SRC-* -path '*/SRPMS/mlnx-ofa_kernel-*.src.rpm' \ + -print -quit) +if [ -z "$_mofa_srpm" ]; then + echo "ERROR: mlnx-ofa_kernel SRPM not found inside %{SOURCE6100}" >&2 + exit 1 +fi +rpm2cpio "$_mofa_srpm" | cpio -idm '*mlnx-ofa_kernel-%{mlnx_ofa_version}.tgz' +tar -xf mlnx-ofa_kernel-%{mlnx_ofa_version}.tgz +rm -rf MLNX_OFED_SRC-* mlnx-ofa_kernel-%{mlnx_ofa_version}.tgz +popd +%endif + +%endif + +# ========================================================================= +# Phase: build — compile mlnx-ofa kernel modules +# ========================================================================= +%if "%{_kmod_phase}" == "build" && %{with_up_base} + +%ifarch x86_64 aarch64 +%{log_msg "Building mlnx-ofa_kernel %{mlnx_ofa_version} modules for %{KVERREL}"} +pushd %{_builddir}/mlnx-ofa_kernel-%{mlnx_ofa_version} + +# Upstream mlnx-ofa_kernel.spec stamps compat shims to a fixed epoch to keep +# autoconf/automake-style timestamp checks happy in the kbuild Makefiles. Same +# trick here; safe no-op if `compat/` is absent. +find compat -type f -exec touch -t 200012201010 '{}' \; || true + +CFLAGS=$(echo "${CFLAGS}" \ + | sed -e 's|-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1||g' \ + -e 's|-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1||g' \ + -e 's|-fexceptions||g') +export CFLAGS="${CFLAGS} -fno-exceptions" +unset CXXFLAGS +unset LDFLAGS + +./configure \ + --build-dummy-mods \ + --prefix=%{_prefix} \ + --kernel-version "%{KVERREL}" \ + --kernel-sources "%{_builddir}/kernel-%{tarfile_release}/linux-%{KVERREL}" \ + --modules-dir "/lib/modules/%{KVERREL}/extra/mlnx-ofa_kernel" \ + --with-core-mod \ + --with-user_mad-mod \ + --with-user_access-mod \ + --with-addr_trans-mod \ + --with-mlx5-mod \ + --with-mlxfw-mod \ + --with-ipoib-mod \ + %{?_smp_mflags} + +make %{?_smp_mflags} kernel + +popd +%endif + +%endif + +# ========================================================================= +# Phase: install — install modules +# ========================================================================= +%if "%{_kmod_phase}" == "install" && %{with_up_base} + +%ifarch x86_64 aarch64 +%{log_msg "Installing mlnx-ofa_kernel modules for %{KVERREL}"} +pushd %{_builddir}/mlnx-ofa_kernel-%{mlnx_ofa_version} + +# mlnx-ofa's `install_modules` recipe runs depmod, which overwrites the +# parent kernel's modules.{builtin,order,*}. Snapshot those before install +# and restore them after, otherwise kernel-core's %files (which lists +# /lib/modules/%{KVERREL}/modules.builtin*) will fail with "File not found". +_mods_dir="%{buildroot}/lib/modules/%{KVERREL}" +_mods_snap="%{_builddir}/mlnx-ofa-mods-snapshot" +rm -rf "$_mods_snap" +if [ -d "$_mods_dir" ]; then + mkdir -p "$_mods_snap" + find "$_mods_dir" -maxdepth 1 -name 'modules.*' -type f \ + -exec cp -a {} "$_mods_snap/" \; +fi + +export INSTALL_MOD_PATH=%{buildroot} +export INSTALL_MOD_DIR=extra/mlnx-ofa_kernel +make install_modules KERNELRELEASE=%{KVERREL} + +popd + +# Drop the modules.{dep,order,builtin,...} files that mlnx-ofa's install just +# wrote, then restore the parent kernel's originals from the snapshot. The +# kernel %post regenerates depmod state at install time on the target system. +find "$_mods_dir" -maxdepth 1 -name 'modules.*' -type f -exec rm -f {} \; +if [ -d "$_mods_snap" ]; then + cp -a "$_mods_snap"/. "$_mods_dir/" + rm -rf "$_mods_snap" +fi + +# Make installed modules executable so they get stripped + debuginfo extracted +# when the package is built (rpmbuild only strips u+x files). +find %{buildroot}/lib/modules/%{KVERREL}/extra/mlnx-ofa_kernel \ + \( -type f -name '*.ko' -o -name '*.ko.gz' -o -name '*.ko.xz' -o -name '*.ko.zst' \) \ + -exec chmod u+x {} \; + +# Strip .BTF sections from installed modules to avoid runtime validation +# failures observed on target VMs ("Invalid name" / BTF: -22). +if command -v objcopy >/dev/null 2>&1; then +find %{buildroot}/lib/modules/%{KVERREL}/extra/mlnx-ofa_kernel \ + \( -name '*.ko' -o -name '*.ko.gz' -o -name '*.ko.xz' -o -name '*.ko.zst' \) | \ +while read -r f; do + case "$f" in + *.ko) + objcopy --remove-section .BTF --remove-section .BTF.ext "$f" || true + ;; + *.ko.gz) + gzip -dkf "$f" + ko="${f%.gz}" + objcopy --remove-section .BTF --remove-section .BTF.ext "$ko" || true + gzip -f "$ko" + ;; + *.ko.xz) + xz -dkf "$f" + ko="${f%.xz}" + objcopy --remove-section .BTF --remove-section .BTF.ext "$ko" || true + xz -zf "$ko" + ;; + *.ko.zst) + zstd -q -d -f "$f" -o "${f%.zst}" + ko="${f%.zst}" + objcopy --remove-section .BTF --remove-section .BTF.ext "$ko" || true + zstd -q -f "$ko" -o "$f" + rm -f "$ko" + ;; + esac +done +fi + +install -D -m 0644 %{_builddir}/mlnx-ofa_kernel-%{mlnx_ofa_version}/COPYING \ + %{buildroot}%{_datadir}/licenses/kmod-%{_kmod_name}-%{mlnx_ofa_version}/COPYING + +%{log_msg "Staging mlnx-ofa_kernel devel tree for %{KVERREL}"} +_devel_src="%{_builddir}/mlnx-ofa_kernel-%{mlnx_ofa_version}" +_devel_dst="%{buildroot}%{_prefix}/src/ofa_kernel/%{_arch}/%{KVERREL}" +mkdir -p "$_devel_dst" + +# Headers + compat shims + helper scripts (sources only — no built objects). +for d in include compat ofed_scripts ; do + if [ -e "$_devel_src/$d" ]; then + cp -a "$_devel_src/$d" "$_devel_dst/" + fi +done +# config.h / config.mk / configure.mk.kernel — produced by `./configure`. +for f in "$_devel_src"/config* "$_devel_src"/Makefile "$_devel_src"/makefile ; do + [ -e "$f" ] && cp -a "$f" "$_devel_dst/" +done + +# Concat every Module.symvers produced by `make kernel` (one per built +# module subdir) into a single symvers in the staged tree. Fallback to the +# upstream helper if no per-module symvers were emitted. +_modsyms=$(find "$_devel_src" -name 'Module.symvers' -o -name 'Modules.symvers' 2>/dev/null || true) +: > "$_devel_dst/Module.symvers" +if [ -n "$_modsyms" ]; then + for ms in $_modsyms ; do + cat "$ms" >> "$_devel_dst/Module.symvers" + done +else + ( cd "$_devel_src" && ./ofed_scripts/create_Module.symvers.sh ) + cp -a "$_devel_src/Module.symvers" "$_devel_dst/Module.symvers" +fi + +# Drop anything that's not a source artifact (object files, kernel modules, +# upstream test stubs) — devel ships sources only. +find "$_devel_dst" \( -name '*.o' -o -name '*.ko' -o -name '*.ko.gz' \ + -o -name '*.ko.xz' -o -name '*.ko.zst' \) -delete +rm -rf "$_devel_dst/compat/modtest" + +# Rewrite the buildroot-relative BACKPORT_INCLUDES path in configure.mk.kernel +# so downstream out-of-tree builds resolve it from the installed location. +if [ -f "$_devel_dst/configure.mk.kernel" ]; then + sed -i -e "s|=-I.*backport_includes|=-I%{_prefix}/src/ofa_kernel/%{_arch}/%{KVERREL}/backport_includes|" \ + "$_devel_dst/configure.mk.kernel" || true +fi +%endif + +%endif + +# ========================================================================= +# Phase: files — scriptlets and file list +# ========================================================================= +%if "%{_kmod_phase}" == "files" && %{with_up_base} + +%ifarch x86_64 aarch64 +%post -n kmod-%{_kmod_name}-%{mlnx_ofa_version} +%{_sbindir}/depmod -a %{KVERREL} || : + +%postun -n kmod-%{_kmod_name}-%{mlnx_ofa_version} +%{_sbindir}/depmod -a %{KVERREL} || : + +%files -n kmod-%{_kmod_name}-%{mlnx_ofa_version} +%license %{_datadir}/licenses/kmod-%{_kmod_name}-%{mlnx_ofa_version}/COPYING +/lib/modules/%{KVERREL}/extra/mlnx-ofa_kernel/ + +%files -n kmod-%{_kmod_name}-devel-%{mlnx_ofa_version} +%license %{_datadir}/licenses/kmod-%{_kmod_name}-%{mlnx_ofa_version}/COPYING +%dir %{_prefix}/src/ofa_kernel +%dir %{_prefix}/src/ofa_kernel/%{_arch} +%{_prefix}/src/ofa_kernel/%{_arch}/%{KVERREL} +%endif + +%endif diff --git a/locks/kernel.lock b/locks/kernel.lock index c813aaf1bb7..bfbf5410d98 100644 --- a/locks/kernel.lock +++ b/locks/kernel.lock @@ -2,5 +2,5 @@ version = 1 import-commit = '5271a1b047ef402ddee40242e02eda23fc273044' upstream-commit = '5271a1b047ef402ddee40242e02eda23fc273044' -input-fingerprint = 'sha256:35fd40d8d7ed26e4e80c412fbe33499ead22ceac032a92c1be2f3c2f729f7df3' +input-fingerprint = 'sha256:6c03b501297788bd15adea837b6a1c9165cef07fe671659e260f56a8a6d50610' resolution-input-hash = 'sha256:466421704711c4fd3c71f0b2ed715a0e61d49e3e26f3a2637fee755795849c8e' diff --git a/specs/k/kernel/kernel.azl.macros b/specs/k/kernel/kernel.azl.macros index ce244463e57..bc63a143673 100644 --- a/specs/k/kernel/kernel.azl.macros +++ b/specs/k/kernel/kernel.azl.macros @@ -2,6 +2,9 @@ # Do not edit manually; changes will be overwritten. %_without_debug 1 %_without_selftests 1 -%azl_pkgrelease 5 +%azl_pkgrelease 6 %kextraversion 1 +%mlnx_ofa_bundle_release 0.8.5.0 +%mlnx_ofa_release OFED.26.04.0.8.5.1 +%mlnx_ofa_version 26.04 %nvidia_open_version 595.58.03 diff --git a/specs/k/kernel/kernel.spec b/specs/k/kernel/kernel.spec index c247915d3b1..c55be95ae83 100644 --- a/specs/k/kernel/kernel.spec +++ b/specs/k/kernel/kernel.spec @@ -1177,6 +1177,8 @@ Source5002: azurelinux-ca-20230216.pem Source6000: open-gpu-kernel-modules-%{nvidia_open_version}.tar.gz Source6001: kmod-nvidia-open-modprobe.conf Source6002: kmod-nvidia-open.inc +Source6100: MLNX_OFED_SRC-%{mlnx_ofa_version}-%{mlnx_ofa_bundle_release}.tgz +Source6101: kmod-mlnx-ofa_kernel.inc ## Patches needed for building this package @@ -1233,6 +1235,11 @@ AutoProv: yes\ %global _kmod_name nvidia-open %include %{_sourcedir}/kmod-nvidia-open.inc +# AZL: kmod subpackage declarations (mlnx-ofa_kernel) +%global _kmod_phase package +%global _kmod_name mlnx-ofa_kernel +%include %{_sourcedir}/kmod-mlnx-ofa_kernel.inc + # AZL-KMOD-PACKAGE-ANCHOR — do not remove (kmod overlays chain here) %package doc Summary: Various documentation bits found in the kernel source @@ -2261,6 +2268,11 @@ cd ../.. %global _kmod_name nvidia-open %include %{_sourcedir}/kmod-nvidia-open.inc +# AZL: Prepare kmod subpackage sources (mlnx-ofa_kernel) +%global _kmod_phase prep +%global _kmod_name mlnx-ofa_kernel +%include %{_sourcedir}/kmod-mlnx-ofa_kernel.inc + # AZL-KMOD-PREP-ANCHOR — do not remove (kmod overlays chain here) %build %{log_msg "Start of build stage"} @@ -3399,6 +3411,11 @@ find Documentation -type d | xargs chmod u+w %global _kmod_name nvidia-open %include %{_sourcedir}/kmod-nvidia-open.inc +# AZL: Build kmod subpackage modules (mlnx-ofa_kernel) +%global _kmod_phase build +%global _kmod_name mlnx-ofa_kernel +%include %{_sourcedir}/kmod-mlnx-ofa_kernel.inc + # AZL-KMOD-BUILD-ANCHOR — do not remove (kmod overlays chain here) # Module signing (modsign) @@ -3907,6 +3924,11 @@ popd %global _kmod_name nvidia-open %include %{_sourcedir}/kmod-nvidia-open.inc +# AZL: Install kmod subpackage files (mlnx-ofa_kernel) +%global _kmod_phase install +%global _kmod_name mlnx-ofa_kernel +%include %{_sourcedir}/kmod-mlnx-ofa_kernel.inc + # AZL-KMOD-INSTALL-ANCHOR — do not remove (kmod overlays chain here) ### @@ -4576,8 +4598,16 @@ fi\ %global _kmod_name nvidia-open %include %{_sourcedir}/kmod-nvidia-open.inc +# AZL: kmod subpackage file lists and scriptlets (mlnx-ofa_kernel) +%global _kmod_phase files +%global _kmod_name mlnx-ofa_kernel +%include %{_sourcedir}/kmod-mlnx-ofa_kernel.inc + # AZL-KMOD-FILES-ANCHOR — do not remove (kmod overlays chain here) %changelog +* Wed Jun 10 2026 Elaheh Dehghani - 6.18.31-1.6 +- feat(kernel): add kmod-mlnx-ofa_kernel subpackage (mlnx-ofa_kernel 26.04, NIC+RDMA+IPoIB) + * Wed May 27 2026 Daniel McIlvaney - 6.18.31-1.5 - feat(kernel): add hand-curated changelog entry diff --git a/specs/k/kernel/kmod-mlnx-ofa_kernel.inc b/specs/k/kernel/kmod-mlnx-ofa_kernel.inc new file mode 100644 index 00000000000..eb53f980c94 --- /dev/null +++ b/specs/k/kernel/kmod-mlnx-ofa_kernel.inc @@ -0,0 +1,284 @@ +# kmod-mlnx-ofa_kernel.inc — NVIDIA / Mellanox OFED kernel modules (mlnx-ofa_kernel) +# +# Phases: package, prep, build, install, files +# Activated by: setting _kmod_phase + _kmod_name globals and including this +# file from kernel.comp.toml overlays. +# +# Requires these defines/sources in kernel.spec (injected via comp.toml overlays): +# mlnx_ofa_version — driver tag (e.g. 26.04) +# mlnx_ofa_release — vendor release stamp (e.g. OFED.26.04.0.8.5.1) +# SOURCE6100 — MLNX_OFED_SRC-%{mlnx_ofa_version}-%{mlnx_ofa_bundle_release}.tgz bundle +# + +# ========================================================================= +# Phase: package — subpackage declaration +# ========================================================================= +%if "%{_kmod_phase}" == "package" && %{with_up_base} + +%ifarch x86_64 aarch64 +%package -n kmod-%{_kmod_name}-%{mlnx_ofa_version} +Summary: Mellanox OFED kernel modules (mlnx-ofa_kernel %{mlnx_ofa_version}) +AutoReq: no +Provides: mlnx-ofa-kmod-version = %{mlnx_ofa_version} +Provides: mlnx-ofa-kmod-release = %{mlnx_ofa_release} +Provides: kmod-%{_kmod_name} = %{version}-%{release} +Provides: kmod-mlnx-ofa = %{version}-%{release} +Obsoletes: kmod-mlnx-ofa < %{version}-%{release} +Provides: installonlypkg(kernel-module) +Requires: %{name}-core-uname-r = %{KVERREL} +Requires(post): kmod +Requires(postun): kmod + +%description -n kmod-%{_kmod_name}-%{mlnx_ofa_version} +NVIDIA / Mellanox InfiniBand and Ethernet (mlx5) kernel modules built from +mlnx-ofa_kernel %{mlnx_ofa_version} (%{mlnx_ofa_release}) against kernel +%{KVERREL}. + +# ------------------------------------------------------------------------- +# -devel: headers + Module.symvers + helper scripts for building out-of-tree +# kernel modules (e.g. nv-peer-mem, GPUDirect) against this kmod. Lives in +# the kmod (not the userspace comp) because the symvers + backport-shim +# headers are produced by *this* build and are tied to this exact kernel. +# ------------------------------------------------------------------------- +%package -n kmod-%{_kmod_name}-devel-%{mlnx_ofa_version} +Summary: Development files for kmod-%{_kmod_name}-%{mlnx_ofa_version} +AutoReq: no +Requires: kmod-%{_kmod_name}-%{mlnx_ofa_version} = %{version}-%{release} +Requires: coreutils +Requires: pciutils +Provides: mlnx-ofa-kmod-devel-version = %{mlnx_ofa_version} +Provides: mlnx-ofa-kmod-devel-release = %{mlnx_ofa_release} +Provides: kmod-%{_kmod_name}-devel = %{version}-%{release} + +%description -n kmod-%{_kmod_name}-devel-%{mlnx_ofa_version} +Development files for kmod-%{_kmod_name}-%{mlnx_ofa_version}: backport +headers, compat layer, Module.symvers, and the ofed_scripts helpers used +by out-of-tree modules (e.g. nv-peer-mem) that link against the mlnx-ofa +NIC/RDMA stack rather than the in-tree mlx5/RDMA drivers. + +Files install under /usr/src/ofa_kernel/%{_arch}/%{KVERREL}/ and are tied +to the kernel build that produced them. Multiple kernel versions can +coexist (one devel tree per kernel build). +%endif + +%endif + +# ========================================================================= +# Phase: prep — extract mlnx-ofa_kernel tarball from MLNX_OFED_SRC bundle +# ========================================================================= +%if "%{_kmod_phase}" == "prep" && %{with_up_base} + +%ifarch x86_64 aarch64 +# %{SOURCE6100} is the MLNX_OFED_SRC bundle (a tar of every Mellanox OFED +# SRPM). We don't need the whole bundle — just the mlnx-ofa_kernel SRPM — +# and from that SRPM we only need the mlnx-ofa_kernel-.tgz source tarball. +pushd %{_builddir} +%{log_msg "Extracting MLNX_OFED_SRC bundle to fetch mlnx-ofa_kernel sources"} +tar -xf %{SOURCE6100} +_mofa_srpm=$(find MLNX_OFED_SRC-* -path '*/SRPMS/mlnx-ofa_kernel-*.src.rpm' \ + -print -quit) +if [ -z "$_mofa_srpm" ]; then + echo "ERROR: mlnx-ofa_kernel SRPM not found inside %{SOURCE6100}" >&2 + exit 1 +fi +rpm2cpio "$_mofa_srpm" | cpio -idm '*mlnx-ofa_kernel-%{mlnx_ofa_version}.tgz' +tar -xf mlnx-ofa_kernel-%{mlnx_ofa_version}.tgz +rm -rf MLNX_OFED_SRC-* mlnx-ofa_kernel-%{mlnx_ofa_version}.tgz +popd +%endif + +%endif + +# ========================================================================= +# Phase: build — compile mlnx-ofa kernel modules +# ========================================================================= +%if "%{_kmod_phase}" == "build" && %{with_up_base} + +%ifarch x86_64 aarch64 +%{log_msg "Building mlnx-ofa_kernel %{mlnx_ofa_version} modules for %{KVERREL}"} +pushd %{_builddir}/mlnx-ofa_kernel-%{mlnx_ofa_version} + +# Upstream mlnx-ofa_kernel.spec stamps compat shims to a fixed epoch to keep +# autoconf/automake-style timestamp checks happy in the kbuild Makefiles. Same +# trick here; safe no-op if `compat/` is absent. +find compat -type f -exec touch -t 200012201010 '{}' \; || true + +CFLAGS=$(echo "${CFLAGS}" \ + | sed -e 's|-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1||g' \ + -e 's|-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1||g' \ + -e 's|-fexceptions||g') +export CFLAGS="${CFLAGS} -fno-exceptions" +unset CXXFLAGS +unset LDFLAGS + +./configure \ + --build-dummy-mods \ + --prefix=%{_prefix} \ + --kernel-version "%{KVERREL}" \ + --kernel-sources "%{_builddir}/kernel-%{tarfile_release}/linux-%{KVERREL}" \ + --modules-dir "/lib/modules/%{KVERREL}/extra/mlnx-ofa_kernel" \ + --with-core-mod \ + --with-user_mad-mod \ + --with-user_access-mod \ + --with-addr_trans-mod \ + --with-mlx5-mod \ + --with-mlxfw-mod \ + --with-ipoib-mod \ + %{?_smp_mflags} + +make %{?_smp_mflags} kernel + +popd +%endif + +%endif + +# ========================================================================= +# Phase: install — install modules +# ========================================================================= +%if "%{_kmod_phase}" == "install" && %{with_up_base} + +%ifarch x86_64 aarch64 +%{log_msg "Installing mlnx-ofa_kernel modules for %{KVERREL}"} +pushd %{_builddir}/mlnx-ofa_kernel-%{mlnx_ofa_version} + +# mlnx-ofa's `install_modules` recipe runs depmod, which overwrites the +# parent kernel's modules.{builtin,order,*}. Snapshot those before install +# and restore them after, otherwise kernel-core's %files (which lists +# /lib/modules/%{KVERREL}/modules.builtin*) will fail with "File not found". +_mods_dir="%{buildroot}/lib/modules/%{KVERREL}" +_mods_snap="%{_builddir}/mlnx-ofa-mods-snapshot" +rm -rf "$_mods_snap" +if [ -d "$_mods_dir" ]; then + mkdir -p "$_mods_snap" + find "$_mods_dir" -maxdepth 1 -name 'modules.*' -type f \ + -exec cp -a {} "$_mods_snap/" \; +fi + +export INSTALL_MOD_PATH=%{buildroot} +export INSTALL_MOD_DIR=extra/mlnx-ofa_kernel +make install_modules KERNELRELEASE=%{KVERREL} + +popd + +# Drop the modules.{dep,order,builtin,...} files that mlnx-ofa's install just +# wrote, then restore the parent kernel's originals from the snapshot. The +# kernel %post regenerates depmod state at install time on the target system. +find "$_mods_dir" -maxdepth 1 -name 'modules.*' -type f -exec rm -f {} \; +if [ -d "$_mods_snap" ]; then + cp -a "$_mods_snap"/. "$_mods_dir/" + rm -rf "$_mods_snap" +fi + +# Make installed modules executable so they get stripped + debuginfo extracted +# when the package is built (rpmbuild only strips u+x files). +find %{buildroot}/lib/modules/%{KVERREL}/extra/mlnx-ofa_kernel \ + \( -type f -name '*.ko' -o -name '*.ko.gz' -o -name '*.ko.xz' -o -name '*.ko.zst' \) \ + -exec chmod u+x {} \; + +# Strip .BTF sections from installed modules to avoid runtime validation +# failures observed on target VMs ("Invalid name" / BTF: -22). +if command -v objcopy >/dev/null 2>&1; then +find %{buildroot}/lib/modules/%{KVERREL}/extra/mlnx-ofa_kernel \ + \( -name '*.ko' -o -name '*.ko.gz' -o -name '*.ko.xz' -o -name '*.ko.zst' \) | \ +while read -r f; do + case "$f" in + *.ko) + objcopy --remove-section .BTF --remove-section .BTF.ext "$f" || true + ;; + *.ko.gz) + gzip -dkf "$f" + ko="${f%.gz}" + objcopy --remove-section .BTF --remove-section .BTF.ext "$ko" || true + gzip -f "$ko" + ;; + *.ko.xz) + xz -dkf "$f" + ko="${f%.xz}" + objcopy --remove-section .BTF --remove-section .BTF.ext "$ko" || true + xz -zf "$ko" + ;; + *.ko.zst) + zstd -q -d -f "$f" -o "${f%.zst}" + ko="${f%.zst}" + objcopy --remove-section .BTF --remove-section .BTF.ext "$ko" || true + zstd -q -f "$ko" -o "$f" + rm -f "$ko" + ;; + esac +done +fi + +install -D -m 0644 %{_builddir}/mlnx-ofa_kernel-%{mlnx_ofa_version}/COPYING \ + %{buildroot}%{_datadir}/licenses/kmod-%{_kmod_name}-%{mlnx_ofa_version}/COPYING + +%{log_msg "Staging mlnx-ofa_kernel devel tree for %{KVERREL}"} +_devel_src="%{_builddir}/mlnx-ofa_kernel-%{mlnx_ofa_version}" +_devel_dst="%{buildroot}%{_prefix}/src/ofa_kernel/%{_arch}/%{KVERREL}" +mkdir -p "$_devel_dst" + +# Headers + compat shims + helper scripts (sources only — no built objects). +for d in include compat ofed_scripts ; do + if [ -e "$_devel_src/$d" ]; then + cp -a "$_devel_src/$d" "$_devel_dst/" + fi +done +# config.h / config.mk / configure.mk.kernel — produced by `./configure`. +for f in "$_devel_src"/config* "$_devel_src"/Makefile "$_devel_src"/makefile ; do + [ -e "$f" ] && cp -a "$f" "$_devel_dst/" +done + +# Concat every Module.symvers produced by `make kernel` (one per built +# module subdir) into a single symvers in the staged tree. Fallback to the +# upstream helper if no per-module symvers were emitted. +_modsyms=$(find "$_devel_src" -name 'Module.symvers' -o -name 'Modules.symvers' 2>/dev/null || true) +: > "$_devel_dst/Module.symvers" +if [ -n "$_modsyms" ]; then + for ms in $_modsyms ; do + cat "$ms" >> "$_devel_dst/Module.symvers" + done +else + ( cd "$_devel_src" && ./ofed_scripts/create_Module.symvers.sh ) + cp -a "$_devel_src/Module.symvers" "$_devel_dst/Module.symvers" +fi + +# Drop anything that's not a source artifact (object files, kernel modules, +# upstream test stubs) — devel ships sources only. +find "$_devel_dst" \( -name '*.o' -o -name '*.ko' -o -name '*.ko.gz' \ + -o -name '*.ko.xz' -o -name '*.ko.zst' \) -delete +rm -rf "$_devel_dst/compat/modtest" + +# Rewrite the buildroot-relative BACKPORT_INCLUDES path in configure.mk.kernel +# so downstream out-of-tree builds resolve it from the installed location. +if [ -f "$_devel_dst/configure.mk.kernel" ]; then + sed -i -e "s|=-I.*backport_includes|=-I%{_prefix}/src/ofa_kernel/%{_arch}/%{KVERREL}/backport_includes|" \ + "$_devel_dst/configure.mk.kernel" || true +fi +%endif + +%endif + +# ========================================================================= +# Phase: files — scriptlets and file list +# ========================================================================= +%if "%{_kmod_phase}" == "files" && %{with_up_base} + +%ifarch x86_64 aarch64 +%post -n kmod-%{_kmod_name}-%{mlnx_ofa_version} +%{_sbindir}/depmod -a %{KVERREL} || : + +%postun -n kmod-%{_kmod_name}-%{mlnx_ofa_version} +%{_sbindir}/depmod -a %{KVERREL} || : + +%files -n kmod-%{_kmod_name}-%{mlnx_ofa_version} +%license %{_datadir}/licenses/kmod-%{_kmod_name}-%{mlnx_ofa_version}/COPYING +/lib/modules/%{KVERREL}/extra/mlnx-ofa_kernel/ + +%files -n kmod-%{_kmod_name}-devel-%{mlnx_ofa_version} +%license %{_datadir}/licenses/kmod-%{_kmod_name}-%{mlnx_ofa_version}/COPYING +%dir %{_prefix}/src/ofa_kernel +%dir %{_prefix}/src/ofa_kernel/%{_arch} +%{_prefix}/src/ofa_kernel/%{_arch}/%{KVERREL} +%endif + +%endif diff --git a/specs/k/kernel/sources b/specs/k/kernel/sources index 84ea812b65b..feecbb99632 100644 --- a/specs/k/kernel/sources +++ b/specs/k/kernel/sources @@ -3,3 +3,4 @@ SHA512 (kernel-abi-stablelists-6.18.13.tar.xz) = 69bbcdd86ae7999b19de306c29bc5ce SHA512 (kernel-kabi-dw-6.18.13.tar.xz) = 6473ea636d813e602a59d7332255c4b4597032501a2ed0507985800500451065618a0b6909663e3dc8db2b75c6f4ba10d498dbc41a3b42758cae38f30ca13115 SHA512 (kernel-6.18.31.1.tar.gz) = 1bf684812ff3fc38974dc99b3e2309cb46dc5af93ac794e79a4a4f3dd17debfadb14510aeaaa7fa2d4c6254876a9f8bc67b900a1951c8dda5d94e5f5028a7557 SHA512 (open-gpu-kernel-modules-595.58.03.tar.gz) = a422b6935209d590f57fa6766f59bb207d9130f8a6777af9245c4ff8cd0f4c4ccef4602a0b26d543e1e8efba24241180992fdb749ea4e5d2aa5218a584b85101 +SHA512 (MLNX_OFED_SRC-26.04-0.8.5.0.tgz) = 1829d190f84f6d54597b98c40e162afa64939e608f7eaf494ac626c454e4d0310e14dedb7108326e9c9a667634eb27cf751dae806249f1783a66c8fc07aacd13