Skip to main content

xen/ctrl/event/
flags.rs

1use xen_sys::{
2    VM_EVENT_FLAG_ALTERNATE_P2M, VM_EVENT_FLAG_DENY, VM_EVENT_FLAG_EMULATE,
3    VM_EVENT_FLAG_EMULATE_NOWRITE, VM_EVENT_FLAG_FAST_SINGLESTEP, VM_EVENT_FLAG_FOREIGN,
4    VM_EVENT_FLAG_GET_NEXT_INTERRUPT, VM_EVENT_FLAG_NESTED_P2M, VM_EVENT_FLAG_RESET_FORK_MEMORY,
5    VM_EVENT_FLAG_RESET_FORK_STATE, VM_EVENT_FLAG_RESET_VMTRACE, VM_EVENT_FLAG_SET_EMUL_INSN_DATA,
6    VM_EVENT_FLAG_SET_EMUL_READ_DATA, VM_EVENT_FLAG_SET_REGISTERS, VM_EVENT_FLAG_TOGGLE_SINGLESTEP,
7    VM_EVENT_FLAG_VCPU_PAUSED,
8};
9
10bitflags::bitflags! {
11    #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
12    pub struct VmEventFlag: u32 {
13        // VCPU_PAUSED in a request signals that the vCPU triggering the event has been paused
14        // VCPU_PAUSED in a response signals to unpause the vCPU
15        const VCPU_PAUSED = VM_EVENT_FLAG_VCPU_PAUSED;
16
17        // Flags to aid debugging vm_event
18        const FOREIGN = VM_EVENT_FLAG_FOREIGN;
19
20        // The following flags can be set in response to a mem_access event.
21        //
22        // Emulate the fault-causing instruction (if set in the event response flags).
23        // This will allow the guest to continue execution without lifting the page
24        // access restrictions.
25        const EMULATE = VM_EVENT_FLAG_EMULATE;
26
27        // Same as VM_EVENT_FLAG_EMULATE, but with write operations or operations
28        // potentially having side effects (like memory mapped or port I/O) disabled.
29        const EMULATE_NO_WRITE = VM_EVENT_FLAG_EMULATE_NOWRITE;
30
31        // Toggle singlestepping on vm_event response.
32        // Requires the vCPU to be paused already (synchronous events only).
33        const TOGGLE_SINGLESTEP = VM_EVENT_FLAG_TOGGLE_SINGLESTEP;
34
35        // Data is being sent back to the hypervisor in the event response, to be
36        // returned by the read function when emulating an instruction.
37        // This flag is only useful when combined with VM_EVENT_FLAG_EMULATE
38        // and takes precedence if combined with VM_EVENT_FLAG_EMULATE_NOWRITE
39        // (i.e. if both VM_EVENT_FLAG_EMULATE_NOWRITE and
40        // VM_EVENT_FLAG_SET_EMUL_READ_DATA are set, only the latter will be honored).
41        const SET_EMUL_READ_DATA = VM_EVENT_FLAG_SET_EMUL_READ_DATA;
42
43        // Deny completion of the operation that triggered the event.
44        // Currently only useful for MSR and control-register write events.
45        // Requires the vCPU to be paused already (synchronous events only).
46        const DENY = VM_EVENT_FLAG_DENY;
47
48        // This flag can be set in a request or a response
49        //
50        // On a request, indicates that the event occurred in the alternate p2m
51        // specified by the altp2m_idx request field.
52        //
53        // On a response, indicates that the VCPU should resume in the alternate p2m
54        // specified by the altp2m_idx response field if possible.
55        const ALTERNATE_P2M = VM_EVENT_FLAG_ALTERNATE_P2M;
56
57        // Set the vCPU registers to the values in the  vm_event response.
58        // At the moment x86-only, applies to EAX-EDX, ESP, EBP, ESI, EDI, R8-R15,
59        // EFLAGS, and EIP.
60        // Requires the vCPU to be paused already (synchronous events only).
61        const SET_REGISTERS = VM_EVENT_FLAG_SET_REGISTERS;
62
63        // Instruction cache is being sent back to the hypervisor in the event response
64        // to be used by the emulator. This flag is only useful when combined with
65        // VM_EVENT_FLAG_EMULATE and does not take presedence if combined with
66        // VM_EVENT_FLAG_EMULATE_NOWRITE or VM_EVENT_FLAG_SET_EMUL_READ_DATA, (i.e.
67        // if any of those flags are set, only those will be honored).
68        const SET_EMUL_INSN_DATA = VM_EVENT_FLAG_SET_EMUL_INSN_DATA;
69
70        // Have a one-shot VM_EVENT_REASON_INTERRUPT event sent for the first
71        // interrupt pending after resuming the VCPU.
72        const GET_NEXT_INTERRUPT = VM_EVENT_FLAG_GET_NEXT_INTERRUPT;
73
74        // Execute fast singlestepping on vm_event response.
75        // Requires the vCPU to be paused already (synchronous events only).
76        //
77        // On a response requires setting the p2midx field of fast_singlestep to which
78        // Xen will switch the vCPU to on the occurance of the first singlestep, after
79        // which singlestep gets automatically disabled.
80        const FAST_SINGLESTEP = VM_EVENT_FLAG_FAST_SINGLESTEP;
81
82        // Set if the event comes from a nested VM and thus npt_base is valid.
83        const NESTED_P2M = VM_EVENT_FLAG_NESTED_P2M;
84
85        // Reset the vmtrace buffer (if vmtrace is enabled)
86        const RESET_VMTRACE = VM_EVENT_FLAG_RESET_VMTRACE;
87
88        // Reset the VM state (if VM is fork)
89        const RESET_FORK_STATE = VM_EVENT_FLAG_RESET_FORK_STATE;
90
91        // Remove unshared entries from physmap (if VM is fork)
92        const RESET_FORK_MEMORY = VM_EVENT_FLAG_RESET_FORK_MEMORY;
93    }
94}