mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-21 20:15:21 +00:00
arch: aarch64: Remove hardcoded host IPA size
With the ability of getting host IPA size in `hypervisor` crate, we can query the host IPA size through ioctl instead of hardcoding a maximum IPA size. Therefore this commit removes the hardcoded maximum host IPA size. Signed-off-by: Henry Wang <Henry.Wang@arm.com>
This commit is contained in:
parent
2fe3586eba
commit
1eb8a4671f
@ -19,6 +19,7 @@ use crate::GuestMemoryMmap;
|
|||||||
use crate::RegionType;
|
use crate::RegionType;
|
||||||
use gic::GicDevice;
|
use gic::GicDevice;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use std::convert::TryInto;
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
@ -195,22 +196,17 @@ fn get_fdt_addr() -> u64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_host_cpu_phys_bits() -> u8 {
|
pub fn get_host_cpu_phys_bits() -> u8 {
|
||||||
// The value returned here is used to determine the physical address space size
|
// A dummy hypervisor created only for querying the host IPA size and will
|
||||||
// for a VM (IPA size).
|
// be freed after the query.
|
||||||
// In recent kernel versions, the maximum IPA size supported by the host can be
|
let hv = hypervisor::new().unwrap();
|
||||||
// known by querying cap KVM_CAP_ARM_VM_IPA_SIZE. And the IPA size for a
|
let host_cpu_phys_bits = hv.get_host_ipa_limit().try_into().unwrap();
|
||||||
// guest can be configured smaller.
|
if host_cpu_phys_bits == 0 {
|
||||||
// But in Cloud-Hypervisor we simply use the maximum value for the VM.
|
// Host kernel does not support `get_host_ipa_limit`,
|
||||||
// Reference https://lwn.net/Articles/766767/.
|
// we return the default value 40 here.
|
||||||
//
|
40
|
||||||
// The correct way to query KVM_CAP_ARM_VM_IPA_SIZE is via rust-vmm/kvm-ioctls,
|
} else {
|
||||||
// which wraps all IOCTL's and provides easy interface to user hypervisors.
|
host_cpu_phys_bits
|
||||||
// For now the cap hasn't been supported. A separate patch will be submitted to
|
}
|
||||||
// rust-vmm to add it.
|
|
||||||
// So a hardcoded value is used here as a temporary solution.
|
|
||||||
// It will be replace once rust-vmm/kvm-ioctls is ready.
|
|
||||||
//
|
|
||||||
40
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user