From 787c0da3531fbd0f3e62282c2a7c7221d3190918 Mon Sep 17 00:00:00 2001 From: Douglas Raillard Date: Tue, 18 Mar 2025 19:23:17 +0000 Subject: [PATCH 1/5] lisa._kmod: Bump Alpine release to 3.21.3 FEATURE Allow using LLVM 19 with 3.21 release. --- lisa/_kmod.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisa/_kmod.py b/lisa/_kmod.py index d5ac168c2..3727f9fa4 100644 --- a/lisa/_kmod.py +++ b/lisa/_kmod.py @@ -189,7 +189,7 @@ class KmodVersionError(Exception): pass -_ALPINE_DEFAULT_VERSION = '3.20.3' +_ALPINE_DEFAULT_VERSION = '3.21.3' _ALPINE_ROOTFS_URL = 'https://dl-cdn.alpinelinux.org/alpine/v{minor}/releases/{arch}/alpine-minirootfs-{version}-{arch}.tar.gz' _ALPINE_PACKAGE_INFO_URL = 'https://pkgs.alpinelinux.org/package/v{version}/{repo}/{arch}/{package}' -- GitLab From 2af6f261f1c0d2ba5592a33759980019cfcf5833 Mon Sep 17 00:00:00 2001 From: Douglas Raillard Date: Tue, 18 Mar 2025 14:01:29 +0000 Subject: [PATCH 2/5] lisa._kmod: Avoid conflict in kernel tree cache keys FIX Ensure that we don't accidentally have cache key conflict between the different sources of the kernel tree (downloaded from URL, from local tree etc). --- lisa/_kmod.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lisa/_kmod.py b/lisa/_kmod.py index 3727f9fa4..d20da9909 100644 --- a/lisa/_kmod.py +++ b/lisa/_kmod.py @@ -2448,6 +2448,7 @@ class _KernelBuildEnv(Loggable, SerializeViaConstructor): checksum=dir_cache.get_key_token(key), ) else: + logger.debug(f'Kernel tree prepare step will not be cached as no cache key could be computed for it.') with _overlay_folders([base_path], backend=overlay_backend, copy_filter=copy_filter) as path: prepare_overlay(path) yield dict( @@ -2466,15 +2467,17 @@ class _KernelBuildEnv(Loggable, SerializeViaConstructor): repo_root = git.find_root(tree_path) sha1 = git.get_sha1(tree_path) patch = git.get_uncommitted_patch(tree_path) - except (FileNotFoundError, subprocess.CalledProcessError): - key = None + except (FileNotFoundError, subprocess.CalledProcessError) as e: + logger.debug(f'Could not compute a cache key for kernel tree at {tree_path}: ({e.__class__.__qualname__}) {e}') + tree_key = None else: if repo_root.resolve() == Path(tree_path).resolve(): patch_sha1 = hashlib.sha1(patch.encode()).hexdigest() - key = f'{sha1}-{patch_sha1}' + tree_key = ('checksum', f'{sha1}-{patch_sha1}') else: - key = None - yield (tree_path, key) + logger.debug(f'Could not compute a cache key for kernel tree at {tree_path} as the root of the kernel tree is not the root of a git repository') + tree_key = None + yield (tree_path, tree_key) elif version is None: raise ValueError('Kernel version is required in order to download the kernel sources') elif cache: @@ -2488,13 +2491,13 @@ class _KernelBuildEnv(Loggable, SerializeViaConstructor): # Assume that the URL will always provide the same tarball yield ( dir_cache.get_entry(url), - url, + ('url', url), ) else: with tempfile.TemporaryDirectory() as path: yield ( cls._make_tree(version, path), - version, + ('version', version), ) cm = chain_cm(overlay_cm, tree_cm) -- GitLab From 63b9a225a478dbf1a896e7cdb09f99317571e1af Mon Sep 17 00:00:00 2001 From: Douglas Raillard Date: Wed, 19 Mar 2025 11:04:36 +0000 Subject: [PATCH 3/5] lisa._assets.kmodules.lisa: Remove unused Rust #[feature(...)] --- lisa/_assets/kmodules/lisa/rust/lisakmod/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/lisa/_assets/kmodules/lisa/rust/lisakmod/src/lib.rs b/lisa/_assets/kmodules/lisa/rust/lisakmod/src/lib.rs index 226e0bea7..fc30807c7 100644 --- a/lisa/_assets/kmodules/lisa/rust/lisakmod/src/lib.rs +++ b/lisa/_assets/kmodules/lisa/rust/lisakmod/src/lib.rs @@ -1,7 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 */ #![no_std] #![no_builtins] -#![feature(once_cell_try)] #![feature(adt_const_params)] #![feature(maybe_uninit_fill)] #![feature(coerce_unsized)] -- GitLab From 7f7db04e7508ea59b74123d578f3aa112b157163 Mon Sep 17 00:00:00 2001 From: Douglas Raillard Date: Wed, 19 Mar 2025 14:20:14 +0000 Subject: [PATCH 4/5] lisa._assets.kmodules.lisa: Fix Rust cconstant!() for 0 value FIX Ensure the value 0 for expressions is correctly processed. --- lisa/_assets/kmodules/lisa/lisa-eval-c.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lisa/_assets/kmodules/lisa/lisa-eval-c.sh b/lisa/_assets/kmodules/lisa/lisa-eval-c.sh index 7126f1a6b..687ac9e35 100755 --- a/lisa/_assets/kmodules/lisa/lisa-eval-c.sh +++ b/lisa/_assets/kmodules/lisa/lisa-eval-c.sh @@ -21,9 +21,11 @@ trap cleanup EXIT # extract the symbol size from the symbol table after compiling. This is works # reliably on any compiler and provides the value in hex format. +# We add +1 to the expression, as symbol size for a zero-sized array seems to +# be 1 weirdly enough. That +1 is then substracted in the awk post-processing cat > $src << EOM $c_headers -static char __attribute__((used)) LISA_C_CONST_VALUE[$c_expr]; +static char __attribute__((used)) LISA_C_CONST_VALUE[($c_expr) + 1]; EOM CC=${CC:=cc} @@ -54,5 +56,5 @@ fi # All -I are relative to the kernel tree root, so we need to run from there. cd "$KERNEL_SRC" && -$CC $LISA_EVAL_C_CFLAGS "${clang_args[@]}" -c "$src" -o "$object" && $NM -S "$object" | awk '{if ($4 == "LISA_C_CONST_VALUE") {print "0x" $2}}' +$CC $LISA_EVAL_C_CFLAGS "${clang_args[@]}" -c "$src" -o "$object" && $NM -S "$object" | awk '{if ($4 == "LISA_C_CONST_VALUE") {print strtonum("0x" $2) - 1}}' -- GitLab From b2b6d4b80b67d6c345bcc04d557642b4f29c5212 Mon Sep 17 00:00:00 2001 From: Douglas Raillard Date: Wed, 19 Mar 2025 17:53:33 +0000 Subject: [PATCH 5/5] lisa._assets.kmodules.lisa: Add support for CONFIG_SHADOW_CALL_STACK=y FEATURE Enable the -Zfixed-x18 rustc option to be compatible with the shadow-call-stack sanitizer. --- lisa/_assets/kmodules/lisa/Makefile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lisa/_assets/kmodules/lisa/Makefile b/lisa/_assets/kmodules/lisa/Makefile index 857ef2eb4..17b972429 100644 --- a/lisa/_assets/kmodules/lisa/Makefile +++ b/lisa/_assets/kmodules/lisa/Makefile @@ -32,6 +32,15 @@ clean-files := $(GENERATED) RUST_VERSION ?= nightly RUSTFLAGS := -Clinker=rust-lld -Clink-self-contained=y -Clto=n -Crelocation-model=static -Cno-redzone=y -Ctarget-cpu=generic -Cforce-frame-pointers=y -Ccodegen-units=1 -Zfunction-sections=y +# For now, simply make Rust transparent wrt to the shadow callstack: +# https://doc.rust-lang.org/beta/unstable-book/compiler-flags/fixed-x18.html +ifeq ($(ARCH),arm64) + ifneq ($(CONFIG_SHADOW_CALL_STACK),) + RUSTFLAGS += -Zfixed-x18 + endif +endif + + LISA_EVAL_C := $(MODULE_SRC)/lisa-eval-c.sh RUSTUP_HOME ?= $(HOME)/.rustup -- GitLab