Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

Merge kvm-ioctls git history into this repository #125

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

Conversation

epilys
Copy link
Member

@epilys epilys commented Oct 28, 2024

The failed checks here seem irrelevant for this PR (one is missing signed offs in existing commits, the buildkite failure is about commit message style lint failure). We're not rewriting history so these are irrelevant. What needs checking is that both tests from both repositories get triggered for this branch; how would we go doing this?

Summary of the PR

See rust-vmm/kvm#291

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.

acatangiu and others added 30 commits November 27, 2019 15:02
Signed-off-by: Adrian Catangiu <acatan@amazon.com>
Signed-off-by: Adrian Catangiu <acatan@amazon.com>
Signed-off-by: Adrian Catangiu <acatan@amazon.com>
Changed `kvm_ioctls::Result` to work with `errno::Result` instead
of `io::Result`.

No longer exporting `kvm_ioctls::Result`. Users of this crate should
not have to use `kvm_ioctls::Result` outside the crate.

Now exporting `kvm_ioctls::Error` type definition so that users of
this crate can create their own wrapping errors without having to know
the `Error` type used internally by this crate.

Signed-off-by: Adrian Catangiu <acatan@amazon.com>
Signed-off-by: Adrian Catangiu <acatan@amazon.com>
Signed-off-by: Adrian Catangiu <acatan@amazon.com>
KVM_GET_VCPU_EVENTS and KVM_SET_VCPU_EVENTS ioctls have been supported
on Aarch64 from a recent kernel version.
This patch enables them on Aarch64 and checked cap KVM_CAP_VCPU_EVENTS
before calling them in test code to avoid error in old kernel.

Change-Id: I9526b48948cf0cd5d63444a82b8b09970311a3bb
Signed-off-by: Michael Zhao <michael.zhao@arm.com>
The test was previously marked as x86_64 and aarch64 compatible.

On aarch64 we were testing only the error case. On older kernel
versions, creating an irqchip before creating the vCPU would return
an error. This restrictions is not in place anymore on Linux Kernel
4.15.

Since we cannot test this error path anymore on aarch64, the test is
now labeled as x86 specific.

Also updated the test to set the irq_base of the PIC and check that
this value is appropriately updated.

Signed-off-by: Andreea Florescu <fandree@amazon.com>
Retry to create VGICv2 device after failling to create VGICv3, in case
GICv2 is equipped (like RaspBerry Pi 4).
Divide test_create_device() into 2 architecture specific functions,
to avoid too much confusing conditional compiling sentences.

Change-Id: Ie43bf9fe50e5244f3cfcf061328beb267b8788b8
Signed-off-by: Michael Zhao <michael.zhao@arm.com>
1. Added Unit tests for register and unregister irqfd on aarch64.

2. Added the new function create_gic_device which is used for
removing duplicated code when creating GIC devices.

Signed-off-by: Henry Wang <henry.wang@arm.com>
On ARM, KVM_CREATE_IRQCHIP is a bit more complex than on X86.
KVM_CREATE_IRQCHIP only creates VGICv2. It usually succeed with a
GICv2 hardware. But if the hardware is GICv3, it's probable that
GICv2 can't be emulated, so KVM_CREATE_IRQCHIP would fail.

An issue was created for the problem:
rust-vmm/kvm#79

To avoid hardware dependency, in the test we'd better check the
ability of creating VGICv2 in advance, and assert the result of
KVM_CREATE_IRQCHIP correspondingly.

Change-Id: Id17339dde28dbb4abd68bf09fe7f8f0d88c14edb
Signed-off-by: Michael Zhao <michael.zhao@arm.com>
1. Added implementation and documentation of ioctl KVM_IRQ_LINE
   as function set_irq_line for both x86 and Arm architectures.

2. Added unit tests of ioctl KVM_IRQ_LINE for x86, x86_64 and
   aarch64 architectures.

3. Move common code to helper functions `set_supported_nr_irqs`
   and `request_gic_init`.

Signed-off-by: Henry Wang <henry.wang@arm.com>
If we're on an AArch64 host that has been configured to use 64k
pages, then we need to align our addresses to that larger granule.

Signed-off-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Diana Popa <dpopa@amazon.com>
Signed-off-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Diana Popa <dpopa@amazon.com>
The main doc example for running some
machine code in a microVM is adapted to
also support aarch64 architecture.

Signed-off-by: Diana Popa <dpopa@amazon.com>
On ARM, the example code tried to create VGIC v3, it may fail due to
hardware dependency. The error can be seen on machines with GIC v2,
like Raspberry PI 4. Now we retry VGICv2 in that case.

Change-Id: Ie4a5b2b86c234350e444f2f9e94630e4d68af7ab
Signed-off-by: Michael Zhao <michael.zhao@arm.com>
Signed-off-by: Alexandra Iordache <aghecen@amazon.com>
The new container is using Rust 1.39. Fixed the warning of unneeded
unsafe block and updated coverage.

Signed-off-by: Andreea Florescu <fandree@amazon.com>
Right now get_dirty_log() acts on the assumption that the page size is
always 4K. This is not necessarily true, since the page size is
configurable. This commit improves the logic by calling sysconf() to
get the actual page size.

Signed-off-by: Serban Iorga <seriorga@amazon.com>
As kcov supports arm64 now, this commit will enable the arm coverage
test in the CI of kvm-ioctl repository.

This commit contains a workaround to avoid `test_create_device`
failure caused by ioctl returning `EINVAL` instead of `ENOTTY` using
gnu toolchain.

Signed-off-by: Henry Wang <henry.wang@arm.com>
Following modifications are included:
1. Add the wrapper for KVM_HAS_DEVICE_ATTR ioctl.
2. Update the test case of VGIC.
3. Add an example to show the usage of KVM_HAS_DEVICE_ATTR together
with KVM_SET_DEVICE_ATTR.

Change-Id: Idacae319c8ff5ace722e81a279560d823e2458cc
Signed-off-by: Michael Zhao <michael.zhao@arm.com>
Signed-off-by: Qiu Wenbo <qiuwenbo@phytium.com.cn>
For some weird reason (maybe some update on the host??) the coverage
percentage on arm needs to be decreased.

Signed-off-by: Andreea Florescu <fandree@amazon.com>
Host_IPA_Limit is the maximum possible value for
IPA_Bits on the host and is dependent on the CPU capability
and the kernel configuration. The limit can be retrieved using
KVM_CAP_ARM_VM_IPA_SIZE of the KVM_CHECK_EXTENSION ioctl.

This commit adds support for getting Host_IPA_Limit for AArch64.

Signed-off-by: Henry Wang <Henry.Wang@arm.com>
Whe unregistering an ioevent, the `datamatch` field should be set
correctly, otherwise it may unregister undesired ioevent.

Signed-off-by: Jason Cai (Xiang Feng) <xiangfeng.cai@alibaba-inc.com>
Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
The following commits are included in the submodule update:

7e3f307 skip coverage-arm test
cd7096e Enable rust-vmm coverage test in CI
c309d06 buildkite: Move to the rustvmm/dev v4 container
c85a8da buildkite: Remove clippy test on aarch64

Signed-off-by: Andreea Florescu <fandree@amazon.com>
Signed-off-by: niting <niting@google.com>
As `KVM_CREATE_VM` ioctl supports configuration of AArch64 IPA
size of the guest after kernel v4.20, this commit adds support to
flexibly configure AArch64 IPA size of the guest in rust-vmm.

Signed-off-by: Henry Wang <Henry.Wang@arm.com>
The `KVM_GET_DEVICE_ATTR` ioctl is useful when we need to extract
the state/information of devices in the VM. In AArch64 VMs, using
this ioctl is the only method to get the vGIC states.

This commit implements the `KVM_GET_DEVICE_ATTR` ioctl with its
unit test on AArch64.

Fixes: rust-vmm/kvm#99

Signed-off-by: Henry Wang <Henry.Wang@arm.com>
Limit `get_reg_list` doc example to run on ARM64 only, since
`get_reg_list` is for ARM64 and RISC-V64 but 500 registers are too big
for RISC-V (a value between 180~200).

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
Originally `set_device_attr` uses VFIO device for testing, but that's
not available yet on RISC-V 64-bit platform, the QEMU patch [1] and
kernel patch [2] are not upstreamed. Disabling VFIO device test for
RISC-V at the time being.

[1] https://lore.kernel.org/all/20240903201633.93182-1-dbarboza@ventanamicro.com/
[2] https://github.com/ventanamicro/linux/tree/dev-upstream

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
Complete `create_device` doc test to create the creation of AIA device
on RISC-V 64-bit platform.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
RISC-V 64-bit requires an in-kernel interrupt chip (AIA) to be created
in advance of committing `gsi_routing_table`.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
Add assembly code which does dirty one page and forces MMIO exit on
RISC-V 64-bit platform to complete `get_dirty_log` doc test.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
Add example which triggers an MMIO exit after creating a dirty page.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
Add:

- `test_run_code`
- `mpstate_test`
- `test_faulty_vcpu_fd`
- `test_faulty_vcpu_fd_riscv64`
- `test_get_reg_list`
- `test_set_one_reg`
- `test_get_one_reg`

tests.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
Add `test_create_device` to verify that vAIA device works on riscv64.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
Add:

- `test_register_unregister_irqfd`
- `test_set_irq_line`
- `test_singal_msi_failure`
- `test_set_gsi_routing`

tests.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
Compilation would fail with previous code on other architectures don't
have `create_irq_chip` available. Repurpose this unit test to work on
all architectures.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
Add `.platform` to enable CI on riscv64 platform.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
Update `CHANGELOG.md` to document added riscv64 ioctls.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
Update `README.md` since riscv64 is introduced as experimental.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
As @roypat pointed out: The x86 32-bit is not supported in other
rust-vmm crates, dropping the `target_arch = "x86"` predicates to stop
supporting x86 32-bit.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
As @roypat pointed out: KVM on ARM32 hosts were dropped since v5.7 [1],
dropping `target_arch = "arm"` predicates to stop supporting ARM 32-bit
architecture.

[1] https://www.phoronix.com/news/Linux-5.7-Kill-32-bit-ARM-KVM

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
Drop `x86` and `arm` 32-bit architecture support.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
Since `use kvm_bindings::*` is in effect, remove redundant prefixing to
keep the code clean.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
Update kvm-ioctls from v0.18.0 to v0.19.0 to incorporate RISC-V support.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
In preparation for creating a common workspace for kvm-bindings and
kvm-ioctls, move the kvm-ioctls crate to its own directory.

A workspace Cargo.toml is not added yet because it makes git detect it
as a modification and treat kvm-ioctls/Cargo.toml as a new file
instead of a rename.

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
In preparation for creating a common workspace for kvm-bindings and
kvm-ioctls, move the kvm-bindings crate to its own directory.

A workspace Cargo.toml is not added yet because it makes git detect it
as a modification and treat kvm-bindings/Cargo.toml as a new file
instead of a rename.

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
In preparation for merging the kvm-ioctls tree into this workspace.

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
This merge commit merges the two separate git trees into a common one,
while retaining the original history.

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Use `path = ` syntax in Cargo.toml to use the local copy of kvm-bindings
if present.
@epilys epilys marked this pull request as ready for review October 29, 2024 11:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.