From 805cb303d5d8f07b29fe2a2a9f1a9cb3f5ec66b3 Mon Sep 17 00:00:00 2001 From: Henry Wang Date: Wed, 9 Jun 2021 21:31:49 +0800 Subject: [PATCH] hypervisor: Add `get_host_ipa_limit` for AArch64 This commit adds a helper `get_host_ipa_limit` to the AArch64 `KvmHypervisor` struct. This helper can be used to get the `Host_IPA_Limit`, which is the maximum possible value for IPA_Bits on the host and is dependent on the CPU capability and the kernel configuration. Signed-off-by: Henry Wang --- hypervisor/src/hypervisor.rs | 5 +++++ hypervisor/src/kvm/mod.rs | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/hypervisor/src/hypervisor.rs b/hypervisor/src/hypervisor.rs index e883e1195..6fe5e8e79 100644 --- a/hypervisor/src/hypervisor.rs +++ b/hypervisor/src/hypervisor.rs @@ -100,4 +100,9 @@ pub trait Hypervisor: Send + Sync { /// Retrieve the list of MSRs supported by the hypervisor. /// fn get_msr_list(&self) -> Result; + #[cfg(target_arch = "aarch64")] + /// + /// Retrieve AArch64 host maximum IPA size supported by KVM. + /// + fn get_host_ipa_limit(&self) -> i32; } diff --git a/hypervisor/src/kvm/mod.rs b/hypervisor/src/kvm/mod.rs index 4a781939e..effa63e8c 100644 --- a/hypervisor/src/kvm/mod.rs +++ b/hypervisor/src/kvm/mod.rs @@ -584,6 +584,13 @@ impl hypervisor::Hypervisor for KvmHypervisor { .get_msr_index_list() .map_err(|e| hypervisor::HypervisorError::GetMsrList(e.into())) } + #[cfg(target_arch = "aarch64")] + /// + /// Retrieve AArch64 host maximum IPA size supported by KVM. + /// + fn get_host_ipa_limit(&self) -> i32 { + self.kvm.get_host_ipa_limit() + } } /// Vcpu struct for KVM pub struct KvmVcpu {