Event channels are the basic primitive provided by Xen for event notifications. An event is the Xen equivalent of a hardware interrupt. They essentially store one bit of information, the event of interest is signalled by transitioning this bit from 0 to 1.
Notifications are received by a guest via an upcall from Xen, indicating when an event arrives (setting the bit).
Further notifications are masked until the bit is cleared again (therefore, guests must check the value of the bit after re-enabling event delivery to ensure no missed notifications).
Event notifications can be masked by setting a flag; this is equivalent to disabling interrupts and can be used to ensure atomicity of certain operations in the guest kernel.
Hypercall interface
event_channel_op(evtchn op t *op)
The event channel operation hypercall is used for all operations on event channels / ports. Operations are distinguished by the value of the cmd field of the op structure.
The possible commands are described below:
EVTCHNOP_alloc_unbound Allocate a new event channel port, ready to be connected to by a remote domain.
• Specified domain must exist.
• A free port must exist in that domain.
Unprivileged domains may only allocate their own ports, privileged domains may also allocate ports in other domains.
EVTCHNOP_bind_interdomain Bind an event channel for interdomain communications.
• Caller domain must have a free port to bind.
• Remote domain must exist.
• Remote port must be allocated and currently unbound.
• Remote port must be expecting the caller domain as the “remote”.
EVTCHNOP_bind_virq Allocate a port and bind a VIRQ to it.
• Caller domain must have a free port to bind.
• VIRQ must be valid.
• VCPU must exist.
• VIRQ must not currently be bound to an event channel.
EVTCHNOP_bind_ipi Allocate and bind a port for notifying other virtual CPUs.
• Caller domain must have a free port to bind.
• VCPU must exist.
EVTCHNOP_bind_pirq Allocate and bind a port to a real IRQ.
• Caller domain must have a free port to bind.
• PIRQ must be within the valid range.
• Another binding for this PIRQ must not exist for this domain.
• Caller must have an available port.
EVTCHNOP_close Close an event channel (no more events will be received).
• Port must be valid (currently allocated).
EVTCHNOP_send Send a notification on an event channel attached to a port.
• Port must be valid.
• Only valid for Interdomain, IPI or Allocated Unbound ports.
EVTCHNOP_status Query the status of a port; what kind of port, whether it is bound, what remote domain is expected, what PIRQ or VIRQ it is bound to, what VCPU will be notified, etc. Unprivileged domains may only query the state of their own ports. Privileged domains may query any port.
EVTCHNOP_bind_vcpu Bind event channel to a particular VCPU - receive notification upcalls only on that VCPU.
• VCPU must exist.
• Port must be valid.
• Event channel must be either: allocated but unbound, bound to an interdomain event channel, bound to a PIRQ.
阅读(1057) | 评论(0) | 转发(0) |