xen: events: add event channel allocation for domain-0

This commit adds interface for evtchn allocation that can be used by
privilaged domain. Domain 0 can specify both dom and remote_dom
parameters for hypercall, where in others domains dom should be always
DOMID_SELF. It is needed for creating pre-defined channels during
domain setup in Zephyr Dom0.

Signed-off-by: Dmytro Firsov <dmytro_firsov@epam.com>
This commit is contained in:
Dmytro Firsov 2023-02-14 14:40:38 +02:00 committed by Fabio Baltieri
parent c9d2fb7d40
commit 5852dd2b1a
2 changed files with 29 additions and 0 deletions

View file

@ -47,6 +47,24 @@ int alloc_unbound_event_channel(domid_t remote_dom)
return rc; return rc;
} }
#ifdef CONFIG_XEN_DOM0
int alloc_unbound_event_channel_dom0(domid_t dom, domid_t remote_dom)
{
int rc;
struct evtchn_alloc_unbound alloc = {
.dom = dom,
.remote_dom = remote_dom,
};
rc = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound, &alloc);
if (rc == 0) {
rc = alloc.port;
}
return rc;
}
#endif /* CONFIG_XEN_DOM0 */
int bind_interdomain_event_channel(domid_t remote_dom, evtchn_port_t remote_port, int bind_interdomain_event_channel(domid_t remote_dom, evtchn_port_t remote_port,
evtchn_cb_t cb, void *data) evtchn_cb_t cb, void *data)
{ {

View file

@ -36,6 +36,17 @@ void notify_evtchn(evtchn_port_t port);
*/ */
int alloc_unbound_event_channel(domid_t remote_dom); int alloc_unbound_event_channel(domid_t remote_dom);
#ifdef CONFIG_XEN_DOM0
/*
* Allocate event-channel between remote domains. Can be used only from Dom0.
*
* @param dom - first remote domain domid (may be DOMID_SELF)
* @param remote_dom - second remote domain domid
* @return - local event channel port on success, negative on error
*/
int alloc_unbound_event_channel_dom0(domid_t dom, domid_t remote_dom);
#endif /* CONFIG_XEN_DOM0 */
/* /*
* Allocate local event channel, binded to remote port and attach specified callback * Allocate local event channel, binded to remote port and attach specified callback
* to it * to it