mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-11 23:27:40 +00:00
vmm: only use KVM_ARM_VCPU_PMU_V3 if available
Having PMU in guests isn't critical, and not all hardware supports it (e.g. Apple Silicon). CpuManager::init_pmu already has a fallback for if PMU is not supported by the VCPU, but we weren't getting that far, because we would always try to initialise the VCPU with KVM_ARM_VCPU_PMU_V3, and then bail when it returned with EINVAL. Signed-off-by: Alyssa Ross <hi@alyssa.is>
This commit is contained in:
parent
27f5016ad3
commit
1fc969d37a
3
Cargo.lock
generated
3
Cargo.lock
generated
@ -491,8 +491,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "kvm-ioctls"
|
name = "kvm-ioctls"
|
||||||
version = "0.13.0"
|
version = "0.13.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/rust-vmm/kvm-ioctls?branch=main#23a3bb045a467e60bb00328a0b13cea13b5815d0"
|
||||||
checksum = "b8f8dc9c1896e5f144ec5d07169bc29f39a047686d29585a91f30489abfaeb6b"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"kvm-bindings",
|
"kvm-bindings",
|
||||||
"libc",
|
"libc",
|
||||||
|
@ -44,6 +44,7 @@ clap = { version = "4.0.29", features = ["cargo"] }
|
|||||||
# List of patched crates
|
# List of patched crates
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
kvm-bindings = { git = "https://github.com/cloud-hypervisor/kvm-bindings", branch = "ch-v0.6.0-tdx" }
|
kvm-bindings = { git = "https://github.com/cloud-hypervisor/kvm-bindings", branch = "ch-v0.6.0-tdx" }
|
||||||
|
kvm-ioctls = { git = "https://github.com/rust-vmm/kvm-ioctls", branch = "main" }
|
||||||
versionize_derive = { git = "https://github.com/cloud-hypervisor/versionize_derive", branch = "ch" }
|
versionize_derive = { git = "https://github.com/cloud-hypervisor/versionize_derive", branch = "ch" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
@ -330,7 +330,7 @@ impl KvmVm {
|
|||||||
Ok(VfioDeviceFd::new_from_kvm(device_fd))
|
Ok(VfioDeviceFd::new_from_kvm(device_fd))
|
||||||
}
|
}
|
||||||
/// Checks if a particular `Cap` is available.
|
/// Checks if a particular `Cap` is available.
|
||||||
fn check_extension(&self, c: Cap) -> bool {
|
pub fn check_extension(&self, c: Cap) -> bool {
|
||||||
self.fd.check_extension(c)
|
self.fd.check_extension(c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,8 @@ use hypervisor::arch::x86::MsrEntry;
|
|||||||
use hypervisor::arch::x86::{SpecialRegisters, StandardRegisters};
|
use hypervisor::arch::x86::{SpecialRegisters, StandardRegisters};
|
||||||
#[cfg(target_arch = "aarch64")]
|
#[cfg(target_arch = "aarch64")]
|
||||||
use hypervisor::kvm::kvm_bindings;
|
use hypervisor::kvm::kvm_bindings;
|
||||||
|
#[cfg(all(target_arch = "aarch64", feature = "kvm"))]
|
||||||
|
use hypervisor::kvm::kvm_ioctls::Cap;
|
||||||
#[cfg(feature = "tdx")]
|
#[cfg(feature = "tdx")]
|
||||||
use hypervisor::kvm::{TdxExitDetails, TdxExitStatus};
|
use hypervisor::kvm::{TdxExitDetails, TdxExitStatus};
|
||||||
use hypervisor::{CpuState, HypervisorCpuError, HypervisorType, VmExit, VmOps};
|
use hypervisor::{CpuState, HypervisorCpuError, HypervisorType, VmExit, VmOps};
|
||||||
@ -378,7 +380,14 @@ impl Vcpu {
|
|||||||
.map_err(Error::VcpuArmPreferredTarget)?;
|
.map_err(Error::VcpuArmPreferredTarget)?;
|
||||||
// We already checked that the capability is supported.
|
// We already checked that the capability is supported.
|
||||||
kvi.features[0] |= 1 << kvm_bindings::KVM_ARM_VCPU_PSCI_0_2;
|
kvi.features[0] |= 1 << kvm_bindings::KVM_ARM_VCPU_PSCI_0_2;
|
||||||
kvi.features[0] |= 1 << kvm_bindings::KVM_ARM_VCPU_PMU_V3;
|
if vm
|
||||||
|
.as_any()
|
||||||
|
.downcast_ref::<hypervisor::kvm::KvmVm>()
|
||||||
|
.unwrap()
|
||||||
|
.check_extension(Cap::ArmPmuV3)
|
||||||
|
{
|
||||||
|
kvi.features[0] |= 1 << kvm_bindings::KVM_ARM_VCPU_PMU_V3;
|
||||||
|
}
|
||||||
// Non-boot cpus are powered off initially.
|
// Non-boot cpus are powered off initially.
|
||||||
if self.id > 0 {
|
if self.id > 0 {
|
||||||
kvi.features[0] |= 1 << kvm_bindings::KVM_ARM_VCPU_POWER_OFF;
|
kvi.features[0] |= 1 << kvm_bindings::KVM_ARM_VCPU_POWER_OFF;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user