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

Merge kvm-ioctls git history into this repository #124

Closed
wants to merge 328 commits into from

Conversation

epilys
Copy link
Member

@epilys epilys commented Oct 28, 2024

Superseded by #125

andreeaflorescu and others added 30 commits October 30, 2019 12:39
We decided against adding Cargo.lock to repositories.
Removed the file from the repository and added Cargo.lock to
.gitignore.

Signed-off-by: Andreea Florescu <[email protected]>
Signed-off-by: Adrian Catangiu <[email protected]>
Use safe fam-wrapper over kvm_cpuid2 exported by the
kvm-bindings crate instead of implementing our own.

Coverage decreases by 0.1% because of the removed code.

Signed-off-by: Adrian Catangiu <[email protected]>
Refactor the unsafe code concerning kvm_msr_list and kvm_msrs,
to work with the safe fam-wrappers MsrList and Msrs.

Signed-off-by: Adrian Catangiu <[email protected]>
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 <[email protected]>
Signed-off-by: Adrian Catangiu <[email protected]>
Signed-off-by: Adrian Catangiu <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
Signed-off-by: Andrew Jones <[email protected]>
Signed-off-by: Diana Popa <[email protected]>
Signed-off-by: Andrew Jones <[email protected]>
Signed-off-by: Diana Popa <[email protected]>
The main doc example for running some
machine code in a microVM is adapted to
also support aarch64 architecture.

Signed-off-by: Diana Popa <[email protected]>
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 <[email protected]>
Signed-off-by: Alexandra Iordache <[email protected]>
The new container is using Rust 1.39. Fixed the warning of unneeded
unsafe block and updated coverage.

Signed-off-by: Andreea Florescu <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
For some weird reason (maybe some update on the host??) the coverage
percentage on arm needs to be decreased.

Signed-off-by: Andreea Florescu <[email protected]>
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 <[email protected]>
dependabot bot and others added 24 commits October 7, 2024 14:37
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `007a406` to `cdb4a2d`.
- [Commits](rust-vmm/rust-vmm-ci@007a406...cdb4a2d)

---
updated-dependencies:
- dependency-name: rust-vmm-ci
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
The `riscv64gc` target is to be built on "native" RISC-V platform,
removed `linker` specification used on other platform.

Signed-off-by: Ruoqing He <[email protected]>
Enable g/set ioctls of `kvm_mp_state`, `kvm_one_reg`;
register/unregister of `irq_fd`; `get_reg_list`, `signal_msi`,
`irq_line` and `set_gsi_routing`.

Signed-off-by: Ruoqing He <[email protected]>
Disable `KVM_ENABLE_CAP`, `KVM_GET_REGS` and `KVM_SET_REGS`, and related
ioctls, tests, doc tests on RISC-V 64-bit platform.

Signed-off-by: Ruoqing He <[email protected]>
Implement `create_aia_device`, `set_supported_nr_irqs` and
`request_aia_init` method to manipulate KVM AIA device.

Signed-off-by: Ruoqing He <[email protected]>
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 <[email protected]>
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/[email protected]/
[2] https://github.com/ventanamicro/linux/tree/dev-upstream

Signed-off-by: Ruoqing He <[email protected]>
Complete `create_device` doc test to create the creation of AIA device
on RISC-V 64-bit platform.

Signed-off-by: Ruoqing He <[email protected]>
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 <[email protected]>
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 <[email protected]>
Add example which triggers an MMIO exit after creating a dirty page.

Signed-off-by: Ruoqing He <[email protected]>
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 <[email protected]>
Add `test_create_device` to verify that vAIA device works on riscv64.

Signed-off-by: Ruoqing He <[email protected]>
Add:

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

tests.

Signed-off-by: Ruoqing He <[email protected]>
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 <[email protected]>
Add `.platform` to enable CI on riscv64 platform.

Signed-off-by: Ruoqing He <[email protected]>
Update `CHANGELOG.md` to document added riscv64 ioctls.

Signed-off-by: Ruoqing He <[email protected]>
Update `README.md` since riscv64 is introduced as experimental.

Signed-off-by: Ruoqing He <[email protected]>
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 <[email protected]>
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 <[email protected]>
Drop `x86` and `arm` 32-bit architecture support.

Signed-off-by: Ruoqing He <[email protected]>
Since `use kvm_bindings::*` is in effect, remove redundant prefixing to
keep the code clean.

Signed-off-by: Ruoqing He <[email protected]>
Update kvm-ioctls from v0.18.0 to v0.19.0 to incorporate RISC-V support.

Signed-off-by: Ruoqing He <[email protected]>
$ git remote add kvm-ioctls https://github.com/rust-vmm/kvm-ioctls.git
$ git fetch kvm-ioctls main
$ git merge --allow-unrelated-histories -s ours kvm-ioctls/main

Signed-off-by: Manos Pitsidianakis <[email protected]>
@epilys
Copy link
Member Author

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?

@epilys
Copy link
Member Author

epilys commented Oct 28, 2024

Remade at #125 because Github is a big meanie who doesn't like renaming branches used in forks.

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.