Skip to content

Minor QoL improvements for kvm_xsave2 #315

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 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions kvm-bindings/src/x86_64/fam_wrappers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,24 @@ pub type MsrList = FamStructWrapper<kvm_msr_list>;
derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes)
)]
pub struct kvm_xsave2 {
/// The length, in bytes, of the FAM in [`kvm_xsave`].
/// The length, in units of sizeof::<__u32>(), of the FAM in [`kvm_xsave`].
///
/// Note that `KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2)` returns the size of the entire
/// `kvm_xsave` structure, e.g. the sum of header and FAM. Thus, this `len` field
/// is equal to `KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2) - 4096`.
/// is equal to
/// ```norun
/// (KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2) - sizeof::<kvm_xsave>()).div_ceil(sizeof::<__u32>())
/// ```
pub len: usize,
pub xsave: kvm_xsave,
}

impl From<kvm_xsave> for kvm_xsave2 {
fn from(xsave: kvm_xsave) -> Self {
kvm_xsave2 { len: 0, xsave }
}
}

// SAFETY:
// - `kvm_xsave2` is a POD
// - `kvm_xsave2` contains a flexible array member as its final field, due to `kvm_xsave` containing
Expand Down