X86 specific call that returns the vcpu's current "xsave struct" using the extended xsave2 interface which supports larger state buffers (>4KB) for features like Intel AMX. This method requires KVM_CAP_XSAVE2 capability and uses KVM_GET_XSAVE2 ioctl. The xsave parameter must be allocated with sufficient size based on the value returned by KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2).
(&self)
| 3493 | /// The xsave parameter must be allocated with sufficient size based on the value |
| 3494 | /// returned by KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2). |
| 3495 | pub fn get_xsave2(&self) -> cpu::Result<XsaveState> { |
| 3496 | assert!( |
| 3497 | self.xsave_size > 0, |
| 3498 | "'xsave_size' must be initialized via 'KVM_CAP_XSAVE2' first" |
| 3499 | ); |
| 3500 | let fam_size = (self.xsave_size as usize - size_of::<kvm_bindings::kvm_xsave>()) |
| 3501 | .div_ceil(size_of::<<kvm_xsave2 as FamStruct>::Entry>()); |
| 3502 | let mut xsave = |
| 3503 | xsave2::new(fam_size).map_err(|e| cpu::HypervisorCpuError::GetXsaveState(e.into()))?; |
| 3504 | // SAFETY: The caller guarantees that xsave is allocated with enough space |
| 3505 | unsafe { |
| 3506 | self.fd |
| 3507 | .get_xsave2(&mut xsave) |
| 3508 | .map_err(|e| cpu::HypervisorCpuError::GetXsaveState(e.into()))?; |
| 3509 | } |
| 3510 | Ok((&xsave).into()) |
| 3511 | } |
| 3512 | |
| 3513 | #[cfg(target_arch = "x86_64")] |
| 3514 | /// X86 specific call that sets the vcpu's current "xsave struct" using the extended |