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:
Michael Zhao
2022-08-23 12:00:37 +08:00
committed by Sebastien Boeuf
parent 223b1f6c51
commit d66d64c325
3 changed files with 19 additions and 12 deletions

View File

@@ -1605,13 +1605,6 @@ impl cpu::Vcpu for KvmVcpu {
addrs: &[vm_memory::GuestAddress],
singlestep: bool,
) -> cpu::Result<()> {
if addrs.len() > 4 {
return Err(cpu::HypervisorCpuError::SetDebugRegs(anyhow!(
"Support 4 breakpoints at most but {} addresses are passed",
addrs.len()
)));
}
let mut dbg = kvm_guest_debug {
#[cfg(target_arch = "x86_64")]
control: KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_USE_HW_BP,
@@ -1623,6 +1616,9 @@ impl cpu::Vcpu for KvmVcpu {
dbg.control |= KVM_GUESTDBG_SINGLESTEP;
}
// Set the debug registers.
// Here we assume that the number of addresses do not exceed what
// `Hypervisor::get_guest_debug_hw_bps()` specifies.
#[cfg(target_arch = "x86_64")]
{
// Set bits 9 and 10.