You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since Linux 5.17, the `kvm_xsave` struct has a flexiblre array member
(FAM) at the end, which can be retrieved using the `KVM_GET_XSAVE2`
ioctl [1]. What makes this FAM special is that the length is not stored
in itself, but has to be retrieved via
`KVM_CHECK_CAPABILITY(KVM_CAP_XSAVE2)` which returns the total size of
the `kvm_xsave` struct (e.g. the traditional 4096 byte region + extra
region with the size of the FAM). To support it in rust-vmm, `Xsave` has
been introduced as its `FamStructWrapper`.
The size required to hold the whole `kvm_xsave` structure can vary
depending on features that have been dynamically enabled by
`arch_prctl()` [2]. Any features must not be enabled after the size has
been confirmed; otherwise, `KVM_GET_XSAVE2` writes beyond the allocated
area for `Xsave`, potentially causing undefined behavior. It is unable
to put `KVM_CHECK_CAPABILITY` call for the size check and
`KVM_GET_XSAVE2` call together into `get_xsave2()`, because there is a
chance of race condition where another thread enables additional
features between them. That's why `get_xsave2()` is marked `unsafe`.
Although `KVM_SET_XSAVE` was extended and `KVM_SET_XSAVE2` was not added
to support the `kvm_xsave` with FAM, `set_xsave2()` is also implemented
to enable users to pass `Xsave` to it for convenience. That is also
marked `unsafe` for the same reason.
[1]: https://www.kernel.org/doc/html/latest/virt/kvm/api.html#kvm-get-xsave2
[2]: https://docs.kernel.org/arch/x86/xstate.html
Co-authored-by: Patrick Roy <[email protected]>
Signed-off-by: Takahiro Itazuri <[email protected]>
Copy file name to clipboardExpand all lines: kvm-ioctls/CHANGELOG.md
+7-2Lines changed: 7 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,11 +2,16 @@
2
2
3
3
## Upcoming Release
4
4
5
+
### Added
6
+
7
+
-[[#310](https://github.com/rust-vmm/kvm/pull/310)]: Added support for
8
+
`KVM_CAP_XSAVE2` and the `KVM_GET_XSAVE2` ioctl.
9
+
5
10
## v0.20.0
6
11
7
-
### Added
12
+
### Added
8
13
9
-
-[[#288](https://github.com/rust-vmm/kvm-ioctls/pull/288)]: Introduce `Cap::GuestMemfd`, `Cap::MemoryAttributes` and
14
+
-[[#288](https://github.com/rust-vmm/kvm-ioctls/pull/288)]: Introduce `Cap::GuestMemfd`, `Cap::MemoryAttributes` and
10
15
`Cap::UserMemory2` capabilities enum variants for use with `VmFd::check_extension`.
11
16
-[[#288](https://github.com/rust-vmm/kvm-ioctls/pull/288)]: Introduce `VmFd::check_extension_raw` and `VmFd::check_extension_int` to allow `KVM_CHECK_EXTENSION` to return integer.
0 commit comments