vmm: Add support for enabling SVE in vm guests

This change enables SVE automatically if the host support SVE/SVE2.

Signed-off-by: Wenyu Huang <huangwenyuu@outlook.com>
This commit is contained in:
Wenyu Huang
2024-08-23 07:12:17 -04:00
committed by Rob Bradford
parent 2049b2c377
commit d2a364c5c0
4 changed files with 45 additions and 2 deletions

View File

@@ -158,6 +158,11 @@ pub enum HypervisorCpuError {
#[error("Failed to init vcpu: {0}")]
VcpuInit(#[source] anyhow::Error),
///
/// Vcpu Finalize error
///
#[error("Failed to finalize vcpu: {0}")]
VcpuFinalize(#[source] anyhow::Error),
///
/// Setting one reg error
///
#[error("Failed to init vcpu: {0}")]
@@ -416,6 +421,10 @@ pub trait Vcpu: Send + Sync {
///
#[cfg(target_arch = "aarch64")]
fn vcpu_init(&self, kvi: &VcpuInit) -> Result<()>;
#[cfg(target_arch = "aarch64")]
fn vcpu_finalize(&self, feature: i32) -> Result<()>;
///
/// Gets a list of the guest registers that are supported for the
/// KVM_GET_ONE_REG/KVM_SET_ONE_REG calls.

View File

@@ -1881,6 +1881,15 @@ impl cpu::Vcpu for KvmVcpu {
.map_err(|e| cpu::HypervisorCpuError::VcpuInit(e.into()))
}
#[cfg(target_arch = "aarch64")]
fn vcpu_finalize(&self, feature: i32) -> cpu::Result<()> {
self.fd
.lock()
.unwrap()
.vcpu_finalize(&feature)
.map_err(|e| cpu::HypervisorCpuError::VcpuFinalize(e.into()))
}
///
/// Gets a list of the guest registers that are supported for the
/// KVM_GET_ONE_REG/KVM_SET_ONE_REG calls.