xen: add initial riscv64 support
PATCH v2 1/1 xen: add initial riscv64 support
Add riscv64 to the Xen architecture mapping and allow the Xen hypervisor recipe to build for it.
Xen sets its own -march and -mabi flags for RISC-V, so clear TUNE_CCARGS for riscv64 in the same way as is already done for aarch64.
The Xen tools do not support riscv64 yet, so skip the xen-tools deploy dependencies on that architecture.
Add a qemuriscv64 section to the Xen build and boot documentation.
Tested-by Ronaldo Nunez <[email protected]>
Signed-off-by Hiago De Franco <[email protected]>
---
v2:
- Added Xen riscv64 instructions (build and boot) to README-xen.md file.
- Updated commit description accordingly.
v1: https://lore.kernel.org/all/[email protected]/
--- recipes-extended/images/README-xen.md | 43 +++++++++++++++++++++++++ recipes-extended/xen/xen-arch.inc | 1 + recipes-extended/xen/xen-hypervisor.inc | 22 ++++++++----- 3 files changed, 58 insertions(+), 8 deletions(-)
recipes-extended/images/README-xen.md +43 -0
@@ -241,6 +241,49 @@ root@qemux86-64:~# ctr image pull docker.io/library/alpine:latest root@qemux86-64:~# vctr run --rm docker.io/library/alpine:latest test1 echo hello hello +### qemuriscv64 + +The Xen tools do not support riscv64 yet, so xen-image-minimal and the +xl toolstack are not available for this architecture. Only the hypervisor +is built, and it is booted directly by QEMU. + +local.conf contains: + + MACHINE = "qemuriscv64" + +Build the hypervisor: + + % bitbake xen + +The hypervisor is deployed as: + + tmp/deploy/images/qemuriscv64/xen-qemuriscv64 + +runqemu cannot be used here because it requires an image with qemuboot +metadata, and xen-image-minimal is not buildable without the tools. Boot +the deployed hypervisor directly from the build directory with QEMU +instead: + + % qemu-system-riscv64 \ + -machine virt,aia=aplic-imsic,aia-guests=4 \ + -cpu rv64,svpbmt=on,sv57=off,sv48=off \ + -smp 2 -m 2g -nographic -bios default \ + -kernel tmp/deploy/images/qemuriscv64/xen-qemuriscv64 + +QEMU's built-in OpenSBI loads Xen in S-mode and passes it the device tree +generated by the virt machine. The svpbmt extension and the AIA +APLIC/IMSIC interrupt controllers are required by the RISC-V port, Xen +panics if either is missing. + +The upstream RISC-V port currently boots the hypervisor only. Dom0 and +DomU support are still under development, so Xen halts after printing: + + (XEN) Xen version 4.23-unstable ... + ... + (XEN) Max supported G-stage mode is sv39x4 + (XEN) VMIDs use is enabled + (XEN) All set up + vxn and containerd integration ------------------------------
recipes-extended/xen/xen-arch.inc +1 -0
@@ -2,6 +2,7 @@ valid_xen_archs = " \ x86_64 x86_32 \ arm32 arm64 \ + riscv64 \ " def map_xen_arch(a, d):
recipes-extended/xen/xen-hypervisor.inc +14 -8
@@ -7,7 +7,7 @@ DESCRIPTION = "The Xen hypervisor" # to build the different components. eg. 32-bit tools and a 64-bit hypervisor. # The Xen hypervisor has a narrower compatible platform range than the Xen tools -COMPATIBLE_HOST = '(x86_64.*).*-linux|aarch64.*-linux' +COMPATIBLE_HOST = '(x86_64.*).*-linux|aarch64.*-linux|riscv64.*-linux' inherit deploy python3native cml1
@@ -94,12 +94,17 @@ do_deploy() { # - add the task before do_build to ensure that deployment has completed when # the recipe build done stamp is written addtask deploy after do_compile do_populate_sysroot before do_build -# To ensure that a deployed hypervisor has matching tools, add a dependency to -# make sure that the tools have built and been staged: -do_deploy[depends] += "xen-tools:do_populate_sysroot" -# Also ensure anything that the tools recipe needs to deploy, such as a -# XSM policy file, has been deployed first: -do_deploy[depends] += "xen-tools:do_deploy" +# To ensure that a deployed hypervisor has matching tools, add dependencies to +# make sure that the tools have built and been staged, and that anything the +# tools recipe needs to deploy, such as a XSM policy file, has been deployed +# first. +XEN_TOOLS_DEPLOY_DEPENDS = " \ + xen-tools:do_populate_sysroot \ + xen-tools:do_deploy \ + " +# xen-tools is not yet buildable for riscv64. +XEN_TOOLS_DEPLOY_DEPENDS:riscv64 = "" +do_deploy[depends] += "${XEN_TOOLS_DEPLOY_DEPENDS}" # Enable use of menuconfig directly from bitbake and also within the devshell do_devshell[depends] += "ncurses-native:do_populate_sysroot"
@@ -113,5 +118,6 @@ CROSS_CURSES_LIB += "-L${STAGING_LIBDIR_NATIVE}" KCONFIG_CONFIG_ROOTDIR = "${S}/xen" # Xen is setting all CC flags on its own. Make sure that they are not modified -# for aarch64, e.g. with architecture-specific optimizations. +# for aarch64 and riscv64, e.g. with architecture-specific optimizations. TUNE_CCARGS:aarch64 = "" +TUNE_CCARGS:riscv64 = ""
Signature · 1 line
2.47.3