Skip to contentSkip to conversation

Cleanup and Linux ARM64 support

PATCH In review Andrew Cooper 3 participants 13 messages Apr 10, 2025 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

v2 cover Cleanup and Linux ARM64 support

Two patches merged. Only minor tweaks to the rest.

https://gitlab.com/xen-project/hardware/test-artifacts/-/pipelines/1762204421
is a pipline showing clean kernel builds.

https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/1762221755 is a Xen pipline using the artefacts from ^.

Andrew Cooper (6):
Port containerise
Clean up Gitlab yaml
Adjust Linux build script to work with other major versions Factor our x86-isms in the linux build script Infrastructure for arm64 linux builds
Linux builds for x86 and ARM64

 .gitlab-ci.yml                            | 41 ++++++++--
 containerize                              | 95 +++++++++++++++++++++++
 images/alpine/3.18-arm64-build.dockerfile | 27 +++++++
 scripts/build-linux.sh                    | 54 +++++++++++++
 scripts/x86_64-kernel-linux.sh            | 31 --------
 5 files changed, 212 insertions(+), 36 deletions(-)
 create mode 100755 containerize
 create mode 100644 images/alpine/3.18-arm64-build.dockerfile
 create mode 100755 scripts/build-linux.sh
 delete mode 100755 scripts/x86_64-kernel-linux.sh
Signature · 1 line
2.39.5
#1 lore raw

PATCH v2 1/6 Port containerise

While it pains me to keep the wrong spelling, do so for consistency.

---
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Marek Marczykowski-Górecki <[email protected]>
CC: Anthony PERARD <[email protected]>

v2:
* Switch back to alpine:x86_64-rootfs as the rename isn't in the series yet.

---
 containerize | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 94 insertions(+)
 create mode 100755 containerize
containerize new file +94 -0
new file mode 100755
index 000000000000..fd488cc57596
@@ -0,0 +1,94 @@
+#!/bin/bash
+
+#
+# DOCKER_CMD should be either `docker` or `podman`.
+#
+# if using (rootless) podman, remember to set /etc/subuid
+# and /etc/subgid.
+#
+docker_cmd=${DOCKER_CMD:-"docker"}
+[ "$DOCKER_CMD" = "podman" ] && userns_podman="--userns=keep-id" selinux=",z"
+
+einfo() {
+    echo "$*" >&2
+}
+
+die() {
+    echo "$*" >&2
+    exit 1
+}
+
+#
+# The caller is expected to override the CONTAINER environment
+# variable with the container they wish to launch.
+#
+BASE="registry.gitlab.com/xen-project/hardware/test-artifacts"
+case "_${CONTAINER}" in
+    _alpine-x86_64-rootfs) CONTAINER="${BASE}/alpine:x86_64-rootfs" ;;
+    _alpine-x86_64-build|_) CONTAINER="${BASE}/alpine:x86_64-build" ;;
+esac
+
+# Use this variable to control whether root should be used
+case "_${CONTAINER_UID0}" in
+    _1)   userarg="-u 0" ;;
+    _0|_) userarg="-u $(id -u) $userns_podman" ;;
+esac
+
+# Save the commands for future use
+cmd=("$@")
+
+# If no command was specified, just drop us into a shell if we're interactive
+[ $# -eq 0 ] && tty -s && cmd=("/bin/bash")
+
+# Are we in an interactive terminal?
+tty -s && termint=t
+
+#
+# Fetch the latest version of the container in hub.docker.com,
+# unless it's a newly created local copy.
+#
+if [[ "_${CONTAINER_NO_PULL}" != "_1" ]]; then
+    einfo "*** Ensuring ${CONTAINER} is up to date"
+    ${docker_cmd} pull ${CONTAINER} > /dev/null ||     \
+        die "Failed to update container"
+fi
+
+if hash greadlink > /dev/null 2>&1; then
+    READLINK=greadlink
+elif [[ $(uname -s) == "Darwin" ]]; then
+    echo "Unable to forward SSH agent without coreutils installed"
+    unset SSH_AUTH_SOCK
+else
+    READLINK=readlink
+fi
+
+# Ensure we've got what we need for SSH_AUTH_SOCK
+if [[ -n ${SSH_AUTH_SOCK} ]]; then
+    fullpath_sock=$(${READLINK} -f ${SSH_AUTH_SOCK} 2> /dev/null)
+    if [ $? -ne 0 ]; then
+        echo "Invalid SSH_AUTH_SOCK: ${SSH_AUTH_SOCK}"
+        unset SSH_AUTH_SOCK
+    else
+        SSH_AUTH_DIR=$(dirname ${fullpath_sock})
+        SSH_AUTH_NAME=$(basename ${fullpath_sock})
+    fi
+fi
+
+# Figure out the base of what we want as our sources
+# by using the top of the git repo
+if [[ -z ${CONTAINER_PATH} ]]; then
+    CONTAINER_PATH=$(git rev-parse --show-toplevel)
+fi
+
+# Kick off Docker
+einfo "*** Launching container ..."
+exec ${docker_cmd} run \
+    ${userarg} \
+    ${SSH_AUTH_SOCK:+-e SSH_AUTH_SOCK="/tmp/ssh-agent/${SSH_AUTH_NAME}"} \
+    -v "${CONTAINER_PATH}":/build:rw${selinux} \
+    -v "${HOME}/.ssh":/root/.ssh:ro \
+    ${SSH_AUTH_DIR:+-v "${SSH_AUTH_DIR}":/tmp/ssh-agent${selinux}} \
+    ${CONTAINER_ARGS} \
+    -${termint}i --rm -- \
+    ${CONTAINER} \
+    "${cmd[@]}"
Signature · 1 line
2.39.5
#3 lore raw

PATCH v2 2/6 Clean up Gitlab yaml

In reply to Andrew Cooper

Factor out the registry into a common location. Drop the worflow name, as all it does is hide the commit message of the change that triggered the pipeline. List all the stages. Set a default expiry of 1 month.

Note all the current jobs as legacy. Their naming scheme needs changing, and we'll use this opportunity to switch formats too. However, the artefacts need to stay using the old name until the final staging-* branch using them is phased out.

---
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Marek Marczykowski-Górecki <[email protected]>
CC: Anthony PERARD <[email protected]>

v2:
* Drop the workflow name.

---
 .gitlab-ci.yml | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
.gitlab-ci.yml +10 -3
index 36ec6a7e1ee5..734f3982c46f 100644
@@ -1,12 +1,16 @@
-workflow:
-  name: "xen test artifacts"
+variables:
+  REGISTRY: registry.gitlab.com/xen-project/hardware/test-artifacts
+
+stages:
+  - build
 
 .artifacts:
   stage: build
   image:
-    name: registry.gitlab.com/xen-project/hardware/test-artifacts/${CONTAINER}
+    name: ${REGISTRY}/${CONTAINER}
   artifacts:
     name: "${CI_JOB_NAME_SLUG}"
+    expire_in: 1 month
     paths:
       - binaries/
     exclude:
@@ -19,6 +23,9 @@ workflow:
   variables:
     CONTAINER: alpine:x86_64-build
 
+#
+# The jobs below here are legacy and being phased out.
+#
 x86_64-kernel-linux-6.6.56:
   extends: .x86_64-artifacts
   script:
Signature · 1 line
2.39.5
Reviewed-by on v2 2/6
#4 lore raw

Re: [PATCH 2/6] Clean up Gitlab yaml

Quoted 10 lines · Andrew Cooper

Factor out the registry into a common location. Drop the worflow name, as all it does is hide the commit message of the change that triggered the pipeline. List all the stages. Set a default expiry of 1 month.

Note all the current jobs as legacy. Their naming scheme needs changing, and we'll use this opportunity to switch formats too. However, the artefacts need to stay using the old name until the final staging-* branch using them is phased out.

Quoted 50 lines

---
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Marek Marczykowski-Górecki <[email protected]>
CC: Anthony PERARD <[email protected]>

v2:
* Drop the workflow name.

---
 .gitlab-ci.yml | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
.gitlab-ci.yml +10 -3
index 36ec6a7e1ee5..734f3982c46f 100644
@@ -1,12 +1,16 @@
-workflow:
-  name: "xen test artifacts"
+variables:
+  REGISTRY: registry.gitlab.com/xen-project/hardware/test-artifacts
+
+stages:
+  - build
 
 .artifacts:
   stage: build
   image:
-    name: registry.gitlab.com/xen-project/hardware/test-artifacts/${CONTAINER}
+    name: ${REGISTRY}/${CONTAINER}
   artifacts:
     name: "${CI_JOB_NAME_SLUG}"
+    expire_in: 1 month
     paths:
       - binaries/
     exclude:
@@ -19,6 +23,9 @@ workflow:
   variables:
     CONTAINER: alpine:x86_64-build
 
+#
+# The jobs below here are legacy and being phased out.
+#
 x86_64-kernel-linux-6.6.56:
   extends: .x86_64-artifacts
   script:
Signature · 1 line
2.39.5
Signature · 3 lines
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
Reviewed-by on v2 2/6
#5 lore raw

Re: [PATCH 2/6] Clean up Gitlab yaml

In reply to Andrew Cooper
Quoted 10 lines · Andrew Cooper

Factor out the registry into a common location. Drop the worflow name, as all it does is hide the commit message of the change that triggered the pipeline. List all the stages. Set a default expiry of 1 month.

Note all the current jobs as legacy. Their naming scheme needs changing, and we'll use this opportunity to switch formats too. However, the artefacts need to stay using the old name until the final staging-* branch using them is phased out.

Thanks,

Signature · 5 lines
Anthony Perard | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech
#6 lore raw

PATCH v2 3/6 Adjust Linux build script to work with other major versions

In reply to Andrew Cooper

Simply the tar expression, as 'tar xf' can figure out the compression automatically.

---
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Marek Marczykowski-Górecki <[email protected]>
CC: Anthony PERARD <[email protected]>

v2:
* Use 'tar xf'

---
 scripts/x86_64-kernel-linux.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
scripts/x86_64-kernel-linux.sh +3 -2
index 2a816f0b3204..5ed5608628bc 100755
@@ -11,9 +11,10 @@ WORKDIR="${PWD}"
 COPYDIR="${WORKDIR}/binaries/"
 
 # Build Linux
+MAJOR=${LINUX_VERSION%%.*}
 curl -fsSLO \
-    https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-"${LINUX_VERSION}".tar.xz
-tar xJf linux-"${LINUX_VERSION}".tar.xz
+    https://cdn.kernel.org/pub/linux/kernel/v"${MAJOR}".x/linux-"${LINUX_VERSION}".tar.xz
+tar xf linux-"${LINUX_VERSION}".tar.xz
 cd linux-"${LINUX_VERSION}"
 make ARCH=x86 defconfig
 make ARCH=x86 xen.config
Signature · 1 line
2.39.5
Reviewed-by on v2 3/6
#7 lore raw

Re: [PATCH 3/6] Adjust Linux build script to work with other major versions

Quoted 4 lines · Andrew Cooper

Simply the tar expression, as 'tar xf' can figure out the compression automatically.

Quoted 33 lines

---
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Marek Marczykowski-Górecki <[email protected]>
CC: Anthony PERARD <[email protected]>

v2:
* Use 'tar xf'

---
 scripts/x86_64-kernel-linux.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
scripts/x86_64-kernel-linux.sh +3 -2
index 2a816f0b3204..5ed5608628bc 100755
@@ -11,9 +11,10 @@ WORKDIR="${PWD}"
 COPYDIR="${WORKDIR}/binaries/"
 
 # Build Linux
+MAJOR=${LINUX_VERSION%%.*}
 curl -fsSLO \
-    https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-"${LINUX_VERSION}".tar.xz
-tar xJf linux-"${LINUX_VERSION}".tar.xz
+    https://cdn.kernel.org/pub/linux/kernel/v"${MAJOR}".x/linux-"${LINUX_VERSION}".tar.xz
+tar xf linux-"${LINUX_VERSION}".tar.xz
 cd linux-"${LINUX_VERSION}"
 make ARCH=x86 defconfig
 make ARCH=x86 xen.config
Signature · 1 line
2.39.5
Signature · 3 lines
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
#8 lore raw

PATCH v2 4/6 Factor our x86-isms in the linux build script

In reply to Andrew Cooper

... in preparation to use it for arm64 too. Rename the script.

---
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Marek Marczykowski-Górecki <[email protected]>
CC: Anthony PERARD <[email protected]>

---
 .gitlab-ci.yml                                |  3 +-
 ...{x86_64-kernel-linux.sh => build-linux.sh} | 34 +++++++++++++------
 2 files changed, 24 insertions(+), 13 deletions(-)
 rename scripts/{x86_64-kernel-linux.sh => build-linux.sh} (55%)
.gitlab-ci.yml +1 -2
index 734f3982c46f..a8e56b165ed6 100644
@@ -28,8 +28,7 @@ stages:
 #
 x86_64-kernel-linux-6.6.56:
   extends: .x86_64-artifacts
-  script:
-    - . scripts/x86_64-kernel-linux.sh
+  script: ./scripts/build-linux.sh
   variables:
     LINUX_VERSION: 6.6.56
 
scripts/build-linux.sh renamed from scripts/x86_64-kernel-linux.sh +23 -11
similarity index 55%
rename from scripts/x86_64-kernel-linux.sh
rename to scripts/build-linux.sh
index 5ed5608628bc..c78cd6ca46da 100755
@@ -9,6 +9,7 @@ set -ex -o pipefail
 
 WORKDIR="${PWD}"
 COPYDIR="${WORKDIR}/binaries/"
+UNAME=$(uname -m)
 
 # Build Linux
 MAJOR=${LINUX_VERSION%%.*}
@@ -16,17 +17,28 @@ curl -fsSLO \
     https://cdn.kernel.org/pub/linux/kernel/v"${MAJOR}".x/linux-"${LINUX_VERSION}".tar.xz
 tar xf linux-"${LINUX_VERSION}".tar.xz
 cd linux-"${LINUX_VERSION}"
-make ARCH=x86 defconfig
-make ARCH=x86 xen.config
+
+make defconfig
 ./scripts/config --enable BRIDGE
 ./scripts/config --enable IGC
 ./scripts/config --enable TUN
-cp .config .config.orig
-cat .config.orig \
-    | grep 'XEN' \
-    | grep '=m' \
-    | sed 's/=m/=y/g' \
-    >> .config
-make ARCH=x86 olddefconfig
-make -s -j "$(nproc)" ARCH=x86
-cp arch/x86/boot/bzImage "${COPYDIR}"
+
+case $UNAME in
+    x86_64)
+        make xen.config
+        cp .config .config.orig
+        cat .config.orig \
+            | grep 'XEN' \
+            | grep '=m' \
+            | sed 's/=m/=y/g' >> .config
+        ;;
+esac
+
+make olddefconfig
+
+case $UNAME in
+    x86_64)
+        make -j$(nproc) bzImage
+        cp arch/x86/boot/bzImage "${COPYDIR}"
+        ;;
+esac
Signature · 1 line
2.39.5
#9 lore raw

PATCH v2 5/6 Infrastructure for arm64 linux builds

In reply to Andrew Cooper

---
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Marek Marczykowski-Górecki <[email protected]>
CC: Anthony PERARD <[email protected]>

v2:
* Drop musl-dev. It's brought in by build-base.
* Include findutils to fix build warnings.

---
 .gitlab-ci.yml                            |  7 ++++++
 containerize                              |  1 +
 images/alpine/3.18-arm64-build.dockerfile | 27 +++++++++++++++++++++++
 scripts/build-linux.sh                    | 10 +++++++++
 4 files changed, 45 insertions(+)
 create mode 100644 images/alpine/3.18-arm64-build.dockerfile
.gitlab-ci.yml +7 -0
index a8e56b165ed6..6faa85d8dd7c 100644
@@ -16,6 +16,13 @@ stages:
     exclude:
       - binaries/.gitignore
 
+.arm64-artifacts:
+  extends: .artifacts
+  tags:
+    - arm64
+  variables:
+    CONTAINER: alpine:3.18-arm64-build
+
 .x86_64-artifacts:
   extends: .artifacts
   tags:
containerize +1 -0
index fd488cc57596..7abeb119ff6a 100755
@@ -24,6 +24,7 @@ die() {
 #
 BASE="registry.gitlab.com/xen-project/hardware/test-artifacts"
 case "_${CONTAINER}" in
+    _alpine-3.18-arm64-build) CONTAINER="${BASE}/alpine:3.18-arm64-build" ;;
     _alpine-x86_64-rootfs) CONTAINER="${BASE}/alpine:x86_64-rootfs" ;;
     _alpine-x86_64-build|_) CONTAINER="${BASE}/alpine:x86_64-build" ;;
 esac
images/alpine/3.18-arm64-build.dockerfile new file +27 -0
new file mode 100644
index 000000000000..b6d9bd1af531
@@ -0,0 +1,27 @@
+# syntax=docker/dockerfile:1
+FROM --platform=linux/arm64/v8 alpine:3.18
+LABEL maintainer.name="The Xen Project" \
+      maintainer.email="[email protected]"
+
+RUN apk --no-cache add bash
+
+RUN bash -ex <<EOF
+      adduser -D user --shell bash
+
+      DEPS=(# Base environment
+            build-base
+            curl
+
+            # Linux build deps
+            bison
+            findutils
+            flex
+            openssl-dev
+            perl
+      )
+
+      apk add --no-cache "\${DEPS[@]}"
+EOF
+
+USER user
+WORKDIR /build
scripts/build-linux.sh +10 -0
index c78cd6ca46da..652fdba7b9d1 100755
@@ -21,6 +21,7 @@ cd linux-"${LINUX_VERSION}"
 make defconfig
 ./scripts/config --enable BRIDGE
 ./scripts/config --enable IGC
+./scripts/config --enable IPV6
 ./scripts/config --enable TUN
 
 case $UNAME in
@@ -32,6 +33,10 @@ case $UNAME in
             | grep '=m' \
             | sed 's/=m/=y/g' >> .config
         ;;
+
+    aarch64)
+        ./scripts/config --enable XEN_NETDEV_BACKEND
+        ;;
 esac
 
 make olddefconfig
@@ -41,4 +46,9 @@ case $UNAME in
         make -j$(nproc) bzImage
         cp arch/x86/boot/bzImage "${COPYDIR}"
         ;;
+
+    aarch64)
+        make -j$(nproc) Image
+        cp arch/arm64/boot/Image "${COPYDIR}"
+        ;;
 esac
Signature · 1 line
2.39.5

A message that is not in the archive (sent off-list or not yet received): Z_fM44HXEnpwa8q6@l14

#11 lore raw

Re: [PATCH 5/6] Infrastructure for arm64 linux builds

Quoted 13 lines · Anthony PERARD

images/alpine/3.18-arm64-build.dockerfile line 4

Quoted 10 lines · Andrew Cooper
images/alpine/3.18-arm64-build.dockerfile new file +4 -0
new file mode 100644
index 000000000000..b6d9bd1af531
@@ -0,0 +1,27 @@
+# syntax=docker/dockerfile:1
+FROM --platform=linux/arm64/v8 alpine:3.18
+LABEL maintainer.name="The Xen Project" \
+      maintainer.email="[email protected]"

I though we were repeating the "LABEL" on each line these days, to avoid the backslash at the end of the line. ;-)

Oh right.  I'll fix.

Quoted 27 lines
Quoted 10 lines
images/alpine/3.18-arm64-build.dockerfile new file +9 -0
+
+RUN apk --no-cache add bash
+
+RUN bash -ex <<EOF
+      adduser -D user --shell bash
+
+      DEPS=(# Base environment
+            build-base
+            curl

images/alpine/3.18-arm64-build.dockerfile line 23

Quoted 10 lines
images/alpine/3.18-arm64-build.dockerfile new file +10 -0
+
+            # Linux build deps
+            bison
+            findutils
+            flex
+            openssl-dev
+            perl
+      )
+
+      apk add --no-cache "\${DEPS[@]}"

If I take one example from xen.git, we don't escape the $ and it's just "${DEPS[@]}", is it because the script is run with:

RUN bash -ex <<EOF

instead of

Quoted 8 lines
    RUN <<EOF
    #!/usr/bin/bash

?

As for the rest of the patch, it looks fine to me. I don't know if the change to the build config are necessary but they looks fine.

Ah, I meant to look at that and forgot.  This was started from the x86 container already in test-artefacts.

But yes, we want to do this the way xen.git does, with a set -eu too.

Quoted 3 lines

With the LABEL repeated on each line:

Thanks.

~Andrew

#12 lore raw

PATCH v2 6/6 Linux builds for x86 and ARM64

In reply to Andrew Cooper

For ARM64, the tests in Xen currently use 6.6.74, but 6.6.86 works so update to the latest.

For x86, stay at 6.6.56. There's a PVH regression upstream in need of fixing.

---
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Marek Marczykowski-Górecki <[email protected]>
CC: Anthony PERARD <[email protected]>

v2:
* Move x86 back to 6.6.56 until the PVH regression is fixed.

---
 .gitlab-ci.yml | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
.gitlab-ci.yml +18 -0
index 6faa85d8dd7c..670f9621e26d 100644
@@ -30,6 +30,24 @@ stages:
   variables:
     CONTAINER: alpine:x86_64-build
 
+#
+# ARM64 artifacts
+#
+linux-6.6.86-arm64:
+  extends: .arm64-artifacts
+  script: ./scripts/build-linux.sh
+  variables:
+    LINUX_VERSION: 6.6.86
+
+#
+# x86_64 artifacts
+#
+linux-6.6.56-x86_64:
+  extends: .x86_64-artifacts
+  script: ./scripts/build-linux.sh
+  variables:
+    LINUX_VERSION: 6.6.56
+
 #
 # The jobs below here are legacy and being phased out.
 #
Signature · 1 line
2.39.5
Acked-by on v2 6/6
#13 lore raw

Re: [PATCH 6/6] Linux builds for x86 and ARM64

Quoted 6 lines · Andrew Cooper

For ARM64, the tests in Xen currently use 6.6.74, but 6.6.86 works so update to the latest.

For x86, stay at 6.6.56. There's a PVH regression upstream in need of fixing.

Thanks,

Signature · 5 lines
Anthony Perard | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech