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

Add support for RISC-V #121

wants to merge 37 commits into from

Conversation

Ivan-Velickovic
Copy link
Collaborator

This PR adds initial support for RISC-V guests to libvmm.

Right now, only 64-bit guests are supported/tested.

This PR is a draft as there is still much more work to do and more to test/fix such as multiple vCPUs are more complex example systems, but right now a Linux guest can boot and get into user-space.

This PR will likely not be merged for a while as it depends on changes to seL4, which will require an RFC and code review that typically takes months.

To try out this PR, you will need changes a specific branch of Microkit and seL4:

@Ivan-Velickovic Ivan-Velickovic force-pushed the riscv branch 3 times, most recently from 0d6bfd7 to cafeace Compare November 6, 2024 00:04
@Ivan-Velickovic Ivan-Velickovic force-pushed the riscv branch 2 times, most recently from 27b20d3 to 0a1299e Compare December 2, 2024 04:43
Signed-off-by: Ivan Velickovic <[email protected]>
Now we are stuck on this line:
'cpuidle: using governor menu'
Current progress:
```
[    0.095968] Unpacking initramfs...
[    0.212981] Freeing initrd memory: 16384K
[    0.214101] workingset: timestamp_bits=46 max_order=16 bucket_order=0
[    0.216709] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 246)
[    0.216914] io scheduler mq-deadline registered
[    0.217026] io scheduler kyber registered
[    0.217192] io scheduler bfq registered
VMM|INFO: handling fault 'virtual memory exception'
VMM|INFO: fault on addr 0xc002080
VMM|INFO: handling plic 0xc002080
VMM|INFO: satp: 0xa0000000000814f7
Failed assertion '(satp >> 60) == SV39_MODE' at /Users/ivanv/ts/libvmm/src/arch/riscv/fault.c:111 in function guest_virtual_physical
```

now need to deal with PLIC faults

Things are a bit concerning because I had to disable two Linux
kernel config options:
* CONFIG_RISCV_ISA_ZICBOM
* CONFIG_RISCV_PROBE_UNALIGNED_ACCESS

ZICBOM was causing a vCPU fault, maybe there's something that seL4 needs
to allow at VS level that it's not. What's weirder is that program counter
in Linux was at the specific point of a no-op instruction which is weird.

Secondly, RISCV_PROBE_UNALIGNED_ACCESS was causing some hanging because
it's using `rdtime` to determine whether unaligned access is allowed by
the hardware. This again is an issue with how we are emulating as the
Linux image with both of these configs enabled runs fine bare-metal on
QEMU (without seL4 involved.).

More investigation required...
Problem is that FPU access in Linux or Linux user-space causes
exceptions *in Linux*, which is weird for two reasons:

1. We have the FPU enabled for QEMU in seL4 so I would think that the
   guest would have FPU access as well.
2. Why is an illegal instruction exception that happened *within Linux*
   being handled by Linux instead of the VMM?
Timer IRQs are now handled, some fixes in seL4 itself were needed
Signed-off-by: Ivan-Velickovic <[email protected]>
…sole

Most likely issue with bootargs/rootfs configuration.
…on guest memory"

This reverts commit 47e1fe338493daf444238c9762de115e1544d554. Seems
like on the HiFive P550 we get htinst of zero some times which means
we have to do the encoding. This is temporary and instead what we want
is that we only do the encoding when we get htinst as zero.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant