Skip to content

Commit c75a562

Browse files
committed
fix(doc): correct the comment on kvm_xsave2.len
The length of the FAM is not in bytes, but rather in terms of how many __u32 elements are contained in the flexible array member. So clarify the note that the return value of KVM_CHECK_EXTENSION not only needs to subtract sizeof::<kvm_xsave>(), it also needs to divide by 4. Signed-off-by: Patrick Roy <[email protected]>
1 parent 30d4dfd commit c75a562

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

kvm-bindings/src/x86_64/fam_wrappers.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,14 @@ pub type MsrList = FamStructWrapper<kvm_msr_list>;
104104
derive(zerocopy::IntoBytes, zerocopy::Immutable, zerocopy::FromBytes)
105105
)]
106106
pub struct kvm_xsave2 {
107-
/// The length, in bytes, of the FAM in [`kvm_xsave`].
107+
/// The length, in units of sizeof::<__u32>(), of the FAM in [`kvm_xsave`].
108108
///
109109
/// Note that `KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2)` returns the size of the entire
110110
/// `kvm_xsave` structure, e.g. the sum of header and FAM. Thus, this `len` field
111-
/// is equal to `KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2) - 4096`.
111+
/// is equal to
112+
/// ```norun
113+
/// (KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2) - sizeof::<kvm_xsave>()).div_ceil(sizeof::<__u32>())
114+
/// ```
112115
pub len: usize,
113116
pub xsave: kvm_xsave,
114117
}

0 commit comments

Comments
 (0)