From 9f111388c0ef96fc3a16a9490a12056533d4e583 Mon Sep 17 00:00:00 2001 From: Akira Moroo Date: Sun, 30 Jan 2022 19:26:32 +0900 Subject: [PATCH] hypervisor: Add `VmExit::Debug` for x86/KVM This commit adds `VmExit::Debug` for x86/KVM. When the guest hits a hardware breakpoint, `VcpuExit::Debug` vm exit occurs. This vm exit will be handled with code implemented in the following commits. Signed-off-by: Akira Moroo --- hypervisor/src/cpu.rs | 2 ++ hypervisor/src/kvm/mod.rs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/hypervisor/src/cpu.rs b/hypervisor/src/cpu.rs index 8b57269a2..96b8cfabf 100644 --- a/hypervisor/src/cpu.rs +++ b/hypervisor/src/cpu.rs @@ -266,6 +266,8 @@ pub enum VmExit<'a> { Hyperv, #[cfg(feature = "tdx")] Tdx, + #[cfg(feature = "kvm")] + Debug, } /// diff --git a/hypervisor/src/kvm/mod.rs b/hypervisor/src/kvm/mod.rs index d272c7657..14a39ba8c 100644 --- a/hypervisor/src/kvm/mod.rs +++ b/hypervisor/src/kvm/mod.rs @@ -1074,6 +1074,8 @@ impl cpu::Vcpu for KvmVcpu { VcpuExit::Hyperv => Ok(cpu::VmExit::Hyperv), #[cfg(feature = "tdx")] VcpuExit::Unsupported(KVM_EXIT_TDX) => Ok(cpu::VmExit::Tdx), + VcpuExit::Debug(_) => Ok(cpu::VmExit::Debug), + r => Err(cpu::HypervisorCpuError::RunVcpu(anyhow!( "Unexpected exit reason on vcpu run: {:?}", r