No description
  • Rust 90.2%
  • Shell 6.8%
  • Linker Script 1.2%
  • Assembly 0.9%
  • Dockerfile 0.9%
Find a file
CMGS 01e9a847e1 efi: Implement reset_system for Cloud Hypervisor
The ResetSystem runtime service was intentionally left as a no-op to
force Linux to use ACPI for shutdown. However, Windows calls
ResetSystem(EfiResetShutdown) as its final shutdown step and does not
fall back to ACPI when the call returns. This causes the Cloud
Hypervisor process to hang indefinitely after Windows shuts down.

Write the appropriate value to Cloud Hypervisor's shutdown I/O port
(0x600) based on the reset type:
- EfiResetShutdown: SLP_TYP=5 + SLP_EN (triggers VM exit)
- EfiResetCold/Warm: reboot value (triggers VM reset)

The service is split into two phases because EFI applications like shim
call ResetSystem during early boot when MOK state import fails
(set_variable returns UNSUPPORTED). Writing to the shutdown port there
made VMs either shut down on Cloud Hypervisor or hang on QEMU during
boot. So reset_system_boot keeps the old no-op behavior during boot
services, and the port I/O only becomes active after ExitBootServices.

fixup_at_virtual remaps reset_system to its virtual address rather than
not_available, so ResetSystem still works after SetVirtualAddressMap,
which Windows needs to shut down on Cloud Hypervisor.

Linux guests are unaffected as they use ACPI directly.

Fixes: cloud-hypervisor/rust-hypervisor-firmware#422

Signed-off-by: CMGS <ilskdw@gmail.com>
2026-09-11 09:37:36 +00:00
.github build: Bump actions/setup-python from 1 to 7 2026-09-10 02:44:32 +00:00
resources resources: Do rustup after coreboot installation 2023-05-30 09:48:31 +01:00
scripts scripts: propagate UID/GID to container on build 2026-09-09 15:58:26 +00:00
src efi: Implement reset_system for Cloud Hypervisor 2026-09-11 09:37:36 +00:00
.gitignore tests: Add containerized build 2021-11-03 18:17:53 +09:00
aarch64-unknown-none.json build: Update toolchain to nightly-2025-06-05 2025-06-06 09:35:28 +00:00
aarch64-unknown-none.ld build: Add GOT sections to linker scripts 2025-06-06 09:35:28 +00:00
build.rs build: Watch riscv64 target json and linker script 2023-12-13 10:07:18 +09:00
Cargo.lock build: Bump uart_16550 from 0.4.0 to 0.8.0 2026-09-10 02:32:47 +00:00
Cargo.toml build: Bump uart_16550 from 0.4.0 to 0.8.0 2026-09-10 02:32:47 +00:00
CODE_OF_CONDUCT.md misc: Add Code of Conduct and contribution guide 2019-05-13 18:59:29 +01:00
CONTRIBUTING.md misc: Add Code of Conduct and contribution guide 2019-05-13 18:59:29 +01:00
LICENSE Initial commit of very basic functionality 2019-05-10 09:47:31 +01:00
MAINTAINERS.md docs: Update security process 2022-08-01 15:35:06 +01:00
README.md build: Remove heap allocator 2024-05-15 11:47:17 +00:00
riscv64gcv-unknown-none-elf.json build: Update toolchain to nightly-2025-06-05 2025-06-06 09:35:28 +00:00
riscv64gcv-unknown-none-elf.ld build: Add GOT sections to linker scripts 2025-06-06 09:35:28 +00:00
rust-toolchain.toml build: Update toolchain to nightly-2025-06-05 2025-06-06 09:35:28 +00:00
rustfmt.toml fat,loader: revert import grouping and add empty rustfmt.toml 2022-08-01 08:43:41 +01:00
x86_64-unknown-none.json build: Update toolchain to nightly-2025-06-05 2025-06-06 09:35:28 +00:00
x86_64-unknown-none.ld build: Add GOT sections to linker scripts 2025-06-06 09:35:28 +00:00

Rust Hypervisor Firmware

This repository contains a simple firmware that is designed to be launched from anything that supports loading ELF binaries and running them with the PVH booting standard

The purpose is to be able to use this firmware to be able to load a bootloader from within a disk image without requiring the use of a complex firmware such as TianoCore/edk2 and without requiring the VMM to reuse functionality used for booting the Linux kernel.

Currently it will directly load a kernel from a disk image that follows the Boot Loader Specification

There is also minimal EFI compatibility support allowing the boot of some images that use EFI (shim + GRUB2 as used by Ubuntu).

The firmware is primarily developed against Cloud Hypervisor but there is also support for using QEMU's PVH loader.

This project was originally developed using Firecracker however as it does not currently support resetting the virtio block device it is not possible to boot all the way into the OS.

Features

  • virtio (PCI) block support
  • GPT parsing (to find EFI system partition)
  • FAT12/16/32 directory traversal and file reading
  • bzImage loader
  • "Boot Loader Specification" parser
  • PE32+ loader
  • Minimal EFI environment (sufficient to boot shim + GRUB2 as used by Ubuntu)

x86-64 Support

Building

To compile:

cargo build --release --target x86_64-unknown-none.json -Zbuild-std=core -Zbuild-std-features=compiler-builtins-mem

The result will be in:

target/x86_64-unknown-none/release/hypervisor-fw

Running

Works with Cloud Hypervisor and QEMU via their PVH loaders as an alternative to the Linux kernel.

Cloud Hypervisor and QEMU are currently the primary development targets for the firmware although support for other VMMs will be considered.

Cloud Hypervisor

As per getting started

However instead of using the binary firmware for the parameter to --kernel instead use the binary you build above.

$ pushd $CLOUDH
$ sudo setcap cap_net_admin+ep ./cloud-hypervisor/target/release/cloud-hypervisor
$ ./cloud-hypervisor/target/release/cloud-hypervisor \
	--kernel ./target/x86_64-unknown-none/release/hypervisor-fw \
	--disk path=focal-server-cloudimg-amd64.raw \
	--cpus boot=4 \
	--memory size=512M \
	--net "tap=,mac=,ip=,mask=" \
	--rng
$ popd

QEMU

Use the QEMU -kernel parameter to specify the path to the firmware.

e.g.

$ qemu-system-x86_64 -machine q35,accel=kvm -cpu host,-vmx -m 1G\
    -kernel ./target/x86_64-unknown-none/release/hypervisor-fw \
    -display none -nodefaults \
    -serial stdio \
    -drive id=os,file=focal-server-cloudimg-amd64.raw,if=none \
    -device virtio-blk-pci,drive=os,disable-legacy=on

AArch64 Support

Building

To compile:

cargo build --release --target aarch64-unknown-none.json -Zbuild-std=core -Zbuild-std-features=compiler-builtins-mem

The result will be in:

target/aarch64-unknown-none/release/hypervisor-fw

RISC-V Support

Experimental RISC-V support is available. This is currently designed to run as a payload from OpenSBI under QEMU virt. It is expected wider platform support will become available in the future.

Building

To compile:

cargo build --release --target riscv64gcv-unknown-none-elf.json -Zbuild-std=core -Zbuild-std-features=compiler-builtins-mem

The result will be in:

target/riscv64gcv-unknown-none-elf/release/hypervisor-fw

Running

Currently only QEMU has been tested.

QEMU

$ qemu-system-riscv64  -M virt -cpu rv64 -smp 1 -m 1024 \
    -nographic -kernel target/riscv64gcv-unknown-none-elf/release/hypervisor-fw \
    -drive id=mydrive,file=root.img,format=raw \
    -device virtio-blk-pci,drive=mydrive,disable-legacy=on

Testing

"cargo test" needs disk images from make-test-disks.sh

And clear-28660-kvm.img:

https://download.clearlinux.org/releases/28660/clear/clear-28660-kvm.img.xz

sha1sum: 5fc086643dea4b20c59a795a262e0d2400fab15f

Security issues

Please contact the maintainers listed in the MAINTAINERS.md file with security issues.