Skip to content

Commit e31b1c7

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 e31b1c7

File tree

4 files changed

+64
-18
lines changed

4 files changed

+64
-18
lines changed

packages/kernel-6.1/1001-Makefile-add-prepare-target-for-external-modules.patch

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From e6e9b5adc830c0924d81c348c8d5b12e3dc4242e Mon Sep 17 00:00:00 2001
1+
From 0484df519ed944a0e164b4d104e1adc9e851fc0f Mon Sep 17 00:00:00 2001
22
From: Ben Cressey <[email protected]>
33
Date: Mon, 19 Apr 2021 18:46:04 +0000
44
Subject: [PATCH] Makefile: add prepare target for external modules
@@ -27,19 +27,19 @@ Signed-off-by: Arnaldo Garcia Rincon <[email protected]>
2727
1 file changed, 13 insertions(+)
2828

2929
diff --git a/Makefile b/Makefile
30-
index 23390805e..2f78ac123 100644
30+
index d8625400c..61273e589 100644
3131
--- a/Makefile
3232
+++ b/Makefile
33-
@@ -1874,6 +1874,19 @@ else # KBUILD_EXTMOD
33+
@@ -1891,6 +1891,19 @@ else # KBUILD_EXTMOD
3434
KBUILD_BUILTIN :=
3535
KBUILD_MODULES := 1
3636

3737
+PHONY += modules_prepare
3838
+modules_prepare:
39-
+ $(Q)$(MAKE) $(build)=scripts/basic
40-
+ $(Q)$(MAKE) $(build)=scripts/dtc
41-
+ $(Q)$(MAKE) $(build)=scripts/mod
42-
+ $(Q)$(MAKE) $(build)=scripts
39+
+ $(PREPARE) $(Q)$(MAKE) $(build)=scripts/basic
40+
+ $(PREPARE) $(Q)$(MAKE) $(build)=scripts/dtc
41+
+ $(PREPARE) $(Q)$(MAKE) $(build)=scripts/mod
42+
+ $(PREPARE) $(Q)$(MAKE) $(build)=scripts
4343
+
4444
+ifdef CONFIG_OBJTOOL
4545
+prepare: tools/objtool
@@ -51,5 +51,5 @@ index 23390805e..2f78ac123 100644
5151

5252
compile_commands.json: $(extmod_prefix)compile_commands.json
5353
--
54-
2.40.0
54+
2.50.1
5555

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: 40 additions & 10 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.
@@ -221,7 +225,7 @@ for patch in ${patches[@]}; do
221225
patch -p1 <../"$patch"
222226
done
223227
# Patches listed in this spec (Patch0001...)
224-
%autopatch -p1
228+
%autopatch -p1 -m 1000 -M 1999
225229

226230
%if "%{_cross_arch}" == "x86_64"
227231
microcode="$(find %{_cross_libdir}/firmware -type f -path '*/*-ucode/*' -printf '%%P\n' | sort | tr '\n' ' ')"
@@ -256,9 +260,9 @@ if ! diff "${KCONFIG_CONFIG}" "${SOURCE_FILE}"; then
256260
fi
257261

258262
rm -f ../config-* ../*.patch
263+
cd %{_builddir}
259264

260265
%if "%{_cross_arch}" == "x86_64"
261-
cd %{_builddir}
262266
# 2.21 for inf1 support
263267
rpmkeys --import %{S:4} --dbpath "${PWD}/rpmdb"
264268
rpmkeys --checksig %{S:2} --dbpath "${PWD}/rpmdb"
@@ -276,14 +280,25 @@ find usr/src/ -mindepth 1 -maxdepth 1 -type d -exec mv {} neuron_latest \;
276280
rm -r usr
277281
%endif
278282

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

288303
%build
289304
%kmake mrproper
@@ -296,6 +311,18 @@ make -s\\\
296311
%kmake %{?_smp_mflags} M=%{_builddir}/neuron_latest
297312
%endif
298313

314+
# Build EFA driver
315+
pushd %{_builddir}/efa_driver/build
316+
sed -i -e 's,$(MAKE),PREPARE=true %{kmake},g' ../config/Makefile
317+
318+
# Prevent polluting the parent environment by configuring CMAKE in a subshell
319+
(
320+
%{cross_cmake} ..
321+
)
322+
323+
%kmake %{?_smp_mflags} M=%{_builddir}/efa_driver/build modules
324+
popd
325+
299326
%install
300327
%kmake %{?_smp_mflags} headers_install
301328
%kmake %{?_smp_mflags} modules_install
@@ -309,6 +336,9 @@ mv %{buildroot}%{_cross_kmoddir}/neuron_2_21/neuron.ko.gz %{buildroot}%{_cross_l
309336
mv %{buildroot}%{_cross_kmoddir}/neuron_latest/neuron.ko.gz %{buildroot}%{_cross_libexecdir}/neuron/neuron_latest/
310337
%endif
311338

339+
%kmake %{?_smp_mflags} INSTALL_MOD_DIR=efa_driver M=%{_builddir}/efa_driver/build/src V=1 modules_install
340+
mv %{buildroot}%{_cross_kmoddir}/efa_driver/efa.ko.gz %{buildroot}%{_cross_kmoddir}/kernel/drivers/amazon/net/efa/
341+
312342
install -d %{buildroot}/boot
313343
install -T -m 0755 arch/%{_cross_karch}/boot/%{_cross_kimage} %{buildroot}/boot/vmlinuz
314344
install -m 0644 .config %{buildroot}/boot/config

0 commit comments

Comments
 (0)