From 19d78ca844b5a19b60e105b04b664b03b123febe Mon Sep 17 00:00:00 2001 From: Ruoqing He Date: Mon, 10 Mar 2025 10:10:15 +0800 Subject: [PATCH 1/8] kernel: Introduce riscv base fragment conf Create `riscv` folder for riscv64 architecture to be inferred while constructing kernel configuration, and introduce `base.conf` which builds 64-bit kernel and with KVM built-in to kernel. Signed-off-by: Ruoqing He --- tools/packaging/kernel/configs/fragments/riscv/base.conf | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 tools/packaging/kernel/configs/fragments/riscv/base.conf diff --git a/tools/packaging/kernel/configs/fragments/riscv/base.conf b/tools/packaging/kernel/configs/fragments/riscv/base.conf new file mode 100644 index 0000000000..226c82ed3c --- /dev/null +++ b/tools/packaging/kernel/configs/fragments/riscv/base.conf @@ -0,0 +1,5 @@ +CONFIG_RISCV=y +CONFIG_64BIT=y + +CONFIG_VIRTUALIZATION=y +CONFIG_KVM=y From 734f5d07a9d5137e6270be3b2cd9e89fec11e626 Mon Sep 17 00:00:00 2001 From: Ruoqing He Date: Mon, 10 Mar 2025 10:13:20 +0800 Subject: [PATCH 2/8] kernel: Introduce riscv pci fragment conf AIA (Advanced Interrupt Architecture) is available and enabled by default after v6.10 kernel, provide pci.conf to make proper use of IMSIC of AIA. Signed-off-by: Ruoqing He --- tools/packaging/kernel/configs/fragments/riscv/pci.conf | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 tools/packaging/kernel/configs/fragments/riscv/pci.conf diff --git a/tools/packaging/kernel/configs/fragments/riscv/pci.conf b/tools/packaging/kernel/configs/fragments/riscv/pci.conf new file mode 100644 index 0000000000..ae81a99224 --- /dev/null +++ b/tools/packaging/kernel/configs/fragments/riscv/pci.conf @@ -0,0 +1,4 @@ +CONFIG_PCI_HOST_COMMON=y +CONFIG_PCI_HOST_GENERIC=y + +CONFIG_PCI_MSI_IRQ_DOMAIN=y From ebd1214b2e1b8012e5cd49f09d7568d3a0d0e18b Mon Sep 17 00:00:00 2001 From: Ruoqing He Date: Mon, 10 Mar 2025 12:44:22 +0800 Subject: [PATCH 3/8] kernel: Introduce riscv mmu fragment conf Memory hotplug and related features is required, enable them in `mmu.conf`. Signed-off-by: Ruoqing He --- tools/packaging/kernel/configs/fragments/riscv/mmu.conf | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 tools/packaging/kernel/configs/fragments/riscv/mmu.conf diff --git a/tools/packaging/kernel/configs/fragments/riscv/mmu.conf b/tools/packaging/kernel/configs/fragments/riscv/mmu.conf new file mode 100644 index 0000000000..4e3228e40c --- /dev/null +++ b/tools/packaging/kernel/configs/fragments/riscv/mmu.conf @@ -0,0 +1,6 @@ +# riscv specific memory related items + +CONFIG_NUMA=y +CONFIG_SPARSEMEM=y +CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y +CONFIG_MEMORY_HOTPLUG=y From 31446b8be861b8e806608913dd635ab0d9b2be08 Mon Sep 17 00:00:00 2001 From: Ruoqing He Date: Mon, 10 Mar 2025 10:31:15 +0800 Subject: [PATCH 4/8] kernel: Skip ACPI common fragment for riscv ACPI is not yet ratified and is still frequently evolving, disable acpi.conf for riscv architecture. Signed-off-by: Ruoqing He --- tools/packaging/kernel/configs/fragments/common/acpi.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/packaging/kernel/configs/fragments/common/acpi.conf b/tools/packaging/kernel/configs/fragments/common/acpi.conf index 25f7d3b1ed..43c9dfe591 100644 --- a/tools/packaging/kernel/configs/fragments/common/acpi.conf +++ b/tools/packaging/kernel/configs/fragments/common/acpi.conf @@ -1,4 +1,4 @@ -# !s390x !powerpc +# !s390x !powerpc !riscv # enable ACPI support. # This could do with REVIEW From e316f633d8c6190e135a0776fa6c852ab6202f58 Mon Sep 17 00:00:00 2001 From: Ruoqing He Date: Mon, 10 Mar 2025 12:54:34 +0800 Subject: [PATCH 5/8] kernel: Bump kata_config_version Bump kata_config_version since riscv kernel build is introduced. Signed-off-by: Ruoqing He --- tools/packaging/kernel/kata_config_version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/packaging/kernel/kata_config_version b/tools/packaging/kernel/kata_config_version index 15c44e939b..fa8f08cb6f 100644 --- a/tools/packaging/kernel/kata_config_version +++ b/tools/packaging/kernel/kata_config_version @@ -1 +1 @@ -149 +150 From 3c8a8ca9c223a42268aa7d2009b4d4dbcb1a24f1 Mon Sep 17 00:00:00 2001 From: Ruoqing He Date: Mon, 10 Mar 2025 10:17:14 +0800 Subject: [PATCH 6/8] kernel: Enable riscv kernel build Modify `build-kernel.sh` to enable building of riscv64 kernel. Signed-off-by: Ruoqing He --- tools/packaging/kernel/build-kernel.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/packaging/kernel/build-kernel.sh b/tools/packaging/kernel/build-kernel.sh index a2943648b1..c887b289aa 100755 --- a/tools/packaging/kernel/build-kernel.sh +++ b/tools/packaging/kernel/build-kernel.sh @@ -94,7 +94,7 @@ Commands: Options: - -a : Arch target to build the kernel, such as aarch64/ppc64le/s390x/x86_64. + -a : Arch target to build the kernel, such as aarch64/ppc64le/riscv64/s390x/x86_64. -b : Enable optional config type. -c : Path to config file to build the kernel. -D : DPU/SmartNIC vendor, only nvidia. @@ -124,6 +124,7 @@ arch_to_kernel() { case "$arch" in aarch64) echo "arm64" ;; ppc64le) echo "powerpc" ;; + riscv64) echo "riscv" ;; s390x) echo "s390" ;; x86_64) echo "$arch" ;; *) die "unsupported architecture: $arch" ;; @@ -551,7 +552,7 @@ install_kata() { fi # Install uncompressed kernel - if [ "${arch_target}" = "arm64" ]; then + if [ "${arch_target}" = "arm64" ] || [ "${arch_target}" = "riscv" ]; then install --mode 0644 -D "arch/${arch_target}/boot/Image" "${install_path}/${vmlinux}" elif [ "${arch_target}" = "s390" ]; then install --mode 0644 -D "arch/${arch_target}/boot/vmlinux" "${install_path}/${vmlinux}" From a7e953c7a7ad701ca3fee0af5b1093c41e66dc2c Mon Sep 17 00:00:00 2001 From: Ruoqing He Date: Mon, 10 Mar 2025 13:11:22 +0800 Subject: [PATCH 7/8] ci: Enable static-tarball build for riscv64 Enable `kernel` and `virtiofsd` static-tarball build for riscv64. Since `virtiofsd` was previously supported and `kernel` is supported now. Signed-off-by: Ruoqing He --- .../build-kata-static-tarball-riscv64.yaml | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 .github/workflows/build-kata-static-tarball-riscv64.yaml diff --git a/.github/workflows/build-kata-static-tarball-riscv64.yaml b/.github/workflows/build-kata-static-tarball-riscv64.yaml new file mode 100644 index 0000000000..4cc5ca0695 --- /dev/null +++ b/.github/workflows/build-kata-static-tarball-riscv64.yaml @@ -0,0 +1,79 @@ +name: CI | Build kata-static tarball for riscv64 +on: + workflow_call: + inputs: + stage: + required: false + type: string + default: test + tarball-suffix: + required: false + type: string + push-to-registry: + required: false + type: string + default: no + commit-hash: + required: false + type: string + target-branch: + required: false + type: string + default: "" + +jobs: + build-asset: + runs-on: riscv-builder + permissions: + contents: read + packages: write + id-token: write + attestations: write + strategy: + matrix: + asset: + - kernel + - virtiofsd + steps: + - name: Login to Kata Containers quay.io + if: ${{ inputs.push-to-registry == 'yes' }} + uses: docker/login-action@v3 + with: + registry: quay.io + username: ${{ secrets.QUAY_DEPLOYER_USERNAME }} + password: ${{ secrets.QUAY_DEPLOYER_PASSWORD }} + + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.commit-hash }} + fetch-depth: 0 # This is needed in order to keep the commit ids history + + - name: Rebase atop of the latest target branch + run: | + ./tests/git-helper.sh "rebase-atop-of-the-latest-target-branch" + env: + TARGET_BRANCH: ${{ inputs.target-branch }} + + - name: Build ${{ matrix.asset }} + run: | + make "${KATA_ASSET}-tarball" + build_dir=$(readlink -f build) + # store-artifact does not work with symlink + mkdir -p kata-build && cp "${build_dir}"/kata-static-"${KATA_ASSET}"*.tar.* kata-build/. + env: + KATA_ASSET: ${{ matrix.asset }} + TAR_OUTPUT: ${{ matrix.asset }}.tar.gz + PUSH_TO_REGISTRY: ${{ inputs.push-to-registry }} + ARTEFACT_REGISTRY: ghcr.io + ARTEFACT_REGISTRY_USERNAME: ${{ github.actor }} + ARTEFACT_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }} + TARGET_BRANCH: ${{ inputs.target-branch }} + RELEASE: ${{ inputs.stage == 'release' && 'yes' || 'no' }} + + - name: store-artifact ${{ matrix.asset }} + uses: actions/upload-artifact@v4 + with: + name: kata-artifacts-arm64-${{ matrix.asset }}${{ inputs.tarball-suffix }} + path: kata-build/kata-static-${{ matrix.asset }}.tar.xz + retention-days: 15 + if-no-files-found: error From e0fb8f08d822decd25f64cfbb32e99381bb8d908 Mon Sep 17 00:00:00 2001 From: Ruoqing He Date: Mon, 10 Mar 2025 18:43:21 +0800 Subject: [PATCH 8/8] ci: Add riscv-builder to actionlint.yaml We have three SG2042 connected and labeled as `riscv-builder`, add that entry to `actionlint.yaml` to help linting while setting up workflows. Signed-off-by: Ruoqing He --- .github/actionlint.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actionlint.yaml b/.github/actionlint.yaml index 5b935cdc72..8d132737c5 100644 --- a/.github/actionlint.yaml +++ b/.github/actionlint.yaml @@ -18,6 +18,7 @@ self-hosted-runner: - k8s-ppc64le - metrics - ppc64le + - riscv-builder - sev - sev-snp - s390x