Skip to content

Riscv vmm #251

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Riscv vmm #251

wants to merge 10 commits into from

Conversation

samvosys
Copy link

@samvosys samvosys commented Feb 5, 2025

Summary of the PR

This pull request adds support for the RISC-V architecture and updates the vmm-reference crate dependencies to the following versions:

  • linux-loader 0.13.0
  • vm-memory 0.16.0
  • kvm-ioctls 0.20.0
  • kvm-bindings 0.11.0
  • vmm-sys-util 0.12.1
  • event-manager 0.4.0
  • vm-superio 0.8.0
  • vm-fdt 0.3.0
  • clap 4.5.28

Interrupt Handling

A key aspect of porting vmm-reference to RISC-V is the handling of interrupts.

For x86 and aarch64, vmm-reference relies on the KVM-provided irqchip and uses IRQFD for interrupt injection.
However, in RISC-V we could not rely on the same mechanism for injecting the interrupt because of an issue - which we are investigating - in the virtualization of edge interrupts in KVM. For this reason, it has been used an IOCTL that allow us to perform this operation from userspace. This implementation leverages the in-kernel irqchip (APLIC). Interrupts are signaled through an abstraction called APlicTrigger, which implements the Trigger trait. This allows devices to trigger interrupts similarly to IRQFD, but in this case, injection is performed via APlicTrigger using the KVM_SET_IRQ_LINE ioctl.

New Features

This PR also introduces two new features:

--dtb: Allows passing a custom device tree.
--dtb-dump: Enables dumping the current device tree blob (DTB).

Requirements

Before submitting your PR, please make sure you addressed the following
requirements:

  • All commits in this PR have Signed-Off-By trailers (with
    git commit -s), and the commit message has max 60 characters for the
    summary and max 75 characters for each description line.
  • All added/changed functionality has a corresponding unit/integration
    test.
  • All added/changed public-facing functionality has entries in the "Upcoming
    Release" section of CHANGELOG.md (if no such section exists, please create one).
  • Any newly added unsafe code is properly documented.

The following crates have been updated to a newer version
kvm-ioctls 0.13.0
kvm-bindings 0.6
vmm-sys-util 0.11.2
event-manager 0.3.0

Signed-off-by: Alvise Rigo <[email protected]>
Reviewed-by: Timos Ampelikiotis <[email protected]>
The new version of vm-memory requires to bump the log crate to version
0.4.20 and vm-virtio to 0.10.0. This has various consequences to the
rest of the code. In particular:

The vmm crate had to be reworked to add a reference to the guest memory
in various places as it is not part of the Queue struct anymore.  For
this reason, it is preferable to wrap the array of Arc<GuestRegionMmap>
with an Arc reference to optimize the various clone() operation that
will be added. This has the advantage of reducing the duplication of
memory and makes sure the various parts of the code to see the same
array of elements (which would not be the case if we clone the array of
Arc<> iteself). While at it, the reference to the guest memory was added
to some key virtio functions.

devices::virtio::{self, block, net} had all to be updated to also accept
the Arc reference to the guest memory.

Signed-off-by: Alvise Rigo <[email protected]>
Reviewed-by: Timos Ampelikiotis <[email protected]>
Signed-off-by: Alvise Rigo <[email protected]>
Reviewed-by: Timos Ampelikiotis <[email protected]>
Update to align to the new Cmdline API and kernel image loader.  While
at it, update the load_kernel() tests as well.

Signed-off-by: Alvise Rigo <[email protected]>
Reviewed-by: Timos Ampelikiotis <[email protected]>
Signed-off-by: Alvise Rigo <[email protected]>
This commit updates the following:
- vm-memory
- vmm-sys-util
- kvm-ioctls
- kvm-bindings
- linux-loader
- virtio-queue
- virtio-blk
- virtio-device
- vm-superio
- clap

Signed-off-by: Samuele Paone <[email protected]>
This commit adds the --dump-dtb, which enables the user to make a dump
of the dtb being used

Signed-off-by: Samuele Paone <[email protected]>
This commit adds the --dtb option which enables the user to upload his
own dtb

Signed-off-by: Samuele Paone <[email protected]>
This commit implments the device tree autogeneration for the RISC-V
architecture

Signed-off-by: Samuele Paone <[email protected]>
This commit implements a first support to the RISC-V architecture. Major
changes are related to interrupts handling:
- use of in-kernel IRQCHIP (APLIC)
- interrupt injection from userspace through kvm ioctl
  (KVM_SET_IRQ_LINE)

Signed-off-by: Samuele Paone <[email protected]>
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.

2 participants