MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / vcpu_set_processor_features

Method vcpu_set_processor_features

hypervisor/src/kvm/mod.rs:2623–2665  ·  view source on GitHub ↗
(
        &self,
        vm: &dyn crate::Vm,
        kvi: &mut crate::VcpuInit,
        id: u32,
    )

Source from the content-addressed store, hash-verified

2621
2622 #[cfg(target_arch = "aarch64")]
2623 fn vcpu_set_processor_features(
2624 &self,
2625 vm: &dyn crate::Vm,
2626 kvi: &mut crate::VcpuInit,
2627 id: u32,
2628 ) -> cpu::Result<()> {
2629 use std::arch::is_aarch64_feature_detected;
2630 #[allow(clippy::nonminimal_bool)]
2631 let sve_supported =
2632 is_aarch64_feature_detected!("sve") || is_aarch64_feature_detected!("sve2");
2633
2634 let mut kvm_kvi: kvm_bindings::kvm_vcpu_init = (*kvi).into();
2635
2636 // We already checked that the capability is supported.
2637 kvm_kvi.features[0] |= 1 << kvm_bindings::KVM_ARM_VCPU_PSCI_0_2;
2638 if vm
2639 .as_any()
2640 .downcast_ref::<crate::kvm::KvmVm>()
2641 .unwrap()
2642 .check_extension(Cap::ArmPmuV3)
2643 {
2644 kvm_kvi.features[0] |= 1 << kvm_bindings::KVM_ARM_VCPU_PMU_V3;
2645 }
2646
2647 if sve_supported
2648 && vm
2649 .as_any()
2650 .downcast_ref::<crate::kvm::KvmVm>()
2651 .unwrap()
2652 .check_extension(Cap::ArmSve)
2653 {
2654 kvm_kvi.features[0] |= 1 << kvm_bindings::KVM_ARM_VCPU_SVE;
2655 }
2656
2657 // Non-boot cpus are powered off initially.
2658 if id > 0 {
2659 kvm_kvi.features[0] |= 1 << kvm_bindings::KVM_ARM_VCPU_POWER_OFF;
2660 }
2661
2662 *kvi = kvm_kvi.into();
2663
2664 Ok(())
2665 }
2666
2667 ///
2668 /// Return VcpuInit with default value set

Callers 1

initMethod · 0.45

Calls 2

check_extensionMethod · 0.80
as_anyMethod · 0.45

Tested by

no test coverage detected