Skip to content

uefi-riscv64: add cloud kernel target#9862

Closed
igorpecovnik wants to merge 3 commits into
mainfrom
uefi-riscv64-add-cloud-kernel
Closed

uefi-riscv64: add cloud kernel target#9862
igorpecovnik wants to merge 3 commits into
mainfrom
uefi-riscv64-add-cloud-kernel

Conversation

@igorpecovnik

@igorpecovnik igorpecovnik commented May 18, 2026

Copy link
Copy Markdown
Member

Summary

x86 and arm64 UEFI both have a cloud kernel variant; riscv64 didn't. Adds the missing pair so a riscv64 cloud image (qcow2 / vhdx for QEMU + KVM hosts running riscv64 VMs) builds out of the box.

Changes

File Change
`config/boards/uefi-riscv64.csc` Append `cloud` to `KERNEL_TARGET`
`config/kernel/linux-uefi-riscv64-cloud.config` New — lean cloud config seeded from `linux-uefi-arm64-cloud.config` (close arch peer), ARM64 lines stripped, RISCV lines added

Why arm64-cloud as the template

  • `x86-cloud`: 398 lines
  • `arm64-cloud`: 383 lines
  • `riscv64-cloud` (this PR): 382 lines
  • (vs `riscv64-current`: 3148 lines — way too fat for a VM kernel)

arm64-cloud is the closer arch peer (no x86-specific microcode, ACPI variants, Intel ME, etc.). Three arm64-only options removed:

  • `CONFIG_ARM64_VA_BITS_48`
  • `CONFIG_ARM64_PSEUDO_NMI`
  • `CONFIG_CRYPTO_AES_ARM64_CE`

Two riscv64-only options added (the same two `linux-uefi-riscv64-current.config` declares):

  • `CONFIG_RISCV_SBI_V01=y`
  • `CONFIG_SERIAL_EARLYCON_RISCV_SBI=y`

The rest of the cloud config is arch-agnostic — virtio drivers, BPF, IP stack, cgroups, KVM-guest essentials, virtio-gpu / simpledrm for graphics. Same shape as the other two cloud variants.

Existing wiring already covers the rest

The cloud-specific build-framework behavior already lives in `uefi_common.inc`:

```bash
cloud)
declare -g KERNEL_MAJOR_MINOR="6.18"
declare -g LINUXCONFIG="linux-uefi-${LINUXFAMILY}-cloud"
declare -g INSTALL_ARMBIAN_FIRMWARE="no"
declare -g EXTRAWIFI="no"
declare -g UEFI_GRUB_TIMEOUT=0
declare -g QCOW2_RESIZE_AMOUNT="16G"
add_packages_to_image qemu-guest-agent spice-vdagent
```

No changes needed there — LINUXFAMILY=riscv64 + BRANCH=cloud now resolves to a real config.

Test plan

  • `./compile.sh build BOARD=uefi-riscv64 BRANCH=cloud RELEASE=trixie BUILD_MINIMAL=yes` produces an image
  • qcow2 variant boots in qemu-system-riscv64 with KVM if available, falls back to TCG otherwise
  • qemu-guest-agent + spice-vdagent installed inside (`dpkg -l`)
  • Kernel modules: `lsmod` shows virtio-net, virtio-blk, virtio-gpu loaded; no SBC drivers

Summary by CodeRabbit

  • New Features

    • Added official "cloud" kernel target for UEFI RISC-V64 systems.
    • Default kernel command line updated to enable a framebuffer+serial (dual) console for cloud images.
  • Bug Fixes

    • Improved bootloader installation to avoid failures when device-tree blobs are absent, making cloud/VM boots more reliable.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a1086715-4a50-4de3-9b83-da6adbbffcca

📥 Commits

Reviewing files that changed from the base of the PR and between f102587 and 5f30fc0.

📒 Files selected for processing (1)
  • config/sources/families/include/uefi_common.inc

📝 Walkthrough

Walkthrough

Adds cloud to the UEFI RISC-V64 board kernel targets, includes an Armbian-generated linux-uefi-riscv64-cloud kernel .config (kernel 6.18), makes GRUB DTB copying conditional, and appends console=tty1 to the UEFI cloud branch kernel cmdline.

Changes

UEFI RISC-V64 Board Configuration

Layer / File(s) Summary
Kernel target configuration
config/boards/uefi-riscv64.csc
KERNEL_TARGET is updated to include cloud alongside current, edge, and legacy.
Add linux-uefi-riscv64-cloud kernel config
config/kernel/linux-uefi-riscv64-cloud.config
Adds a complete Armbian-generated kernel .config (kernel 6.18) with core options, networking/netfilter, drivers, filesystems, security/crypto, tracing, and RISC-V SBI/early console settings.
GRUB DTB copy guard in installer
extensions/grub-riscv64.sh
pre_umount_final_image__install_grub now checks /boot/dtb for files before creating ${chroot_target}/boot/efi/dtb and copying DTBs; logs and skips copy if none present.
UEFI cloud branch kernel cmdline
config/sources/families/include/uefi_common.inc
Appends console=tty1 to GRUB_CMDLINE_LINUX_DEFAULT in the cloud branch and documents the resulting dual-console behavior.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

Patches

Poem

🐰 A tiny hop to mark the day,
Cloud target added on its way,
A kernel long, options in tow,
GRUB skips DTBs when none will show,
Console lines settle, builds aglow.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding a 'cloud' kernel target to the uefi-riscv64 board configuration.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch uefi-riscv64-add-cloud-kernel

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added 05 Milestone: Second quarter release size/large PR with 250 lines or more Needs review Seeking for review Hardware Hardware related like kernel, U-Boot, ... labels May 18, 2026
x86 and arm64 UEFI both have a cloud kernel variant; riscv64 didn't.
This adds the missing pair so a riscv64 cloud image (qcow2 / vhdx
for QEMU + KVM hosts running riscv64 VMs) builds out of the box.

Two changes:

  - config/boards/uefi-riscv64.csc: append `cloud` to KERNEL_TARGET
    so the framework knows to expose it.
  - config/kernel/linux-uefi-riscv64-cloud.config: seed from the
    current riscv64 UEFI config. Same kernel version (6.18, per
    uefi_common.inc's cloud branch) so the seed is appropriate.

The cloud-specific leanness comes from uefi_common.inc's cloud arm
(INSTALL_ARMBIAN_FIRMWARE=no, EXTRAWIFI=no, UEFI_GRUB_TIMEOUT=0,
qemu-guest-agent + spice-vdagent in the image). Stripping kernel
modules to match x86-cloud's lean shape (~400 lines vs current's
3148) can come as a follow-up once we have field data on what's
actually needed for riscv64 VMs.
@igorpecovnik igorpecovnik force-pushed the uefi-riscv64-add-cloud-kernel branch from eef855a to 1272e78 Compare May 18, 2026 21:37
The DTB-to-ESP copy assumed /boot/dtb/* always exists. True for
SBC riscv64 kernels (StarFive, SiFive, etc.) which ship per-board
DTBs; false for cloud/VM kernels where the firmware
(QEMU/EDK2/OpenSBI) generates the device tree at boot.

Result on uefi-riscv64 BRANCH=cloud:
  cp: cannot stat '/.../boot/dtb/*': No such file or directory
  Error 1 in pre_umount_final_image__install_grub

Guard the copy with compgen -G so the directory-but-no-files case
is also skipped (some kernels create the dir but install no .dtb).
On the no-DTB path, emit an info-level alert instead of failing.

Existing SBC riscv64 builds (kernels that ship DTBs) hit the same
old path and continue to work unchanged.

Also added a brief comment explaining the
  sed -i 's,devicetree,echo,g' /etc/grub.d/10_linux
line two below: it rewrites GRUB's `devicetree` stanza emitter to
'echo' so update-grub doesn't bake in a hardcoded DTB path that
fails at boot when the file isn't present (cloud) or when an SBC
swaps storage between models (SBC).
@github-actions github-actions Bot added the Framework Framework components label May 18, 2026
Cloud images output to serial only by default (SERIALCON=ttyS0 gets
appended by the grub-${LINUXFAMILY} extension), so users viewing the
VM through Cockpit-machines / virt-manager / a hosting-panel VNC
viewer see "Display output is not active" forever — even though the
guest is happily booting and serving SSH.

Add console=tty1 to the cloud-branch base cmdline. Linux writes
boot messages to BOTH declared consoles; /dev/console (where
systemd-getty-generator spawns the unattended login) maps to the
LAST console=, which after the SERIALCON append is still ttyS0 —
so cloud-init / serial workflows stay untouched. The framebuffer
console just becomes a read-only window for operators glancing at
VNC.

Universal across x86 / arm64 / riscv64 UEFI cloud (riscv64 cloud
landed two commits ago). Safe on hosts without a virtio-gpu device
attached: kernel silently drops the tty1 console, falls back to
serial-only — no regression.

Kernel config requirements (CONFIG_VT + CONFIG_FRAMEBUFFER_CONSOLE)
are already pulled in transitively by the existing CONFIG_FB +
CONFIG_DRM_SIMPLEDRM + CONFIG_DRM_VIRTIO_GPU set in all three
*-cloud configs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

05 Milestone: Second quarter release Framework Framework components Hardware Hardware related like kernel, U-Boot, ... Needs review Seeking for review size/large PR with 250 lines or more

Development

Successfully merging this pull request may close these issues.

1 participant