You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It might be beneficial to have the same fields in a breakpoint response too.
In fact, upon a breakpoint event, you can do a couple of things:
recoiling
replace the original instruction
trigger singlestep
replace breakpoint
emulate the original instruction in breakpoint even handler (a.k.a RIP++), but this is not very reliable, unless you can embed a decompiler and can implement a specific behavior for each instruction.
if (data->vaddr==event->interrupt_event.gla) {
// our breakpoint !printf("We hit our breakpoint on %s, setting emulation buffer to 0x%"PRIx64"\n",
data->symbol, *(uint64_t*)data->emul.data);
// don't reinjectevent->interrupt_event.reinject=0;
// set previous opcode for emulationevent->emul_insn=&data->emul;
// set response to emulate instructionrsp |= VMI_EVENT_RESPONSE_SET_EMUL_INSN;
}
Amond the benefits of simplifying recoiling on a breakpoint (which is tedius since you need to handle one event handler for the interrupt, and a second for the singlestep event), this solution has the advantage of being race-condition free in a multi-VCPU context.
Also, on a side note, this makes it more difficult to implement VMI_EVENT_RESPONSE_SET_EMUL_READ_DATA and VMI_EVENT_RESPONSE_SET_EMUL_INSN, as for kvmi-v6, they should be specific to a kvmi_event_pf.
In the KVMi-v6 API, the ability to emulate new data or new instructions is tied to the reply of a memory event:
kvm/include/uapi/linux/kvmi.h
Line 251 in 5205f80
It might be beneficial to have the same fields in a breakpoint response too.
In fact, upon a breakpoint event, you can do a couple of things:
emulate the original instruction in breakpoint even handler (a.k.a
RIP++
), but this is not very reliable, unless you can embed a decompiler and can implement a specific behavior for each instruction.configure the original instruction to be emulated, via the breakpoint event response.
In LibVMI, this behavior is already implemented in
breakpoint-emulate-example.c
:https://github.com/libvmi/libvmi/blob/master/examples/breakpoint-emulate-example.c#L87
Amond the benefits of simplifying recoiling on a breakpoint (which is tedius since you need to handle one event handler for the interrupt, and a second for the singlestep event), this solution has the advantage of being race-condition free in a multi-VCPU context.
Also, on a side note, this makes it more difficult to implement
VMI_EVENT_RESPONSE_SET_EMUL_READ_DATA
andVMI_EVENT_RESPONSE_SET_EMUL_INSN
, as for kvmi-v6, they should be specific to akvmi_event_pf
.So this type of generic
process_cb_response()
is not possible:https://github.com/libvmi/libvmi/blob/master/libvmi/driver/xen/xen_events.c#L604
On Xen, I'm not sure, but LibVMI has an internal structure, with emulation context available for all events:
https://github.com/libvmi/libvmi/blob/master/libvmi/driver/xen/xen_events_private.h#L97
@tklengyel , can you tell us if an emulation context is theoretically available for all VM events on Xen ?
Thanks.
The text was updated successfully, but these errors were encountered: