Skip to content
Merged
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::IntoBytes, zerocopy::Immutable, zerocopy::FromBytes)
)]
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