Message ID | abe4c5be55125eb3da33dbd187fd9b8ad5ace714.1660902588.git.rahul.singh@arm.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | xen/evtchn: implement static event channel signaling | expand |
On 19.08.2022 12:02, Rahul Singh wrote: > Static event channel support will be added for dom0less domains. Modify > evtchn_bind_interdomain to support static evtchn. > > It is necessary to have access to the evtchn_bind_interdomain function > to do that, so make evtchn_bind_interdomain global and also make it > __must_check. > > evtchn_bind_interdomain() always allocates the next available local > port. Static event channel support for dom0less domains requires > allocating a specified port. Modify the evtchn_bind_interdomain to > accept the port number as an argument and allocate the specified port > if available. If the port number argument is zero, the next available > port will be allocated. > > evtchn_bind_interdomain() finds the local domain from "current->domain" > pointer. evtchn_bind_interdomain() will be called from the XEN to create > static event channel during domain creation. "current" pointer is not > valid at that time, therefore modify the evtchn_bind_interdomain() to > pass domain as an argument. > > Signed-off-by: Rahul Singh <rahul.singh@arm.com> Acked-by: Jan Beulich <jbeulich@suse.com>
Hi Rahul, On 19/08/2022 11:02, Rahul Singh wrote: > Static event channel support will be added for dom0less domains. Modify > evtchn_bind_interdomain to support static evtchn. > > It is necessary to have access to the evtchn_bind_interdomain function > to do that, so make evtchn_bind_interdomain global and also make it > __must_check. > > evtchn_bind_interdomain() always allocates the next available local > port. Static event channel support for dom0less domains requires > allocating a specified port. NIT: I first read this as you are trying to describe what the patch does. I would add "currently", "at the moment" or similar to make clear this is the current behavior. > Modify the evtchn_bind_interdomain to > accept the port number as an argument and allocate the specified port > if available. If the port number argument is zero, the next available > port will be allocated. > > evtchn_bind_interdomain() finds the local domain from "current->domain" > pointer. evtchn_bind_interdomain() will be called from the XEN to create > static event channel during domain creation. "current" pointer is not > valid at that time, therefore modify the evtchn_bind_interdomain() to > pass domain as an argument. Ditto. > > Signed-off-by: Rahul Singh <rahul.singh@arm.com> Reviewed-by: Julien Grall <jgrall@amazon.com> Cheers,
Hi Julien, > On 23 Aug 2022, at 9:23 am, Julien Grall <julien@xen.org> wrote: > > Hi Rahul, > > On 19/08/2022 11:02, Rahul Singh wrote: >> Static event channel support will be added for dom0less domains. Modify >> evtchn_bind_interdomain to support static evtchn. >> It is necessary to have access to the evtchn_bind_interdomain function >> to do that, so make evtchn_bind_interdomain global and also make it >> __must_check. >> evtchn_bind_interdomain() always allocates the next available local >> port. Static event channel support for dom0less domains requires >> allocating a specified port. > > NIT: I first read this as you are trying to describe what the patch does. I would add "currently", "at the moment" or similar to make clear this is the current behavior. Ack. I will add “currently” in next version. > > >> Modify the evtchn_bind_interdomain to >> accept the port number as an argument and allocate the specified port >> if available. If the port number argument is zero, the next available >> port will be allocated. >> evtchn_bind_interdomain() finds the local domain from "current->domain" >> pointer. evtchn_bind_interdomain() will be called from the XEN to create >> static event channel during domain creation. "current" pointer is not >> valid at that time, therefore modify the evtchn_bind_interdomain() to >> pass domain as an argument. > > Ditto. Ack. Regards, Rahul
diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c index 194f5346fb..eed0e94d07 100644 --- a/xen/common/event_channel.c +++ b/xen/common/event_channel.c @@ -373,11 +373,16 @@ static void double_evtchn_unlock(struct evtchn *lchn, struct evtchn *rchn) evtchn_write_unlock(rchn); } -static int evtchn_bind_interdomain(evtchn_bind_interdomain_t *bind) +/* + * If lport is zero get the next free port and allocate. If port is non-zero + * allocate the specified lport. + */ +int evtchn_bind_interdomain(evtchn_bind_interdomain_t *bind, struct domain *ld, + evtchn_port_t lport) { struct evtchn *lchn, *rchn; - struct domain *ld = current->domain, *rd; - int lport, rc; + struct domain *rd; + int rc; evtchn_port_t rport = bind->remote_port; domid_t rdom = bind->remote_dom; @@ -397,8 +402,11 @@ static int evtchn_bind_interdomain(evtchn_bind_interdomain_t *bind) write_lock(&ld->event_lock); } - if ( (lport = get_free_port(ld)) < 0 ) - ERROR_EXIT(lport); + lport = rc = evtchn_get_port(ld, lport); + if ( rc < 0 ) + ERROR_EXIT(rc); + rc = 0; + lchn = evtchn_from_port(ld, lport); rchn = _evtchn_from_port(rd, rport); @@ -1231,7 +1239,7 @@ long do_event_channel_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) struct evtchn_bind_interdomain bind_interdomain; if ( copy_from_guest(&bind_interdomain, arg, 1) != 0 ) return -EFAULT; - rc = evtchn_bind_interdomain(&bind_interdomain); + rc = evtchn_bind_interdomain(&bind_interdomain, current->domain, 0); if ( !rc && __copy_to_guest(arg, &bind_interdomain, 1) ) rc = -EFAULT; /* Cleaning up here would be a mess! */ break; diff --git a/xen/include/xen/event.h b/xen/include/xen/event.h index f3021fe304..f29b1123d9 100644 --- a/xen/include/xen/event.h +++ b/xen/include/xen/event.h @@ -74,6 +74,11 @@ int evtchn_allocate_port(struct domain *d, unsigned int port); /* Allocate a new event channel */ int __must_check evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc); +/* Bind an event channel port to interdomain */ +int __must_check evtchn_bind_interdomain(evtchn_bind_interdomain_t *bind, + struct domain *ld, + evtchn_port_t port); + /* Unmask a local event-channel port. */ int evtchn_unmask(unsigned int port);
Static event channel support will be added for dom0less domains. Modify evtchn_bind_interdomain to support static evtchn. It is necessary to have access to the evtchn_bind_interdomain function to do that, so make evtchn_bind_interdomain global and also make it __must_check. evtchn_bind_interdomain() always allocates the next available local port. Static event channel support for dom0less domains requires allocating a specified port. Modify the evtchn_bind_interdomain to accept the port number as an argument and allocate the specified port if available. If the port number argument is zero, the next available port will be allocated. evtchn_bind_interdomain() finds the local domain from "current->domain" pointer. evtchn_bind_interdomain() will be called from the XEN to create static event channel during domain creation. "current" pointer is not valid at that time, therefore modify the evtchn_bind_interdomain() to pass domain as an argument. Signed-off-by: Rahul Singh <rahul.singh@arm.com> --- Changes in v2: - Merged patches related to evtchn_bind_interdomain in one patch --- --- xen/common/event_channel.c | 20 ++++++++++++++------ xen/include/xen/event.h | 5 +++++ 2 files changed, 19 insertions(+), 6 deletions(-)