On the x86 platform, the int 3 instruction causes a breakpoint trap. For KVM, the Virtual CPUs can be configured to exit to the hypervisor on this trap, by enabling the flags KVM_GUESTDBG_ENABLE and KVM_GUESTDBG_USE_SW_BP (see KVM documentation). When the VM exits, I would like to step over the instruction and continue execution, without the guest VM being notified of the breakpoint trap.
I have tried the following:
- Enable
KVM_GUESTDBG_USE_SW_BPandKVM_GUESTDBG_ENABLE, wait for the breakpoint trap exit to occur - Disable
KVM_GUESTDBG_USE_SW_BPand enableKVM_GUESTDBG_SINGLESTEP - Resume the vCPU to step over the
int 3instruction and generate another VM exit - enable
KVM_GUESTDBG_USE_SW_BPand disableKVM_GUESTDBG_SINGLESTEPto continue normal execution
This approach however fails to isolate the debug breakpoint trap from the guest VM, and the guest OS will receive the exception. Enabling KVM_GUESTDBG_BLOCKIRQ does not prevent this either.
Upon the first generated VM exit, how does one correctly step over a software-induced breakpoint trap, without leaking the breakpoint trap to the guest VM?