[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen staging] CI: Add a SecureBoot/UKI test



commit 1208df803530bb885419627ab36a43313b98ce5c
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Wed Nov 25 16:18:27 2026 +0000
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Thu Nov 26 10:58:35 2026 +0000

    CI: Add a SecureBoot/UKI test
    
    Debian 13 ships an OVMF image that is pre-enrolled with the snakeoil key.  
The
    only problem using this is that sbsign requires an interactive prompt for 
the
    password, so arrange for container generation to strip the password; it's 
not
    a secret.
    
    Extend the qemu-xtf infrasturcture with a UKI variant, sign the result with
    the snakeoil key, and use the snakeoil OVMF image.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Acked-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>
---
 automation/build/debian/13-x86_64.dockerfile  | 11 +++++
 automation/gitlab-ci/test.yaml                |  7 +++
 automation/scripts/include/xtf-x86_64-efi-uki | 71 +++++++++++++++++++++++++++
 3 files changed, 89 insertions(+)

diff --git a/automation/build/debian/13-x86_64.dockerfile 
b/automation/build/debian/13-x86_64.dockerfile
index 784299d52d..a25677c129 100644
--- a/automation/build/debian/13-x86_64.dockerfile
+++ b/automation/build/debian/13-x86_64.dockerfile
@@ -57,8 +57,11 @@ RUN <<EOF
         # for test phase, qemu-* jobs
         busybox-static
         expect
+        openssl
         ovmf
+        python3-virt-firmware
         qemu-system-x86
+        sbsigntool
 
         # for build-each-commit-gcc
         ccache
@@ -66,6 +69,14 @@ RUN <<EOF
 
     apt-get -y --no-install-recommends install "${DEPS[@]}"
 
+    # Strip the password off the snakeoil key to avoid sbsign wanting an
+    # interactive prompt
+    openssl rsa \
+            -in  /usr/share/ovmf/PkKek-1-snakeoil.key \
+            -out /usr/share/ovmf/PkKek-1-snakeoil-nopass.key \
+            -passin pass:snakeoil
+    chmod 644 /usr/share/ovmf/PkKek-1-snakeoil-nopass.key
+
     rm -rf /var/lib/apt/lists*
 EOF
 
diff --git a/automation/gitlab-ci/test.yaml b/automation/gitlab-ci/test.yaml
index 96127995d7..cf4b7ed416 100644
--- a/automation/gitlab-ci/test.yaml
+++ b/automation/gitlab-ci/test.yaml
@@ -776,6 +776,13 @@ qemu-smoke-x86_64-gcc-efi:
   needs:
     - debian-13-x86_64-gcc-debug
 
+qemu-smoke-x86_64-gcc-efi-uki:
+  extends: .qemu-smoke-x86_64
+  script:
+    - ./automation/scripts/qemu-xtf.sh x86_64-efi-uki pv64 example 2>&1 | tee 
${LOGFILE}
+  needs:
+    - debian-13-x86_64-gcc-debug
+
 qemu-xtf-argo-x86_64-gcc-debug:
   extends: .qemu-smoke-x86_64
   variables:
diff --git a/automation/scripts/include/xtf-x86_64-efi-uki 
b/automation/scripts/include/xtf-x86_64-efi-uki
new file mode 100644
index 0000000000..b47def06d4
--- /dev/null
+++ b/automation/scripts/include/xtf-x86_64-efi-uki
@@ -0,0 +1,71 @@
+#!/bin/bash
+#
+# XTF test utilities (x86_64, EFI).
+#
+
+# Arch-specific environment overrides.
+function xtf_arch_prepare()
+{
+    export FW_PREFIX="${FW_PREFIX:-/usr/share/OVMF}"
+    export QEMU_PREFIX="${QEMU_PREFIX:-}"
+    export XEN_BINARY="${XEN_BINARY:-${WORKDIR}/xen.efi}"
+    export XEN_CMDLINE="${XEN_CMDLINE:-loglvl=all noreboot 
console_timestamps=boot console=com1}"
+    export XTF_SRC_BRANCH="${XTF_SRC_BRANCH:-master}"
+    export 
XTF_SRC_URI="${XTF_SRC_URI:-https://xenbits.xen.org/git-http/xtf.git}";
+    export XTF_SRC_VARIANTS="hvm64 pv64"
+}
+
+# Perform arch-specific XTF environment setup.
+function xtf_arch_setup()
+{
+    local esp_dir="${WORKDIR}/boot-esp"
+    local efi_dir="${esp_dir}/EFI/BOOT"
+
+    cat > ${WORKDIR}/xen.cfg <<EOF
+[global]
+default=test
+
+[test]
+options=${XEN_CMDLINE}
+kernel=kernel
+EOF
+
+    vma=$(objdump -h ${XEN_BINARY} | \
+              perl -ane 'if (/\..*/) { $vma=hex($F[2]) + hex($F[3]) }
+                         END { printf "0x%016x\n", ($vma + 0xfff) & ~0xfff }')
+
+    objcopy \
+        --add-section .config=${WORKDIR}/xen.cfg \
+        --change-section-vma .config=$vma \
+        --add-section .kernel=${XTF_BINARY} \
+        --change-section-vma .kernel=$(( $vma + 0x100000 )) \
+        ${XEN_BINARY} \
+        ${XEN_BINARY}.uki
+
+    mkdir -p ${efi_dir}
+
+    sbsign --key  /usr/share/ovmf/PkKek-1-snakeoil-nopass.key \
+           --cert /usr/share/ovmf/PkKek-1-snakeoil.pem \
+           --output ${efi_dir}/BOOTX64.EFI \
+           ${XEN_BINARY}.uki
+
+    local ovmf_code=${FW_PREFIX}/OVMF_CODE_4M.snakeoil.fd
+    local ovmf_vars=${FW_PREFIX}/OVMF_VARS_4M.snakeoil.fd
+    local ovmf_format=raw
+
+    cp $ovmf_code ${WORKDIR}/OVMF_CODE
+    cp $ovmf_vars ${WORKDIR}/OVMF_VARS
+
+    export TEST_CMD="${QEMU_PREFIX}qemu-system-x86_64 \
+        -no-reboot \
+        -nographic \
+        -monitor none \
+        -serial stdio \
+        -m 2048 \
+        -smp 2 \
+        -M q35,kernel-irqchip=split \
+        -drive 
if=pflash,format=${ovmf_format},readonly=on,file=${WORKDIR}/OVMF_CODE \
+        -drive if=pflash,format=${ovmf_format},file=${WORKDIR}/OVMF_VARS \
+        -drive file=fat:rw:${esp_dir},media=disk,index=0,format=raw \
+    "
+}
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.