Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6b08d4f
Add support for RISC-V
Ivan-Velickovic Sep 2, 2025
d05a343
extract arch-independent Linux checks
Ivan-Velickovic Jul 24, 2025
35f3475
examples/simple: add QEMU virt RISC-V support
Ivan-Velickovic Sep 2, 2025
4d9b774
examples/virtio: add support for QEMU virt RISC-V
Ivan-Velickovic Sep 2, 2025
97a04f0
aarch64/virq.c: style
Ivan-Velickovic Jul 21, 2025
522f04b
Move vIRQ passthrough handling to architecture independent code
Ivan-Velickovic Jul 23, 2025
2801475
styling
Ivan-Velickovic Jul 24, 2025
81e07c1
checkpoint: Linux capable of booting multiple vCPUs
Ivan-Velickovic Jul 24, 2025
01e4233
riscv: passthrough irq and fault handling fixes
Ivan-Velickovic Jul 29, 2025
0fc1422
Fixes for rebase
Ivan-Velickovic Sep 2, 2025
1a1905a
plic.c: debug prints remove
Ivan-Velickovic Sep 2, 2025
872a5f4
fault.c: add debug function to dump instruction info
Ivan-Velickovic Sep 4, 2025
f71f1f8
build.zig improvements and add support for p550,
Ivan-Velickovic Sep 4, 2025
c85ffa2
plic.h: add define for p550
Ivan-Velickovic Sep 4, 2025
45a8ae5
wip: getting virtio example working on p550, without block support
Ivan-Velickovic Sep 4, 2025
d9e2679
wip: debugging guest virtual to physical translation
Ivan-Velickovic Sep 4, 2025
04a2072
fault.c: correct pointer arithmetic when reading instructions from gu…
Ivan-Velickovic Sep 4, 2025
c96e2ee
fault.c: revert debugging changes
Ivan-Velickovic Sep 4, 2025
3a9e69a
examples/virtio: undo disabling virtio net device
Ivan-Velickovic Sep 4, 2025
9eb1fb2
util.h: avoid redefinition of BIT
Ivan-Velickovic Sep 5, 2025
1290319
fault.c: support guest virtual to physical translation for Sv48 and Sv59
Ivan-Velickovic Sep 5, 2025
f8b6662
examples/simple: port for HiFive P550, not currently working
Ivan-Velickovic Sep 5, 2025
f44ab72
Add LICENSES/GPL-2-only.txt
Ivan-Velickovic Sep 5, 2025
b679254
pin sddf submodule to branch with P550 patches
Ivan-Velickovic Sep 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
319 changes: 319 additions & 0 deletions LICENSES/GPL-2.0-only.txt

Large diffs are not rendered by default.

34 changes: 27 additions & 7 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ const LazyPath = std.Build.LazyPath;

const src = [_][]const u8{
"src/guest.c",
"src/fault.c",
"src/linux.c",
"src/dtb.c",
"src/virq.c",
"src/util/util.c",
"src/util/printf.c",
"src/virtio/mmio.c",
Expand Down Expand Up @@ -34,6 +38,16 @@ const src_aarch64 = [_][]const u8{
"src/arch/aarch64/vcpu.c",
};

const src_riscv = [_][]const u8{
"src/arch/riscv/fault.c",
"src/arch/riscv/sbi.c",
"src/arch/riscv/linux.c",
"src/arch/riscv/tcb.c",
"src/arch/riscv/vcpu.c",
"src/arch/riscv/virq.c",
"src/arch/riscv/plic.c",
};

/// Convert the target for Microkit (e.g freestanding AArch64 or RISC-V) to the Linux
/// equivalent. Assumes musllibc will be used.
fn linuxTarget(b: *std.Build, target: std.Build.ResolvedTarget) std.Build.ResolvedTarget {
Expand All @@ -44,7 +58,7 @@ fn linuxTarget(b: *std.Build, target: std.Build.ResolvedTarget) std.Build.Resolv
return b.resolveTargetQuery(query);
}

pub fn build(b: *std.Build) void {
pub fn build(b: *std.Build) !void {
const optimize = b.standardOptimizeOption(.{});
const target = b.standardTargetOptions(.{});

Expand All @@ -69,23 +83,29 @@ pub fn build(b: *std.Build) void {
.microkit_board_dir = microkit_board_dir
});

const src_arch = switch (target.result.cpu.arch) {
.aarch64 => blk: {
var srcs = std.ArrayList([]const u8){};
defer srcs.deinit(b.allocator);

try srcs.appendSlice(b.allocator, &src);

switch (target.result.cpu.arch) {
.aarch64 => {
const vgic_src = switch (arm_vgic_version.?) {
2 => src_aarch64_vgic_v2,
3 => src_aarch64_vgic_v3,
else => @panic("Unsupported vGIC version given"),
};

break :blk src_aarch64 ++ vgic_src;
try srcs.appendSlice(b.allocator, &src_aarch64);
try srcs.appendSlice(b.allocator, &vgic_src);
},
.riscv64 => try srcs.appendSlice(b.allocator, &src_riscv),
else => {
std.log.err("Unsupported libvmm architecture given '{s}'", .{ @tagName(target.result.cpu.arch) });
std.posix.exit(1);
}
};
}
libvmm.addCSourceFiles(.{
.files = &(src ++ src_arch),
.files = srcs.items,
.flags = &.{
"-Wall",
"-Werror",
Expand Down
5 changes: 3 additions & 2 deletions examples/rust/src/vmm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use core::ffi::{c_void};
use sel4_microkit::{protection_domain, MessageInfo, Channel, Child, Handler, debug_println};

const GUEST_RAM_VADDR: usize = 0x40000000;
const GUEST_RAM_SIZE: usize = 0x10000000;
const GUEST_DTB_VADDR: usize = 0x4f000000;
const GUEST_INIT_RAM_DISK_VADDR: usize = 0x4d700000;
const GUEST_VCPU_ID: usize = 0;
Expand All @@ -33,7 +34,7 @@ const UART_CH: Channel = Channel::new(1);
#[link(name = "vmm", kind = "static")]
#[link(name = "microkit", kind = "static")]
extern "C" {
fn linux_setup_images(ram_start: usize,
fn linux_setup_images(ram_start: usize, ram_size: usize,
kernel: usize, kernel_size: usize,
dtb_src: usize, dtb_dest: usize, dtb_size: usize,
initrd_src: usize, initrd_dest: usize, initrd_size: usize) -> usize;
Expand Down Expand Up @@ -70,7 +71,7 @@ fn init() -> VmmHandler {
let initrd_addr = initrd.as_ptr() as usize;

unsafe {
let guest_pc = linux_setup_images(GUEST_RAM_VADDR,
let guest_pc = linux_setup_images(GUEST_RAM_VADDR, GUEST_RAM_SIZE,
linux_addr, linux.len(),
dtb_addr, GUEST_DTB_VADDR, dtb.len(),
initrd_addr, GUEST_INIT_RAM_DISK_VADDR, initrd.len()
Expand Down
Loading
Loading