mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: Restrict the maximum number of HW breakpoints
Set the maximum number of HW breakpoints according to the value returned from `Hypervisor::get_guest_debug_hw_bps()`. Signed-off-by: Michael Zhao <michael.zhao@arm.com>
This commit is contained in:
committed by
Sebastien Boeuf
parent
223b1f6c51
commit
d66d64c325
+8
-4
@@ -133,12 +133,13 @@ impl GdbStub {
|
||||
gdb_sender: mpsc::Sender<GdbRequest>,
|
||||
gdb_event: vmm_sys_util::eventfd::EventFd,
|
||||
vm_event: vmm_sys_util::eventfd::EventFd,
|
||||
hw_breakpoints: usize,
|
||||
) -> Self {
|
||||
Self {
|
||||
gdb_sender,
|
||||
gdb_event,
|
||||
vm_event,
|
||||
hw_breakpoints: Default::default(),
|
||||
hw_breakpoints: Vec::with_capacity(hw_breakpoints),
|
||||
single_step: false,
|
||||
}
|
||||
}
|
||||
@@ -383,9 +384,12 @@ impl HwBreakpoint for GdbStub {
|
||||
addr: <Self::Arch as Arch>::Usize,
|
||||
_kind: <Self::Arch as Arch>::BreakpointKind,
|
||||
) -> TargetResult<bool, Self> {
|
||||
// If we already have 4 breakpoints, we cannot set a new one.
|
||||
if self.hw_breakpoints.len() >= 4 {
|
||||
error!("Not allowed to set more than 4 HW breakpoints");
|
||||
// If the HW breakpoints reach the limit, no more can be added.
|
||||
if self.hw_breakpoints.len() >= self.hw_breakpoints.capacity() {
|
||||
error!(
|
||||
"Not allowed to set more than {} HW breakpoints",
|
||||
self.hw_breakpoints.capacity()
|
||||
);
|
||||
return Ok(false);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user