From 86ce26f1fc8d3ace29158670b89340c7a228ed81 Mon Sep 17 00:00:00 2001 From: Cristian Ciocaltea Date: Tue, 22 Feb 2022 16:49:28 +0200 Subject: [PATCH] ci: Load KVM kernel module for LAVA runners If 'HWCI_KVM' enviroment variable is set, load the KVM kernel module specific to the detected CPU virtualisation extensions: vmx for Intel VT and svm for AMD-V. As an additional optimization, handle HWCI_KERNEL_MODULES probing in the main shell process instead of creating an unnecessary subshell. Signed-off-by: Cristian Ciocaltea Reviewed-by: Guilherme Gallo Reviewed-by: Tomeu Vizoso Part-of: --- .gitlab-ci/common/generate-env.sh | 1 + .gitlab-ci/common/init-stage2.sh | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci/common/generate-env.sh b/.gitlab-ci/common/generate-env.sh index 58e92490381..92d0a89a861 100755 --- a/.gitlab-ci/common/generate-env.sh +++ b/.gitlab-ci/common/generate-env.sh @@ -61,6 +61,7 @@ for var in \ GTEST_SKIPS \ HWCI_FREQ_MAX \ HWCI_KERNEL_MODULES \ + HWCI_KVM \ HWCI_START_XORG \ HWCI_TEST_SCRIPT \ IR3_SHADER_DEBUG \ diff --git a/.gitlab-ci/common/init-stage2.sh b/.gitlab-ci/common/init-stage2.sh index fe46338b78a..c85e52cc78a 100755 --- a/.gitlab-ci/common/init-stage2.sh +++ b/.gitlab-ci/common/init-stage2.sh @@ -8,7 +8,23 @@ set -ex # Set up any devices required by the jobs -[ -z "$HWCI_KERNEL_MODULES" ] || (echo -n $HWCI_KERNEL_MODULES | xargs -d, -n1 /usr/sbin/modprobe) +[ -z "$HWCI_KERNEL_MODULES" ] || { + echo -n $HWCI_KERNEL_MODULES | xargs -d, -n1 /usr/sbin/modprobe +} + +# Load the KVM module specific to the detected CPU virtualization extensions: +# - vmx for Intel VT +# - svm for AMD-V +if [ "$HWCI_KVM" = "true" ]; then + unset KVM_KERNEL_MODULE + grep -qs '\bvmx\b' /proc/cpuinfo && KVM_KERNEL_MODULE=kvm_intel || { + grep -qs '\bsvm\b' /proc/cpuinfo && KVM_KERNEL_MODULE=kvm_amd + } + + [ -z "${KVM_KERNEL_MODULE}" ] && \ + echo "WARNING: Failed to detect CPU virtualization extensions" || \ + modprobe ${KVM_KERNEL_MODULE} +fi # Fix prefix confusion: the build installs to $CI_PROJECT_DIR, but we expect # it in /install