Skip to content

vhost: add openRuyi Server RISC-V support - #38

Open
chengchen512 wants to merge 2 commits into
gevico:mainfrom
chengchen512:feat/openruyi-riscv-vhost
Open

chengchen512 wants to merge 2 commits into
gevico:mainfrom
chengchen512:feat/openruyi-riscv-vhost

Conversation

@chengchen512

@chengchen512 chengchen512 commented Oct 30, 2026 •

Copy link
Copy Markdown

Summary

This PR adds openRuyi Server 2026.09 as a RISC-V vHost with native ROCm/HIP 7.2.4.

The implementation uses the current image recipe and topology structure. The machine uses 4 GiB RAM, 4 GiB VRAM, two vCPUs, and four compute units.

Commit 1: Prepare reusable RISC-V support

QEMU build

The previous build command selected the QEMU target from the host architecture. The command now accepts a target argument.

scripts/host/build.sh keeps the targets already in the build configuration. This permits x86_64 and riscv64 binaries in the same build directory.

The previous script required x-vfio-user-server for every target. A RISC-V vHost needs the vfio-user-pci client.

In a cross-build on x86_64, the riscv64 target has no KVM support. The server depends on MULTIPROCESS, which requires KVM. Thus, the previous server check rejected a valid riscv64 build.

The script now reads CONFIG_VFIO_USER_SERVER from the generated configuration for the target. It requires the server only when that feature is enabled. It always requires the client.

Image build

The previous image build command selected the Ubuntu recipe. just build-rocm-assets now accepts a recipe argument and keeps Ubuntu as the default.

The official openRuyi Server QCOW2 contains an EFI bootloader and its kernel. Packer uses QEMU's bundled EDK II firmware to start this disk.

This method uses the bootloader supplied with the image. It avoids a separate kernel extraction step before image preparation.

resources/images/packer/qemu.pkr.hcl now accepts optional EFI firmware paths. The recipe supplies these paths through the current [provision.files] mapping.

After software installation, the recipe exports the installed kernel for simulation.

The previous bundle verification used readelf and required an ELF kernel. The openRuyi kernel uses the RISC-V Linux Image format.

resources/images/bundle.py now identifies the RISC-V Image header. Other kernel formats continue through the previous ELF verification path.

Shared resources

  • Add the vhost-riscv profile with TCG, AIA, Sv48, and guest RAM at 0x80000000.
  • Document the profile in English and Chinese.
  • Update gem5 to the upstream merge for gevico/gem5#10.

Commit 2: Add the openRuyi Server platform

  • Add the recipe under resources/images/recipes/openruyi/2026.09/riscv64/rocm/7.2.4/.
  • Install native ROCm, hipcc, rocm-smi, and development packages from the openRuyi DNF repositories.
  • Install the GPU firmware and configure the amdgpu parameters.
  • Export the kernel and records of the package and compiler versions.
  • Add the machine configuration and the topology test.
  • Add English and Chinese instructions.

Simulation boot

Simulation uses OpenSBI and the exported kernel through QEMU's -kernel option.

The kernel mounts the VirtIO root disk at /dev/vda2. EFI firmware is part of image preparation, not the simulation boot path.

Test results

The following tests passed:

  • openRuyi image build and bundle verification.
  • Direct kernel boot.
  • amdgpu and KFD initialization.
  • rocm-smi queries.
  • Native HIP compilation and vector addition with 128 elements.
  • Packer boot with the final template.
  • openRuyi and Ubuntu recipe configuration validation.
  • All 16 image unit tests.
  • Rust formatting, Clippy, and workspace tests.
  • ShellCheck, English and Chinese documentation tests, and checkpatch.

The image tests and documentation tests also passed with the first commit alone.

Manual test

Run these commands from the repository root:

just build-qemu 2 riscv64
just build-gem5 1
just build-rocm-assets openruyi/2026.09/riscv64/rocm/7.2.4

Start the simulation with a new run directory:

just run-topology resources/machines/openruyi-gpu.yaml \
  --run-dir build/openruyi-session \
  --pool-dir build/openruyi-session/memory \
  --ready-timeout 900

Connect to the serial console from another terminal:

socat -,raw,echo=0 UNIX-CONNECT:build/openruyi-session/m0/serial.sock

Log in with the official Server account:

  • Username: root
  • Password: openruyi

Load the GPU driver:

modprobe amdgpu

Run the GPU and compiler checks:

rocm-smi
hipcc --version

Compile a HIP program inside the guest:

hipcc --offload-arch=gfx942 -O2 program.hip -o program

Run the program:

./program

@fengyuanyu1

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@fengyuanyu1

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-30T15:21:09.571959Z
We couldn’t complete this review. Comment @codex review to try again.
a25f44a Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

An unknown error occurred
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@fengyuanyu1

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

An unknown error occurred
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

binary: build/qemu/qemu-system-riscv64
memory: 4G
cpus: 2
accel: tcg

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up suggestion: once a RISC-V host with working KVM support is available, could we probe the host's capabilities and prefer KVM with a matching CPU configuration? Keeping TCG for the current x86-hosted setup is fine; this can be handled as follow-up work rather than a requirement for this PR.

Comment thread resources/machines/openruyi-gpu.yaml Outdated
- id: uefi-code
path: build/firmware/openruyi/RISCV_VIRT_CODE.fd
format: raw
bus: pflash

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you clarify why openRuyi uses UEFI/pflash instead of exporting its kernel and using the existing direct-boot flow with -kernel, as the Ubuntu recipe does? Is there a requirement from the distribution, GPU initialization, or PCIe BAR allocation that makes UEFI necessary?

If there is no such requirement, I would prefer to reuse the existing boot flow to reduce firmware-build and variable-store maintenance. If UEFI is necessary, please document the constraint and why the firmware-related extensions to resources/vhosts/qemu.yaml and resources/images/packer/qemu.pkr.hcl are needed.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the question. The UEFI path is only used during Packer provisioning to boot the official openRuyi Server QCOW2, which ships with an EFI bootloader. The simulation runtime has been switched to direct kernel boot using OpenSBI and QEMU's -kernel option, as described in the updated PR description. Testing confirmed the Linux kernel handles BAR allocation and VBIOS reading without UEFI, so the pflash/VARS overlays are no longer needed at simulation time. The firmware paths in qemu.pkr.hcl are retained solely for provisioning the stock image.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add vhost-riscv to the built-in profiles section in this page and its Chinese counterpart, docs/zh/topology/hosts/index.rst. Both pages still describe five profiles and omit the new one. Please update the stated count and describe the RISC-V QEMU executable, TCG/CPU settings, and guest RAM mapping.

Comment thread resources/vhosts/qemu.yaml Outdated
{% set drivers = {"virtio": "virtio-blk-pci", "nvme": "nvme",
"scsi": "scsi-hd", "ide": "ide-hd"} %}
{% for disk in disks %}
{% if disk.bus == "pflash" %}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the shared runtime-template extension related to the boot-flow discussion. Could openRuyi reuse the existing exported-kernel/direct-boot flow, or is firmware boot required at runtime? Please clarify that constraint before retaining this additional boot path.

Comment thread resources/images/packer/qemu.pkr.hcl Outdated
disk_interface = var.architecture == "riscv64" ? "virtio" : "ide"
net_device = var.architecture == "riscv64" ? "virtio-net-pci" : "e1000"
disable_vnc = var.architecture == "riscv64"
efi_boot = var.efi_firmware_code != ""

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to the boot-flow discussion: does the openRuyi base image require EFI to boot the provisioning VM? Please explain this separately from the simulation-session boot choice. Unifying runtime boot with the existing -kernel flow would not necessarily remove the need for these Packer EFI settings.

@zevorn

zevorn commented Oct 30, 2026

Copy link
Copy Markdown
Member

@codex review this PR thoroughly

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

An unknown error occurred
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@zevorn zevorn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have many review comments right now. Let's prioritize fixing the issues we've already found. Thanks.

@zevorn zevorn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to split this PR into two commits:

  1. The first commit includes the code changes explaining why they were made, the issues resolved, and some planned targets. This serves as the basic feature.
  2. The second commit explains the addition of a new platform, for example, OpenSBI for the RISC-V platform (or openRuyi for the RISC-V platform).

The second commit depends on the first, and every commit is an atomic patch. This will give us a clear patch series that is easy for other maintainers to review.

QEMU builds assume the emulation target matches the host ISA and require
vfio-user server support even when a cross target only provides a client.
The image entry point fixes the Ubuntu recipe and kernel verification
assumes ELF, preventing reuse for RISC-V Linux Images.

Allow target and recipe selection while keeping existing defaults. Retain
configured QEMU targets and check optional server support from generated
per-target features. Recognize the RISC-V Image header and read optional
provisioning firmware paths from existing recipe metadata.

Add a distribution-independent TCG vHost profile with RAM at 0x80000000.
Advance gem5 to upstream merge ddd3efc for the RISC-V GPU fixes.

This provides the foundation for OpenRuyi Server and other RISC-V images.
A native RISC-V/KVM profile can reuse these feature checks after host
capability and matching CPU selection are validated.

Validation: both QEMU targets, image unit tests, bilingual documentation,
ShellCheck, maintainer coverage and checkpatch.

Signed-off-by: chengchen512 <2497083717@qq.com>
Add the official openRuyi Server 2026.09 RVA23 QCOW2 recipe in the existing
image-recipe hierarchy. Install native ROCm/HIP 7.2.4 through DNF and
export package and compiler version records.

Packer provisions the stock disk with QEMU's bundled EDK II and exports
its kernel. Simulation sessions use the existing OpenSBI/direct-kernel
flow with a VirtIO root disk at /dev/vda2. Keep 4 GiB RAM, 4 GiB VRAM,
two vCPUs and four compute units.

Use the preceding reusable RISC-V support, add the platform memory-map
test, and document build, login, rocm-smi and native HIP use in Chinese
and English.

Validation: direct-kernel GPU/HIP execution, default-device Packer boot
with NoCloud/SSH and Ansible checks, Rust checks, bilingual documentation,
maintainer coverage and checkpatch.

Signed-off-by: chengchen512 <2497083717@qq.com>
@chengchen512

Copy link
Copy Markdown
Author

I have updated the PR based on the review:

Simulation now uses direct kernel boot (-kernel + OpenSBI); UEFI/pflash is limited to Packer provisioning of the stock QCOW2.

The QEMU build script now checks CONFIG_VFIO_USER_SERVER from the generated per-target configuration, so a RISC-V vHost only requires the vfio-user client instead of failing on the server check.

Commit split into two atomic patches as requested.

vhost-riscv added to both English and Chinese documentation.

@fengyuanyu1

Copy link
Copy Markdown
Collaborator

Thanks for the update. The direct-kernel boot flow, provisioning-only EFI setup, and updated documentation address my comments.

As a follow-up, we could publish prebuilt vHost images together with matching kernels and checksums, so users can download, verify, and launch them directly. Recipes and Packer would remain available for rebuilding and updating the images.

@zevorn zevorn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need a ci for openruyi vhost also

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants