Merge pull request #11001 from RuoqingHe/enable-riscv-kernel-build

kernel: Support and enable riscv kernel build
This commit is contained in:
Fupan Li 2025-03-13 19:28:00 +08:00 committed by GitHub
commit 592d58ca52
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 100 additions and 4 deletions

View File

@ -18,6 +18,7 @@ self-hosted-runner:
- k8s-ppc64le
- metrics
- ppc64le
- riscv-builder
- sev
- sev-snp
- s390x

View File

@ -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

View File

@ -94,7 +94,7 @@ Commands:
Options:
-a <arch> : Arch target to build the kernel, such as aarch64/ppc64le/s390x/x86_64.
-a <arch> : Arch target to build the kernel, such as aarch64/ppc64le/riscv64/s390x/x86_64.
-b <type> : Enable optional config type.
-c <path> : Path to config file to build the kernel.
-D <vendor> : 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}"

View File

@ -1,4 +1,4 @@
# !s390x !powerpc
# !s390x !powerpc !riscv
# enable ACPI support.
# This could do with REVIEW

View File

@ -0,0 +1,5 @@
CONFIG_RISCV=y
CONFIG_64BIT=y
CONFIG_VIRTUALIZATION=y
CONFIG_KVM=y

View File

@ -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

View File

@ -0,0 +1,4 @@
CONFIG_PCI_HOST_COMMON=y
CONFIG_PCI_HOST_GENERIC=y
CONFIG_PCI_MSI_IRQ_DOMAIN=y

View File

@ -1 +1 @@
149
150