Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for RISC-V #121

Draft
wants to merge 37 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
f5dbfc7
Start adding support for RISC-V
Ivan-Velickovic Apr 2, 2023
87b1eef
checkpoint: linux is starting to boot. Now need to do PLIC emulation
Ivan-Velickovic Sep 9, 2024
7e8d062
checkpoint: get further into booting linux, but still problems
Ivan-Velickovic Sep 10, 2024
59b2243
checkpoint: linux booting progressing
Ivan-Velickovic Sep 10, 2024
c852e1e
checkpoint: linux getting to user-space, but crashing in user-space
Ivan-Velickovic Sep 12, 2024
7f227ab
checkpoint: it works!!!! user-space works and IRQs work
Ivan-Velickovic Sep 13, 2024
30ac5c8
[no ci] examples/simple: add ariane to build.zig
Ivan-Velickovic Nov 1, 2024
de1d942
examples/simple: fix to compile on aarch64 again
Ivan-Velickovic Nov 4, 2024
c887558
[no ci] examples/simple: fix comment for multi-arch
Ivan-Velickovic Nov 6, 2024
15a4858
[no ci]: cheshire
Ivan-Velickovic Dec 2, 2024
74c8901
[no ci]: implement vCPU/TCB register printing for RISC-V
Ivan-Velickovic Dec 5, 2024
be92eca
[no ci]: fix SEL4_USER_CONTEXT_SIZE on RISC-V
Ivan-Velickovic Dec 5, 2024
16103d3
[no ci]: implement legacy SBI extension for console putchar/getchar
Ivan-Velickovic Dec 5, 2024
2a36e10
[no ci] examples/simple/build.zig: fix for latest zig
Ivan-Velickovic Jan 7, 2025
f79360f
[no ci] plic.h, add defines for Cheshire
Ivan-Velickovic Jan 7, 2025
6b376fc
[no ci] examples/simple/build.zig: minor fixes
Ivan-Velickovic Jan 7, 2025
894c9db
[no ci] fixes for cheshire
Ivan-Velickovic Jan 7, 2025
b9b9db9
[no ci] simple: fix for latest kernel QEMU RISC-V virt
Ivan-Velickovic Feb 10, 2025
ecbcbe3
[no ci]: change qemu_virt_riscv64 to defconfig Linux image, add fixes…
Ivan-Velickovic Feb 11, 2025
14afd85
fix
Ivan-Velickovic Feb 11, 2025
1bdce22
cheshire wip
Ivan-Velickovic Feb 11, 2025
94eb29b
cheshire wip
Ivan-Velickovic Feb 11, 2025
3431605
p550: initial port. status is that kernel boots but no user-space con…
Ivan-Velickovic Feb 12, 2025
a84e6f8
comment out logs
Ivan-Velickovic Feb 12, 2025
8994f61
[no ci]: decode htinst instead of decoding instruction based on guest…
Ivan-Velickovic Feb 12, 2025
a174232
Revert "[no ci]: decode htinst instead of decoding instruction based …
Ivan-Velickovic Feb 12, 2025
594fd6c
[no ci]: p550,qemu_virt_riscv64: enable FPU again. Fixed seL4 issue w…
Ivan-Velickovic Feb 19, 2025
c57de47
vmm.c: minor fix
Ivan-Velickovic Feb 19, 2025
9ccdbe3
fault.c: remove comment, put TODO in my own notes instead
Ivan-Velickovic Feb 19, 2025
85fa7cb
plic.c: add todo
Ivan-Velickovic Feb 19, 2025
021d24a
plic.c: fixes to IRQ handling
Ivan-Velickovic Feb 19, 2025
9de8a6c
[no ci] p550: use same Linux image as QEMU virt RISC-V
Ivan-Velickovic Feb 19, 2025
71cf334
[no ci] start getting RISC-V working with virtIO
Ivan-Velickovic Feb 19, 2025
b4396d8
[no ci] examples/simple: use slimmed down Linux for qemu_virt_riscv64
Ivan-Velickovic Feb 19, 2025
c48aef4
p550 overlay.dts changes/fixes
Ivan-Velickovic Feb 20, 2025
c88eb67
mmio.c: fix
Ivan-Velickovic Feb 20, 2025
a51fa09
[no ci] package_guest_images: use rodata instead of separate sections
Ivan-Velickovic Feb 20, 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
19 changes: 15 additions & 4 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const std = @import("std");
const LazyPath = std.Build.LazyPath;

const src = [_][]const u8{
"src/fault.c",
"src/guest.c",
"src/util/util.c",
"src/util/printf.c",
Expand Down Expand Up @@ -34,6 +35,15 @@ const src_aarch64 = [_][]const u8{
"src/arch/aarch64/vcpu.c",
};

const src_riscv64 = [_][]const u8{
"src/arch/riscv/fault.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",
};

pub fn build(b: *std.Build) void {
const optimize = b.standardOptimizeOption(.{});
const target = b.standardTargetOptions(.{});
Expand All @@ -59,29 +69,30 @@ pub fn build(b: *std.Build) void {
.libmicrokit_linker_script = @as([]const u8, libmicrokit_linker_script_opt.?),
});

const src_arch = switch (target.result.cpu.arch) {
const src_files = switch (target.result.cpu.arch) {
.aarch64 => blk: {
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;
break :blk &(src ++ src_aarch64 ++ vgic_src);
},
.riscv64 => &(src ++ src_riscv64),
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 = src_files,
.flags = &.{
"-Wall",
"-Werror",
"-Wno-unused-function",
"-mstrict-align",
"-fno-sanitize=undefined", // @ivanv: ideally we wouldn't have to turn off UBSAN
// "-fno-sanitize=undefined", // @ivanv: ideally we wouldn't have to turn off UBSAN
}
});

Expand Down
42 changes: 42 additions & 0 deletions examples/simple/board/cheshire/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# QEMU ARM virt images

## Linux kernel

### Details
* Image name: `linux`
* Config name: `linux_config`
* Git remote: https://github.com/torvalds/linux.git
* Tag: v6.5 (commit hash: `2dde18cd1d8fac735875f2e4987f11817cc0bc2c`)
* Toolchain: `riscv64-linux-gnu-`
* Version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0

You can also get the Linux config used after booting by running the following
command in userspace: `zcat /proc/config.gz`.

### Instructions for reproducing
```
git clone --depth 1 --branch v6.5 https://github.com/torvalds/linux.git
cp linux_config linux/.config
make -C linux ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- all -j$(nproc)
```

The path to the image is: `linux/arch/riscv/boot/Image`.

## Buildroot RootFS image

### Details
* Image name: `rootfs.cpio.gz`
* Config name: `buildroot_config`
* Version: 2023.08.1

### Instructions for reproducing

```
wget https://buildroot.org/downloads/buildroot-2023.08.1.tar.xz
tar xvf buildroot-2023.08.1.tar.xz
cp buildroot_config buildroot-2022.08.1/.config
make -C buildroot-2023.08.1
```

The root filesystem will be located at: `buildroot-2023.08.1/output/images/rootfs.cpio.gz` along
with the other buildroot artefacts.
Loading