Skip to content

Commit 4e91118

Browse files
committed
kernel-6.1: include efa from efa-installer
The EFA driver in the Amazon Linux kernel can have some delay between when the installer is released and it making it into the kernel tree. This adds a build step to update the driver from the installer to get the latest changes as soon as the installer is available. As part of this change, the `efa.cmake` file was updated to do a serial execution of the tests to validate the available configurations in the kernel sources. This is a problem unique to Bottlerocket due to how out of tree kmod builds are treated. Signed-off-by: Arnaldo Garcia Rincon <[email protected]>
1 parent 94d9271 commit 4e91118

File tree

4 files changed

+102
-9
lines changed

4 files changed

+102
-9
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
From ca4c769ebfd7aa545ace9ebe8df7e250619c1c8e Mon Sep 17 00:00:00 2001
2+
From: Arnaldo Garcia Rincon <[email protected]>
3+
Date: Wed, 12 Nov 2025 03:12:41 +0000
4+
Subject: [PATCH] config/efa.cmake: execute config tests in serial
5+
6+
Signed-off-by: Arnaldo Garcia Rincon <[email protected]>
7+
---
8+
config/efa.cmake | 10 ++--------
9+
1 file changed, 2 insertions(+), 8 deletions(-)
10+
11+
diff --git a/config/efa.cmake b/config/efa.cmake
12+
index 5bdad0b..02fc5f4 100644
13+
--- a/config/efa.cmake
14+
+++ b/config/efa.cmake
15+
@@ -53,15 +53,10 @@ include(ProcessorCount)
16+
ProcessorCount(max_process)
17+
18+
function(try_compile prologue body success_def fail_def)
19+
- # Rate limit processes
20+
- process_rl()
21+
set_conf_tmp_dir("${prologue}" "${body}")
22+
- execute_process(COMMAND ${CMAKE_SOURCE_DIR}/config/runbg.sh ${CMAKE_SOURCE_DIR}/config/compile_conftest.sh ${CMAKE_CURRENT_BINARY_DIR}/${tmp_dir} ${KERNEL_DIR} "${success_def}" "${fail_def}"
23+
+ execute_process(COMMAND ${CMAKE_SOURCE_DIR}/config/compile_conftest.sh ${CMAKE_CURRENT_BINARY_DIR}/${tmp_dir} ${KERNEL_DIR} "${success_def}" "${fail_def}"
24+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
25+
- OUTPUT_STRIP_TRAILING_WHITESPACE
26+
- OUTPUT_VARIABLE pid)
27+
- list(APPEND pids ${pid})
28+
- set(pids "${pids}" CACHE INTERNAL "")
29+
+ RESULT_VARIABLE res)
30+
endfunction()
31+
32+
function(try_compile_dev_or_ops fp_name prologue fn success_def fail_def)
33+
@@ -535,5 +530,4 @@ struct ib_mr *efa_reg_user_mr_dmabuf(struct ib_pd *ibpd, u64 start, u64 length,
34+
"
35+
HAVE_REG_USER_MR_DMAH "")
36+
37+
-wait_for_pids()
38+
message("-- Inspecting kernel - done")
39+
--
40+
2.50.1
41+

packages/kernel-6.1/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,9 @@ sha512 = "4bdb01d846f12a04bdbe6902c3008ebadbcb50d4d94e8f81b524c02a4e94da7041cdb5
2727
url = "https://yum.repos.neuron.amazonaws.com/aws-neuronx-dkms-2.24.7.0.noarch.rpm"
2828
sha512 = "2892ad1c6c4ff670d8e4aa0151af57b2b437f647a58ffa58901377b2ddeb504a9e4cce6c148643f8340e1ede8bb26ab66039b0a6bbb184bf5d647c6c71720186"
2929

30+
[[package.metadata.build-package.external-files]]
31+
url = "https://efa-installer.amazonaws.com/aws-efa-installer-1.44.0.tar.gz"
32+
sha512 = "eaa336d8eb2affed5f5960a133af9f98b2b113c2dde17246c51947324f2318710012e7bced124e73f7113c8261748aaa0f4856063d71340b2d85a7f089551526"
33+
3034
[build-dependencies]
3135
microcode = { path = "../microcode" }
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
cmake_minimum_required(VERSION 3.10)
2+
project(efa C)
3+
4+
set(KERNEL_VER "__KERNEL_VERSION__")
5+
set(KERNEL_DIR "__KERNEL_DIR__")
6+
set(KERNEL_MAKEFILE "__KERNEL_MAKEFILE__")
7+
8+
set(GCOV_PROFILE OFF CACHE BOOL "Enable GCOV profiling")
9+
set(ENABLE_P2P ON CACHE BOOL "Enable Peer-to-peer memory")
10+
set(ENABLE_KVERBS ON CACHE BOOL "Enable kernel verbs support")
11+
12+
add_subdirectory(src)

packages/kernel-6.1/kernel-6.1.spec

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Source2: https://yum.repos.neuron.amazonaws.com/aws-neuronx-dkms-2.21.37.0.noarc
1414
# Use latest-neuron-srpm-url.sh to get this.
1515
Source3: https://yum.repos.neuron.amazonaws.com/aws-neuronx-dkms-2.24.7.0.noarch.rpm
1616
Source4: gpgkey-00FA2C1079260870A76D2C285749CAD8646D9185.asc
17+
Source5: https://efa-installer.amazonaws.com/aws-efa-installer-1.44.0.tar.gz
1718

1819
# Custom Bottlerocket kernel configurations.
1920
Source100: config-bottlerocket
@@ -44,6 +45,9 @@ Source300: bootconfig-aws.conf
4445
Source301: bootconfig-vmware.conf
4546
Source302: bootconfig-metal.conf
4647

48+
# Replace upstream CMakeLists.txt with one that allows overriding kernel paths.
49+
Source400: EFACMakeLists.txt.in
50+
4751
# Help out-of-tree module builds run `make prepare` automatically.
4852
Patch1001: 1001-Makefile-add-prepare-target-for-external-modules.patch
4953
# Expose tools/* targets for out-of-tree module builds.
@@ -59,6 +63,8 @@ Patch1005: 1005-Revert-Revert-drm-fb_helper-improve-CONFIG_FB-depend.patch
5963
Patch1006: 1006-strscpy-write-destination-buffer-only-once.patch
6064
# Disable incomplete measurement into PCR 9 on aarch64.
6165
Patch1007: 1007-efi-libstub-don-t-measure-kernel-command-line-into-P.patch
66+
# Execute EFA tests in serial; concurrency doesn't work with the `make prepare` patch.
67+
Patch2000: 2000-config-efa.cmake-execute-config-tests-in-serial.patch
6268

6369
BuildRequires: bc
6470
BuildRequires: elfutils-devel
@@ -221,7 +227,7 @@ for patch in ${patches[@]}; do
221227
patch -p1 <../"$patch"
222228
done
223229
# Patches listed in this spec (Patch0001...)
224-
%autopatch -p1
230+
%autopatch -p1 -m 1000 -M 1999
225231

226232
%if "%{_cross_arch}" == "x86_64"
227233
microcode="$(find %{_cross_libdir}/firmware -type f -path '*/*-ucode/*' -printf '%%P\n' | sort | tr '\n' ' ')"
@@ -276,14 +282,29 @@ find usr/src/ -mindepth 1 -maxdepth 1 -type d -exec mv {} neuron_latest \;
276282
rm -r usr
277283
%endif
278284

279-
%global kmake \
280-
make -s\\\
281-
ARCH="%{_cross_karch}"\\\
282-
CROSS_COMPILE="%{_cross_target}-"\\\
283-
INSTALL_HDR_PATH="%{buildroot}%{_cross_prefix}"\\\
284-
INSTALL_MOD_PATH="%{buildroot}%{_cross_prefix}"\\\
285-
INSTALL_MOD_STRIP=1\\\
286-
%{nil}
285+
# EFA driver
286+
tar -xf %{S:5}
287+
rpm2cpio aws-efa-installer/RPMS/ALINUX2023/%{_cross_arch}/efa-driver/efa-*.%{_cross_arch}.rpm | cpio -idmu './usr/src/efa-*'
288+
find usr/src/ -mindepth 1 -maxdepth 1 -type d -exec mv {} efa_driver \;
289+
rm -r aws-efa-installer
290+
mkdir efa_driver/build
291+
sed \
292+
-e "s|__KERNEL_VERSION__|%{version}|g" \
293+
-e "s|__KERNEL_DIR__|%{builddir}/linux-%{version}|g" \
294+
-e "s|__KERNEL_MAKEFILE__|%{builddir}/linux-%{version}/Makefile|g" %{S:400} > efa_driver/CMakeLists.txt
295+
296+
pushd efa_driver
297+
%patch -P 2000 -p1 -d .
298+
popd
299+
300+
%global kmake %{shrink: \
301+
make -s \
302+
ARCH="%{_cross_karch}" \
303+
CROSS_COMPILE="%{_cross_target}-" \
304+
INSTALL_HDR_PATH="%{buildroot}%{_cross_prefix}" \
305+
INSTALL_MOD_PATH="%{buildroot}%{_cross_prefix}" \
306+
INSTALL_MOD_STRIP=1 \
307+
%{nil}}
287308

288309
%build
289310
%kmake mrproper
@@ -296,6 +317,18 @@ make -s\\\
296317
%kmake %{?_smp_mflags} M=%{_builddir}/neuron_latest
297318
%endif
298319

320+
# Build EFA driver
321+
pushd %{_builddir}/efa_driver/build
322+
sed -i -e 's,$(MAKE),%{kmake},g' ../config/Makefile
323+
324+
# Prevent polluting the parent environment by configuring CMAKE in a subshell
325+
(
326+
%{cross_cmake} ..
327+
)
328+
329+
%kmake %{?_smp_mflags} M=%{_builddir}/efa_driver/build modules
330+
popd
331+
299332
%install
300333
%kmake %{?_smp_mflags} headers_install
301334
%kmake %{?_smp_mflags} modules_install
@@ -309,6 +342,9 @@ mv %{buildroot}%{_cross_kmoddir}/neuron_2_21/neuron.ko.gz %{buildroot}%{_cross_l
309342
mv %{buildroot}%{_cross_kmoddir}/neuron_latest/neuron.ko.gz %{buildroot}%{_cross_libexecdir}/neuron/neuron_latest/
310343
%endif
311344

345+
%kmake %{?_smp_mflags} INSTALL_MOD_DIR=efa_driver M=%{_builddir}/efa_driver/build/src V=1 modules_install
346+
mv %{buildroot}%{_cross_kmoddir}/efa_driver/efa.ko.gz %{buildroot}%{_cross_kmoddir}/kernel/drivers/amazon/net/efa/
347+
312348
install -d %{buildroot}/boot
313349
install -T -m 0755 arch/%{_cross_karch}/boot/%{_cross_kimage} %{buildroot}/boot/vmlinuz
314350
install -m 0644 .config %{buildroot}/boot/config

0 commit comments

Comments
 (0)