diff --git a/kvm-bindings/src/x86_64/fam_wrappers.rs b/kvm-bindings/src/x86_64/fam_wrappers.rs index adf20402..827822f7 100644 --- a/kvm-bindings/src/x86_64/fam_wrappers.rs +++ b/kvm-bindings/src/x86_64/fam_wrappers.rs @@ -104,15 +104,24 @@ pub type MsrList = FamStructWrapper; 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::()).div_ceil(sizeof::<__u32>()) + /// ``` pub len: usize, pub xsave: kvm_xsave, } +impl From 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