(&self, vm: &dyn hypervisor::Vm)
| 607 | /// Initializes an aarch64 specific vcpu for booting Linux. |
| 608 | #[cfg(target_arch = "aarch64")] |
| 609 | pub fn init(&self, vm: &dyn hypervisor::Vm) -> Result<()> { |
| 610 | use std::arch::is_aarch64_feature_detected; |
| 611 | #[allow(clippy::nonminimal_bool)] |
| 612 | let sve_supported = |
| 613 | is_aarch64_feature_detected!("sve") || is_aarch64_feature_detected!("sve2"); |
| 614 | let mut kvi = self.vcpu.create_vcpu_init(); |
| 615 | |
| 616 | // This reads back the kernel's preferred target type. |
| 617 | vm.get_preferred_target(&mut kvi) |
| 618 | .map_err(Error::VcpuArmPreferredTarget)?; |
| 619 | |
| 620 | self.vcpu |
| 621 | .vcpu_set_processor_features(vm, &mut kvi, self.id) |
| 622 | .map_err(Error::VcpuSetProcessorFeatures)?; |
| 623 | |
| 624 | self.vcpu.vcpu_init(&kvi).map_err(Error::VcpuArmInit)?; |
| 625 | |
| 626 | if sve_supported { |
| 627 | let finalized_features = self.vcpu.vcpu_get_finalized_features(); |
| 628 | self.vcpu |
| 629 | .vcpu_finalize(finalized_features) |
| 630 | .map_err(Error::VcpuArmFinalize)?; |
| 631 | } |
| 632 | Ok(()) |
| 633 | } |
| 634 | |
| 635 | /// Runs the VCPU until it exits, returning the reason. |
| 636 | /// |
no test coverage detected