From 223b1f6c51d16cad9af19f707b682c36c31423a0 Mon Sep 17 00:00:00 2001 From: Michael Zhao Date: Tue, 23 Aug 2022 11:21:56 +0800 Subject: [PATCH] hypervisor: Introduce `get_guest_debug_hw_bps()` Added `Hypervisor::get_guest_debug_hw_bps()` for fetching the number of supported hardware breakpoints. Signed-off-by: Michael Zhao --- Cargo.lock | 2 +- hypervisor/src/hypervisor.rs | 8 +++++++- hypervisor/src/kvm/mod.rs | 14 ++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c359945d1..1b283abbe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -472,7 +472,7 @@ dependencies = [ [[package]] name = "kvm-ioctls" version = "0.11.0" -source = "git+https://github.com/rust-vmm/kvm-ioctls?branch=main#63f2f1231d49478197e15b8e9ff5d4e827aa288f" +source = "git+https://github.com/rust-vmm/kvm-ioctls?branch=main#6705a619970fb0b2be47f1781f2ccf856cd5ce6a" dependencies = [ "kvm-bindings", "libc", diff --git a/hypervisor/src/hypervisor.rs b/hypervisor/src/hypervisor.rs index 63621e45f..3252d125b 100644 --- a/hypervisor/src/hypervisor.rs +++ b/hypervisor/src/hypervisor.rs @@ -117,7 +117,7 @@ pub trait Hypervisor: Send + Sync { } #[cfg(target_arch = "aarch64")] /// - /// Retrieve AArch64 host maximum IPA size supported by KVM. + /// Retrieve AArch64 host maximum IPA size supported by KVM /// fn get_host_ipa_limit(&self) -> i32; /// @@ -125,4 +125,10 @@ pub trait Hypervisor: Send + Sync { /// #[cfg(feature = "tdx")] fn tdx_capabilities(&self) -> Result; + /// + /// Get the number of supported hardware breakpoints + /// + fn get_guest_debug_hw_bps(&self) -> usize { + unimplemented!() + } } diff --git a/hypervisor/src/kvm/mod.rs b/hypervisor/src/kvm/mod.rs index 23d76d866..e2584fccb 100644 --- a/hypervisor/src/kvm/mod.rs +++ b/hypervisor/src/kvm/mod.rs @@ -1076,6 +1076,20 @@ impl hypervisor::Hypervisor for KvmHypervisor { Ok(data) } + + /// + /// Get the number of supported hardware breakpoints + /// + fn get_guest_debug_hw_bps(&self) -> usize { + #[cfg(target_arch = "x86_64")] + { + 4 + } + #[cfg(target_arch = "aarch64")] + { + self.kvm.get_guest_debug_hw_bps() as usize + } + } } /// Vcpu struct for KVM pub struct KvmVcpu {