qemu-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: QEMU-KVM Hardware Breakpoint Handling


From: Alex Bennée
Subject: Re: QEMU-KVM Hardware Breakpoint Handling
Date: Fri, 01 Jul 2022 11:55:48 +0100
User-agent: mu4e 1.7.27; emacs 28.1.90

Arnabjyoti Kalita <akalita@cs.stonybrook.edu> writes:

> Hello all,
>
> I am using QEMU in KVM mode and I have set a hardware breakpoint at a
> particular instruction with the help of the ioctl -
> KVM_SET_GUEST_DEBUG.
>
> I set it like this -
>
> struct kvm_guest_debug debug = {
>      .control = KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_USE_HW_BP,
> };
> debug.arch.debugger[0] = addr;   /* addr of instruction where
> breakpoint is set */
> debug.arch.debugger[7] = 0x2;
>
> ret = kvm_vcpu_ioctl(cpu, KVM_SET_GUEST_DEBUG, &debug);
>
> When the hardware breakpoint instruction is accessed, the QEMU VM goes
> to a paused state. This tells me that the breakpoint was set
> correctly. Now, I do not want gdb to be invoked and I would like to
> "handle" this breakpoint myself.

You need to look at the kvm_arch_handle_exit path although it will get
complicated because if you don't update the guest debug state you will
trap again as soon as you return to execute the instruction.

> I would like to record when the breakpoint was "hit" as well as the
> cpu id of the CPU that hit the breakpoint and then let the CPU resume
> its normal execution. How would I be able to implement this? Any
> pointers would be appreciated.
>
> Thank you very much for all your help.
>
> Best Regards,
> Arnabjyoti Kalita


-- 
Alex Bennée



reply via email to

[Prev in Thread] Current Thread [Next in Thread]