x86/monitor: Add new monitor event to catch all vmexits
authorTamas K Lengyel <tamas.lengyel@intel.com>
Fri, 11 Mar 2022 20:43:55 +0000 (20:43 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 18 May 2022 17:31:11 +0000 (18:31 +0100)
commit540645212a1485d5adfb75dc6f93c2af8f06de9d
treec5834578f9c4ab63c89b9a8ad01e2e211d2b9729
parentb7d885695f91d4aa6fc498d27cfa1fefef53b2f2
x86/monitor: Add new monitor event to catch all vmexits

Add monitor event that hooks the vmexit handler allowing for both sync and
async monitoring of events. With async monitoring an event is placed on the
monitor ring for each exit and the rest of the vmexit handler resumes normally.
If there are additional monitor events configured those will also place their
respective events on the monitor ring.

With the sync version an event is placed on the monitor ring but the handler
does not get resumed, thus the sync version is only useful when the VM is not
expected to resume normally after the vmexit. Our use-case is primarily with
the sync version with VM forks where the fork gets reset after sync vmexit
event, thus the rest of the vmexit handler can be safely skipped. This is
very useful when we want to avoid Xen crashing the VM under any circumstance,
for example during fuzzing. Collecting all vmexit information regardless of
the root cause makes it easier to reason about the state of the VM on the
monitor side, hence we opt to receive all events, even for external interrupt
and NMI exits and let the monitor agent decide how to proceed.

Signed-off-by: Tamas K Lengyel <tamas.lengyel@intel.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
tools/include/xenctrl.h
tools/libs/ctrl/xc_monitor.c
xen/arch/x86/hvm/monitor.c
xen/arch/x86/hvm/vmx/vmx.c
xen/arch/x86/include/asm/domain.h
xen/arch/x86/include/asm/hvm/monitor.h
xen/arch/x86/include/asm/monitor.h
xen/arch/x86/monitor.c
xen/include/public/domctl.h
xen/include/public/vm_event.h