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

Commit 9fb0abc

Browse files
committed
Merge 'kvm-ioctls' git history into workspace
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>
2 parents 1938ace + fcf3247 commit 9fb0abc

21 files changed

+9548
-2
lines changed
File renamed without changes.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
**/*.rs.bk
33
Cargo.lock
44
.idea
5+
**/.pytest_cache/
6+
**/__pycache__/*

CODEOWNERS

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
# Add the list of code owners here (using their GitHub username)
2-
* gatekeeper-PullAssigner
1+
# These owners will be the default owners for everything in
2+
# the repo.
3+
* gatekeeper-PullAssigner @acatangiu @aghecenco @andreeaflorescu @lauralt @sameo @roypat @ShadowCurse

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ resolver = "2"
33

44
members = [
55
"kvm-bindings",
6+
"kvm-ioctls",
67
]

kvm-ioctls/CHANGELOG.md

Lines changed: 296 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,296 @@
1+
# Changelog
2+
3+
## Upcoming Release
4+
5+
## v0.19.0
6+
7+
### Added
8+
9+
- [[#275](https://github.com/rust-vmm/kvm-ioctls/pull/275)]: Introduce `riscv64` ioctls.
10+
11+
### Removed
12+
13+
- [[#289](https://github.com/rust-vmm/kvm-ioctls/pull/289)]: Drop `x86` 32-bit
14+
and `arm` 32-bit support.
15+
16+
### Changed
17+
18+
- [[#273](https://github.com/rust-vmm/kvm-ioctls/pull/273)]: `DeviceFd::get_device_attr` is now
19+
marked as unsafe.
20+
- [[#277](https://github.com/rust-vmm/kvm-ioctls/pull/277)]: Updated kvm-bindings to 0.9.1.
21+
22+
## v0.18.0
23+
24+
### Added
25+
26+
- [[#264](https://github.com/rust-vmm/kvm-ioctls/pull/264)]: Added `KVM_SET_USER_MEMORY_REGION2`,
27+
`KVM_CREATE_GUEST_MEMFD` and `KVM_SET_MEMORY_ATTRIBUTES` ioctls.
28+
- [[#267](https://github.com/rust-vmm/kvm-ioctls/pull/267)]: Added `HypercallExit` field to
29+
`VcpuExit::Hypercall` and added `ExitHypercall` to `Cap`.
30+
- [[#270](https://github.com/rust-vmm/kvm-ioctls/pull/270)]: Added `MemoryFaultInfo` to `Cap` and
31+
propagated `MemoryFault` exit reason in `KVM_RUN`.
32+
33+
## v0.17.0
34+
35+
### Changed
36+
37+
- [[#255](https://github.com/rust-vmm/kvm-ioctls/issues/255)]: Fixed a
38+
soundness issue when accessing the `kvm_run` struct. `VcpuFd::run()` and
39+
`VcpuFd::set_kvm_immediate_exit()` now take `&mut self` as a consequence.
40+
- [[#260](https://github.com/rust-vmm/kvm-ioctls/pull/260)]: Updated kvm-bindings to 0.8.0.
41+
42+
## v0.16.0
43+
44+
### Added
45+
- [[#242](https://github.com/rust-vmm/kvm-ioctls/pull/242)] x86: add support
46+
for SMI injection via `Vcpu::smi()` (`KVM_SMI` ioctl).
47+
- [[#241](https://github.com/rust-vmm/kvm-ioctls/pull/241)] Add support for
48+
userspace MSR handling.
49+
- [[#246](https://github.com/rust-vmm/kvm-ioctls/pull/246)] Add support for
50+
userspace NMI injection (`KVM_NMI` ioctl).
51+
- [[#244](https://github.com/rust-vmm/kvm-ioctls/pull/244)] add support for
52+
coalesced MMIO (`KVM_CAP_COALESCED_MMIO` / `KVM_CAP_COALESCED_PIO`)
53+
54+
### Changed
55+
- [[#234](https://github.com/rust-vmm/kvm-ioctls/issues/234)] vcpu: export
56+
reg_size as a public method.
57+
- [[#243](https://github.com/rust-vmm/kvm-ioctls/pull/243)] derived the `Copy`
58+
trait for `IoEventAddress` and `NoDatamatch`.
59+
60+
## v0.15.0
61+
62+
### Added
63+
- [[#230](https://github.com/rust-vmm/kvm-ioctls/pull/230)] Added
64+
`check_extension_raw` method to use raw integer values instead
65+
of `Cap` enum.
66+
- [[#228](https://github.com/rust-vmm/kvm-ioctls/pull/228)] arm64: add
67+
support for vCPU SVE feature.
68+
- [[#219](https://github.com/rust-vmm/kvm-ioctls/pull/226)] Add `Cap::ArmPtrAuthAddress`
69+
and `Cap::ArmPtrAuthGeneric` capabilities.
70+
71+
## v0.14.0
72+
73+
### Added
74+
75+
- [[#219](https://github.com/rust-vmm/kvm-ioctls/pull/219)] Support for
76+
`KVM_GET_MSR_FEATURE_INDEX_LIST` and `KVM_GET_MSRS` system ioctls.
77+
- [[#221](https://github.com/rust-vmm/kvm-ioctls/pull/221)] Add
78+
`Cap::ArmPmuV3`.
79+
80+
### Changed
81+
82+
- [[#223](https://github.com/rust-vmm/kvm-ioctls/pull/223)] aarch64:
83+
Updated `get/set_one_reg` to support different registers sizes through
84+
byte slices.
85+
86+
## v0.13.0
87+
88+
### Added
89+
- [[#213](https://github.com/rust-vmm/kvm-ioctls/pull/213)] Add `Kvm::new_with_path()`
90+
and `Kvm::open_with_cloexec_at()` to allow using kvm device files other than
91+
`/dev/kvm`.
92+
93+
## v0.12.0
94+
95+
### Added
96+
97+
- [[#187](https://github.com/rust-vmm/kvm-ioctls/pull/187)] Support for
98+
`KVM_SET_IDENTITY_MAP_ADDR`
99+
- Derive Debug for all exported structs and enums
100+
- [[#189](https://github.com/rust-vmm/kvm-ioctls/pull/189)] Expose `KVM_SET_` and
101+
`KVM_HAS_DEVICE_ATTR` for vcpu
102+
- [[#191](https://github.com/rust-vmm/kvm-ioctls/pull/191)] Add `KVM_TRANSLATE` support and
103+
the `translate_gva` function that translates guest virtual address to the physical address
104+
- [[#190](https://github.com/rust-vmm/kvm-ioctls/pull/190)] Enable usage of `sync_regs`
105+
to allow bulk getting and setting of general purpose registers, reducing the number of
106+
ioctls needed.
107+
- [[#198](https://github.com/rust-vmm/kvm-ioctls/pull/198)] Return details about
108+
`KVM_EXIT_FAIL_ENTRY` in vCPU run
109+
- [[#199](https://github.com/rust-vmm/kvm-ioctls/pull/199)] Add `register_irqfd_with_resample`
110+
so that `irqfd` + `resaplefd` can be registered through `KVM_IRQFD`
111+
- [[#202](https://github.com/rust-vmm/kvm-ioctls/pull/202)] Add `KVM_CAP_GUEST_DEBUG_HVM_DPS/WPS`
112+
- [[#202](https://github.com/rust-vmm/kvm-ioctls/pull/202)] Added `check_extension_int`
113+
which allows checking the capabilities that return numbers instead of booleans
114+
115+
### Changed
116+
117+
- Updated vmm-sys-util to 0.11.0
118+
- Updated kvm-bindings to 0.6.0
119+
- Upgraded to rust 2021 edition
120+
- Switched to specifying dependencies using caret requirements
121+
instead of comparision requirements
122+
- [[#195](https://github.com/rust-vmm/kvm-ioctls/pull/195)] Do not panic on unsupported
123+
`KVM_EXIT` reason
124+
- [[#196](https://github.com/rust-vmm/kvm-ioctls/pull/196)] Expose a mutable reference
125+
to the `kvm_run` structure to allow proper handling of unsupported exit reasons
126+
- [[#200](https://github.com/rust-vmm/kvm-ioctls/pull/200)] Fix wrong `target_arch` gate
127+
preventing `set_guest_debug` from being exported on ARM
128+
- [[#206](https://github.com/rust-vmm/kvm-ioctls/pull/206)] use `u128` in `get/set_on_reg`
129+
130+
## v0.11.0
131+
132+
### Added
133+
- [[#178](https://github.com/rust-vmm/kvm-ioctls/pull/178)] Support for the AMD
134+
Security Encrypted Virtualization (SEV) through the following VM ioctls:
135+
`encrypt_op`, `encrypt_op_sev`, `register_enc_memory_region` and
136+
`unregister_enc_memory_region`.
137+
- [[#184](https://github.com/rust-vmm/kvm-ioctls/pull/184)] `DeviceFd` now
138+
derives `Debug`.
139+
140+
## v0.10.0
141+
142+
### Changed
143+
- Now depends on kvm-bindings >=0.5.0 which replaced the v4.20 KVM bindings
144+
with the v5.13 ones.
145+
- Updated `VcpuExit::Debug` to return architecture specific information for the
146+
debug event.
147+
148+
## v0.9.0
149+
150+
### Added
151+
- Support for accessing and controlling the Time Stamp Counter on x86 platforms
152+
through the `get_tsc_khz` and `set_tsc_khz` functions.
153+
154+
### Changed
155+
- Updated `create_vm` on `aarch64` to create a VM fd from the KVM fd using the
156+
host's maximum IPA size.
157+
158+
## v0.8.0
159+
160+
### Added
161+
- Support for specifying VM type (an opaque platform and architecture specific
162+
constant) when creating a VM (`KVM_CREATE_VM` ioctl) via the
163+
`Kvm::create_vm_with_type` function.
164+
165+
### Changed
166+
- Now depends on kvm-bindings >=0.4.0 to support use of a newer vmm-sys-utils
167+
dependency.
168+
169+
## v0.7.0
170+
171+
### Added
172+
- Support for the system API that returns the maximum allowed vCPU ID
173+
(`KVM_CAP_MAX_VCPU_ID`).
174+
- Support for `KVM_MEMORY_ENCRYPT_OP`.
175+
176+
### Fixed
177+
- [[#119](https://github.com/rust-vmm/kvm-ioctls/issues/119)]: Disallow invalid
178+
number of cpuid entries to be passed to `get_supported_cpuid` and
179+
`get_emulated_cpuid`.
180+
181+
### Changed
182+
- [[#123](https://github.com/rust-vmm/kvm-ioctls/issues/123)]: Updated
183+
`create_vcpu` to use `u64` as the parameter for the number of vCPUs.
184+
185+
## v0.6.0
186+
187+
### Added
188+
- Support for the vcpu ioctls: `KVM_SET_GUEST_DEBUG`, `KVM_KVMCLOCK_CTRL`, and
189+
`KVM_GET_REG_LIST`.
190+
- Support for the vm ioctl `KVM_GET_DEVICE_ATTR`.
191+
- Support for the device ioctl `KVM_HAS_DEVICE_ATTR`.
192+
- Support for `VcpuExit::Debug`.
193+
- Support for enabling vcpu capabilities using `Vcpu::enable_cap`.
194+
- Support for checking Hyper-V (`HypervSynic` and `HypervSynic2`), MSI
195+
(`MsiDevid`), and IPA Size (`ArmVmIPASize`) capabilities.
196+
using `kvm.check_extension`.
197+
- Support for checking the VM capabilities via `Vm::check_extension`.
198+
- Create a VM with flexible IPA size using `Kvm::create_vm_with_ipa_size`.
199+
200+
### Removed
201+
- Removed `Kvm::new_with_fd_number`. The same functionality is offered by the
202+
`Kvm` [FromRawFd](https://doc.rust-lang.org/std/os/unix/io/trait.FromRawFd.html)
203+
trait implementation.
204+
205+
### Changed
206+
- The VM ioctl `unregister_ioevent` now correctly unregisters the events that
207+
correspond to the data match passed as a parameter.
208+
- The `SystemEvent` Vcpu Exit now also contains the relevant type and flags.
209+
- Updated `get_dirty_log` such that it does not assume the page size is 4K,
210+
but instead reads it using `libc::sysconf`.
211+
212+
## v0.5.0
213+
214+
### Added
215+
- Support for the vcpu ioctls `KVM_GET/SET_VCPU_EVENTS` and `KVM_GET_DIRTY_LOG`
216+
on `aarch64`.
217+
- Support for the vcpu ioctl `KVM_IRQ_LINE`.
218+
219+
## v0.4.0
220+
221+
### Added
222+
- Support for unregistering ioeventfds through `KVM_IOEVENTFD`.
223+
224+
### Changed
225+
- Functions working with event FDs now require
226+
vmm_sys_util::eventfd::EventFd in their interface instead of
227+
RawFd.
228+
- Functions working with FAM structs kvm_msr_list and kvm_msrs, were
229+
changed to work with their respective safe counterparts MsrList and
230+
respectively Msrs.
231+
- Now exporting kvm_ioctls::Error type definition so that users of this
232+
crate can create their own wrapping errors without having to know the
233+
Error type used internally by this crate.
234+
- No longer exporting kvm_ioctls::Result. Users of this crate should
235+
not have to use kvm_ioctls::Result outside the crate.
236+
- kvm_ioctls::Error now works with errno::Error instead of io::Error.
237+
238+
### Removed
239+
- CpuId safe wrapper over FAM struct kvm_cpuid2. The safe wrapper is
240+
now provided by the kvm_bindings crate starting with v0.2.0.
241+
- KVM_MAX_MSR_ENTRIES and MAX_KVM_CPUID_ENTRIES. Equivalent constants
242+
are provided by the kvm_bindings crate starting with v0.2.0.
243+
244+
## v0.3.0
245+
246+
### Added
247+
- Support for setting vcpu `kvm_immediate_exit` flag
248+
- Support for the vcpu ioctl `KVM_GET_CPUID2`
249+
- Support for the vcpu ioctl `KVM_GET_MP_STATE`
250+
- Support for the vcpu ioctl `KVM_SET_MP_STATE`
251+
- Support for the vcpu ioctl `KVM_GET_VCPU_EVENTS`
252+
- Support for the vcpu ioctl `KVM_SET_VCPU_EVENTS`
253+
- Support for the vcpu ioctl `KVM_GET_DEBUGREGS`
254+
- Support for the vcpu ioctl `KVM_SET_DEBUGREGS`
255+
- Support for the vcpu ioctl `KVM_GET_XSAVE`
256+
- Support for the vcpu ioctl `KVM_SET_XSAVE`
257+
- Support for the vcpu ioctl `KVM_GET_XCRS`
258+
- Support for the vcpu ioctl `KVM_SET_XCRS`
259+
- Support for the vm ioctl `KVM_GET_IRQCHIP`
260+
- Support for the vm ioctl `KVM_SET_IRQCHIP`
261+
- Support for the vm ioctl `KVM_GET_CLOCK`
262+
- Support for the vm ioctl `KVM_SET_CLOCK`
263+
- Support for the vm ioctl `KVM_GET_PIT2`
264+
- Support for the vm ioctl `KVM_SET_PIT2`
265+
- Support for the vcpu ioctl `KVM_GET_ONE_REG`
266+
267+
### Changed
268+
- Function offering support for `KVM_SET_MSRS` also returns the number
269+
of MSR entries successfully written.
270+
271+
## v0.2.0
272+
273+
### Added
274+
- Add support for `KVM_ENABLE_CAP`.
275+
- Add support for `KVM_SIGNAL_MSI`.
276+
277+
### Fixed
278+
- Fix bug in KvmRunWrapper. The memory for kvm_run struct was not unmapped
279+
after the KvmRunWrapper object got out of scope.
280+
- Return proper value when receiving the EOI KVM exit.
281+
- Mark set_user_memory_region as unsafe.
282+
283+
## v0.1.0
284+
285+
First release of the kvm-ioctls crate.
286+
287+
The kvm-ioctls crate provides safe wrappers over the KVM API, a set of ioctls
288+
used for creating and configuring Virtual Machines (VMs) on Linux.
289+
The ioctls are accessible through four structures:
290+
- Kvm - wrappers over system ioctls
291+
- VmFd - wrappers over VM ioctls
292+
- VcpuFd - wrappers over vCPU ioctls
293+
- DeviceFd - wrappers over device ioctls
294+
295+
The kvm-ioctls can be used on x86_64 and aarch64. Right now the aarch64
296+
support is considered experimental.

kvm-ioctls/Cargo.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[package]
2+
name = "kvm-ioctls"
3+
version = "0.19.0"
4+
authors = ["Amazon Firecracker Team <firecracker-maintainers@amazon.com>"]
5+
description = "Safe wrappers over KVM ioctls"
6+
repository = "https://github.com/rust-vmm/kvm-ioctls"
7+
readme = "README.md"
8+
keywords = ["kvm"]
9+
license = "Apache-2.0 OR MIT"
10+
edition = "2021"
11+
12+
[dependencies]
13+
libc = "0.2.39"
14+
kvm-bindings = { version = "0.10.0", features = ["fam-wrappers"] }
15+
vmm-sys-util = "0.12.1"
16+
bitflags = "2.4.1"
17+
18+
[dev-dependencies]
19+
byteorder = "1.2.1"

0 commit comments

Comments
 (0)