xen/evtchn: implement static event channel signaling
v4 cover xen/evtchn: implement static event channel signaling
The purpose of this patch series is to add the static event channel signaling support to Xen on Arm based on design doc [1].
[1] https://lists.xenproject.org/archives/html/xen-devel/2022-05/msg01160.html
Julien Grall (1):
xen/evtchn: Make sure all buckets below d->valid_evtchns are allocated
Rahul Singh (5):
xen/evtchn: restrict the maximum number of evtchn supported for domUs xen/evtchn: modify evtchn_alloc_unbound to allocate specified port xen/evtchn: modify evtchn_bind_interdomain to support static evtchn xen/arm: introduce new xen,enhanced property value xen/arm: introduce xen-evtchn dom0less property
Stanislav Kinsburskii (1):
xen/evtchn: Add an helper to reserve/allocate a port
docs/misc/arm/device-tree/booting.txt | 102 ++++++++++++++++ xen/arch/arm/domain_build.c | 167 +++++++++++++++++++++++++- xen/arch/arm/include/asm/kernel.h | 23 +++- xen/arch/arm/include/asm/setup.h | 1 + xen/arch/arm/setup.c | 2 + xen/common/event_channel.c | 121 ++++++++++++------- xen/include/xen/device_tree.h | 16 +++ xen/include/xen/event.h | 8 +- 8 files changed, 387 insertions(+), 53 deletions(-)
Signature · 1 line
2.25.1
PATCH v4 1/7 xen/evtchn: Make sure all buckets below d->valid_evtchns are allocated
From: Julien Grall <[email protected]>
Since commit 01280dc19cf3 "evtchn: simplify port_is_valid()", the event channels code assumes that all the buckets below d->valid_evtchns are always allocated.
This assumption hold in most of the situation because a guest is not allowed to chose the port. Instead, it will be the first free from port 0.
When static event channel support will be added for dom0less domains user can request to allocate the evtchn port numbers that are scattered in nature.
The existing implementation of evtchn_allocate_port() is not able to deal with such situation and will end up to override bucket or/and leave some bucket unallocated. The latter will result to a droplet crash if the event channel belongs to an unallocated bucket.
This can be solved by making sure that all the buckets below d->valid_evtchns are allocated. There should be no impact for most of the situation but LM/LU as only one bucket would be allocated. For LM/LU, we may end up to allocate multiple buckets if ports in use are sparse.
A potential alternative is to check that the bucket is valid in is_port_valid(). This should still possible to do it without taking per-domain lock but will result a couple more of memory access.
---
Changes in v4:
- fix comment to remove the reference to Guest Transparent Migration and Live Update
- Added Michal Reviewed-by
Changes in v3:
- fix comments in commit msg.
- modify code related to d->valid_evtchns and {read,write}_atomic()
Changes in v2:
- new patch in this version to avoid the security issue
--- xen/common/event_channel.c | 55 ++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 20 deletions(-)
xen/common/event_channel.c +35 -20
@@ -193,6 +193,15 @@ static struct evtchn *alloc_evtchn_bucket(struct domain *d, unsigned int port)return NULL ; } +/* +* Allocate a given port and ensure all the buckets up to that ports +* have been allocated. +* +* The last part is important because the rest of the event channel code +* relies on all the buckets up to d->valid_evtchns to be valid. However, +* event channels may be sparsed when allocating the static evtchn port +* numbers that are scattered in nature. +*/ int evtchn_allocate_port (struct domain *d,evtchn_port_t port) {if ( port > d->max_evtchn_port || port >=max_evtchns (d) )
@@ -207,30 +216,36 @@ int evtchn_allocate_port(struct domain *d, evtchn_port_t port) }else { -struct evtchn *chn; -struct evtchn **grp; +unsigned int alloc_port =read_atomic (&d->valid_evtchns); -if ( !group_from_port (d, port) ) +do { - grp = xzalloc_array(struct evtchn *, BUCKETS_PER_GROUP); -if ( !grp ) -return -ENOMEM ; -group_from_port (d, port) = grp; - } +struct evtchn *chn; +struct evtchn **grp; - chn =alloc_evtchn_bucket (d, port); -if ( !chn ) -return -ENOMEM ; -bucket_from_port (d, port) = chn; +if ( !group_from_port (d, alloc_port) ) + { + grp = xzalloc_array(struct evtchn *, BUCKETS_PER_GROUP); +if ( !grp ) +return -ENOMEM ; +group_from_port (d, alloc_port) = grp; + } -/* -* d->valid_evtchns is used to check whether the bucket can be -* accessed without the per-domain lock. Therefore, -* d->valid_evtchns should be seen *after* the new bucket has -* been setup. -*/ -smp_wmb (); -write_atomic (&d->valid_evtchns, d->valid_evtchns +EVTCHNS_PER_BUCKET ); + chn =alloc_evtchn_bucket (d, alloc_port); +if ( !chn ) +return -ENOMEM ; +bucket_from_port (d, alloc_port) = chn; + +/* +* d->valid_evtchns is used to check whether the bucket can be +* accessed without the per-domain lock. Therefore, +* d->valid_evtchns should be seen *after* the new bucket has +* been setup. +*/ +smp_wmb (); + alloc_port +=EVTCHNS_PER_BUCKET ; +write_atomic (&d->valid_evtchns, alloc_port); + }while ( port >= alloc_port ); }write_atomic (&d->active_evtchns, d->active_evtchns +1 );
Signature · 1 line
2.25.1
Re: [PATCH v4 1/7] xen/evtchn: Make sure all buckets below d->valid_evtchns are allocated
Quoted 25 lines · Rahul Singh
From: Julien Grall <[email protected]>
Since commit
01280dc19cf3"evtchn: simplifyport_is_valid()", the event channels code assumes that all the buckets belowd->valid_evtchnsare always allocated.This assumption hold in most of the situation because a guest is not allowed to chose the port. Instead, it will be the first free from port 0.
When static event channel support will be added for dom0less domains user can request to allocate the evtchn port numbers that are scattered in nature.
The existing implementation of
evtchn_allocate_port()is not able to deal with such situation and will end up to override bucket or/and leave some bucket unallocated. The latter will result to a droplet crash if the event channel belongs to an unallocated bucket.This can be solved by making sure that all the buckets below
d->valid_evtchnsare allocated. There should be no impact for most of the situation but LM/LU as only one bucket would be allocated. For LM/LU, we may end up to allocate multiple buckets if ports in use are sparse.
Quoted 7 lines
A potential alternative is to check that the bucket is valid in
is_port_valid(). This should still possible to do it without taking per-domain lock but will result a couple more of memory access.Signed-off-by Julien Grall <[email protected]>Signed-off-by Rahul Singh <[email protected]>Reviewed-by Michal Orzel <[email protected]>
PATCH v4 2/7 xen/evtchn: Add an helper to reserve/allocate a port
In reply to Rahul SinghFrom: Stanislav Kinsburskii <[email protected]>
In a follow-up patch we will want to either reserve or allocate a port for various event channel helpers.
A new wrapper is introduced to either reserve a given port or allocate a fresh one if zero.
Take the opportunity to replace the open-coded version in evtchn_bind_virq().
---
Changes in v4:
- Change the Author to Stanislav Kinsburskii <[email protected]>
Changes in v3:
- minor comments in commit msg
Changes in v2:
- new patch in this version
--- xen/common/event_channel.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-)
xen/common/event_channel.c +16 -13
@@ -305,6 +305,18 @@ void evtchn_free(struct domain *d, struct evtchn *chn)xsm_evtchn_close_post (chn); } +static int evtchn_get_port (struct domain *d,evtchn_port_t port) +{ +int rc; + +if ( port !=0 ) + rc =evtchn_allocate_port (d, port); +else + rc =get_free_port (d); + +return rc ?: port; +} +int evtchn_alloc_unbound (evtchn_alloc_unbound_t *alloc) {struct evtchn *chn;
@@ -462,19 +474,10 @@ int evtchn_bind_virq(evtchn_bind_virq_t *bind, evtchn_port_t port)if (read_atomic (&v->virq_to_evtchn[virq]) )ERROR_EXIT (-EEXIST ); -if ( port !=0 ) - { -if ( (rc =evtchn_allocate_port (d, port)) !=0 ) -ERROR_EXIT (rc); - } -else - { -int alloc_port =get_free_port (d); - -if ( alloc_port <0 ) -ERROR_EXIT (alloc_port); - port = alloc_port; - } + port = rc =evtchn_get_port (d, port); +if ( rc <0 ) +ERROR_EXIT (rc); + rc =0 ; chn =evtchn_from_port (d, port);
Signature · 1 line
2.25.1
PATCH v4 3/7 xen/evtchn: restrict the maximum number of evtchn supported for domUs
In reply to Rahul SinghRestrict the maximum number of evtchn supported for domUs to avoid allocating a large amount of memory in Xen.
Set the default value of max_evtchn_port to 1023. The value of 1023 should be sufficient for domUs guests because on ARM we don't bind physical interrupts to event channels. The only use of the evtchn port is inter-domain communications. Another reason why we choose the value of 1023 to follow the default behavior of libxl.
---
Changes in v4:
- fix minor comments in commit msg
- Added Michal Reviewed-by
Changes in v3:
- added in commit msg why we set the max_evtchn_port value to 1023.
- added the comment in code also why we set the max_evtchn_port to 1023
- remove the define and set the value to 1023 in code directly.
Changes in v2:
- new patch in the version
--- xen/arch/arm/domain_build.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
xen/arch/arm/domain_build.c +7 -1
@@ -3277,7 +3277,13 @@ void __init create_domUs(void)struct xen_domctl_createdomain d_cfg = { .arch.gic_version =XEN_DOMCTL_CONFIG_GIC_NATIVE , .flags = XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap, - .max_evtchn_port =-1 , +/* +* The default of 1023 should be sufficient for domUs guests +* because on ARM we don't bind physical interrupts to event +* channels. The only use of the evtchn port is inter-domain +* communications. +*/ + .max_evtchn_port =1023 , .max_grant_frames =-1 , .max_maptrack_frames =-1 , .grant_opts =XEN_DOMCTL_GRANT_version (opt_gnttab_max_version),
Signature · 1 line
2.25.1
Re: [PATCH v4 3/7] xen/evtchn: restrict the maximum number of evtchn supported for domUs
Quoted 5 lines · Rahul Singh
Restrict the maximum number of evtchn supported for domUs to avoid allocating a large amount of memory in Xen.
Set the default value of
max_evtchn_portto 1023. The value of 1023 should be sufficient for domUs guests because on ARM we don't bind
To me, domUs and guests mean the same. So s/guests//
Quoted 25 lines
physical interrupts to event channels. The only use of the evtchn port is inter-domain communications. Another reason why we choose the value of 1023 to follow the default behavior of libxl.
Signed-off-by Rahul Singh <[email protected]>Reviewed-by Michal Orzel <[email protected]>---
Changes in v4:
- fix minor comments in commit msg
- Added Michal Reviewed-by
Changes in v3:
- added in commit msg why we set themax_evtchn_portvalue to 1023.
- added the comment in code also why we set themax_evtchn_portto 1023
- remove the define and set the value to 1023 in code directly.
Changes in v2:
- new patch in the version--- xen/arch/arm/domain_build.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)xen/arch/arm/domain_build.c +0
-0
xen/arch/arm/domain_build.c void __init create_domUs(void) · line 3281
Quoted 6 lines
xen/arch/arm/domain_build.c +2
-1@@ -3277,7 +3277,13 @@ void __init create_domUs(void)struct xen_domctl_createdomain d_cfg = { .arch.gic_version =XEN_DOMCTL_CONFIG_GIC_NATIVE , .flags = XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap, - .max_evtchn_port =-1 , +/* +* The default of 1023 should be sufficient for domUs guests
To me, domUs and guests mean the same. So s/guests//
Same here. With that:
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v4 3/7] xen/evtchn: restrict the maximum number of evtchn supported for domUs
Hi Julien,
Quoted 11 lines · Julien Grall
Quoted 4 lines · Rahul Singh
Restrict the maximum number of evtchn supported for domUs to avoid allocating a large amount of memory in Xen.
Set the default value ofmax_evtchn_portto 1023. The value of 1023 should be sufficient for domUs guests because on ARM we don't bindTo me, domUs and guests mean the same. So s/guests//
Ack.
Quoted 33 lines
Quoted 24 lines
physical interrupts to event channels. The only use of the evtchn port is inter-domain communications. Another reason why we choose the value of 1023 to follow the default behavior of libxl.
Signed-off-by Rahul Singh <[email protected]>Reviewed-by Michal Orzel <[email protected]>---
Changes in v4:
- fix minor comments in commit msg
- Added Michal Reviewed-by
Changes in v3:
- added in commit msg why we set themax_evtchn_portvalue to 1023.
- added the comment in code also why we set themax_evtchn_portto 1023
- remove the define and set the value to 1023 in code directly.
Changes in v2:
- new patch in the version--- xen/arch/arm/domain_build.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)xen/arch/arm/domain_build.c +0
-0xen/arch/arm/domain_build.c void __init create_domUs(void) · line 3281
Quoted 6 lines
xen/arch/arm/domain_build.c +2
-1@@ -3277,7 +3277,13 @@ void __init create_domUs(void)struct xen_domctl_createdomain d_cfg = { .arch.gic_version =XEN_DOMCTL_CONFIG_GIC_NATIVE , .flags = XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap, - .max_evtchn_port =-1 , +/* +* The default of 1023 should be sufficient for domUs guests To me, domUs and guests mean the same. So s/guests//
Quoted 5 lines
Same here. With that:
Acked-by Julien Grall <[email protected]>Cheers,
Ack.
Regards,
Rahul
PATCH v4 4/7 xen/evtchn: modify evtchn_alloc_unbound to allocate specified port
In reply to Rahul SinghCurrently evtchn_alloc_unbound() always allocates the next available port. Static event channel support for dom0less domains requires allocating a specified port.
Modify the evtchn_alloc_unbound() 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.
---
Changes in v4:
- no changes
Changes in v3:
- fix minor comments in commit msg
Changes in v2:
- fix minor comments
--- xen/arch/arm/domain_build.c | 2 +- xen/common/event_channel.c | 17 ++++++++++++----- xen/include/xen/event.h | 3 ++- 3 files changed, 15 insertions(+), 7 deletions(-)
xen/arch/arm/domain_build.c +1 -1
@@ -3171,7 +3171,7 @@ static int __init alloc_xenstore_evtchn(struct domain *d) alloc.dom = d->domain_id; alloc.remote_dom = hardware_domain->domain_id; - rc =evtchn_alloc_unbound (&alloc); + rc =evtchn_alloc_unbound (&alloc,0 );if ( rc ) {printk ("Failed allocating event channel for domain\n" );
xen/common/event_channel.c +12 -5
@@ -317,11 +317,15 @@ static int evtchn_get_port(struct domain *d, evtchn_port_t port)return rc ?: port; } -int evtchn_alloc_unbound (evtchn_alloc_unbound_t *alloc) +/* +* If port is zero get the next free port and allocate. If port is non-zero +* allocate the specified port. +*/ +int evtchn_alloc_unbound (evtchn_alloc_unbound_t *alloc,evtchn_port_t port) {struct evtchn *chn;struct domain *d; -int port, rc; +int rc;domid_t dom = alloc->dom; d =rcu_lock_domain_by_any_id (dom);
@@ -330,8 +334,11 @@ int evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc)write_lock (&d->event_lock); -if ( (port =get_free_port (d)) <0 ) -ERROR_EXIT_DOM (port, d); + port = rc =evtchn_get_port (d, port); +if ( rc <0 ) +ERROR_EXIT (rc); + rc =0 ; + chn =evtchn_from_port (d, port); rc =xsm_evtchn_unbound (XSM_TARGET , d, chn, alloc->remote_dom);
@@ -1222,7 +1229,7 @@ long do_event_channel_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)struct evtchn_alloc_unbound alloc_unbound;if (copy_from_guest (&alloc_unbound, arg,1 ) !=0 )return -EFAULT ; - rc =evtchn_alloc_unbound (&alloc_unbound); + rc =evtchn_alloc_unbound (&alloc_unbound,0 );if ( !rc &&__copy_to_guest (arg, &alloc_unbound,1 ) ) rc = -EFAULT ;/* Cleaning up here would be a mess! */ break ;
xen/include/xen/event.h +2 -1
@@ -72,7 +72,8 @@ void evtchn_free(struct domain *d, struct evtchn *chn);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); +int __must_check evtchn_alloc_unbound (evtchn_alloc_unbound_t *alloc, +evtchn_port_t port);/* Unmask a local event-channel port. */ int evtchn_unmask (unsigned int port);
Signature · 1 line
2.25.1
PATCH v4 5/7 xen/evtchn: modify evtchn_bind_interdomain to support static evtchn
In reply to Rahul SinghStatic 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.
Currently 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.
Currently 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.
---
Changes in v4:
- no changes
Changes in v3:
- fix minor comments in commit msg
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(-)
xen/common/event_channel.c +14 -6
@@ -381,11 +381,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;
@@ -405,8 +410,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);
@@ -1239,7 +1247,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 ;
xen/include/xen/event.h +5 -0
@@ -75,6 +75,11 @@ int evtchn_allocate_port(struct domain *d, unsigned int port);int __must_check evtchn_alloc_unbound (evtchn_alloc_unbound_t *alloc,evtchn_port_t port); +/* 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);
Signature · 1 line
2.25.1
PATCH v4 6/7 xen/arm: introduce new xen,enhanced property value
In reply to Rahul SinghIntroduce a new "xen,enhanced" dom0less property value "no-xenstore" to disable xenstore interface for dom0less guests.
---
Changes in v4:
- Implement defines for dom0less features
Changes in v3:
- new patch in this version
--- docs/misc/arm/device-tree/booting.txt | 4 ++++ xen/arch/arm/domain_build.c | 10 ++++++---- xen/arch/arm/include/asm/kernel.h | 23 +++++++++++++++++++++-- 3 files changed, 31 insertions(+), 6 deletions(-)
docs/misc/arm/device-tree/booting.txt +4 -0
@@ -204,6 +204,10 @@ with the following properties: - "disabled" Xen PV interfaces are disabled. + - no-xenstore + Xen PV interfaces, including grant-table will be enabled but xenstore + will be disabled for the VM. + If the xen,enhanced property is present with no value, it defaults to "enabled". If the xen,enhanced property is not present, PV interfaces are disabled.
xen/arch/arm/domain_build.c +6 -4
@@ -2891,7 +2891,7 @@ static int __init prepare_dtb_domU(struct domain *d, struct kernel_info *kinfo) goto err; } -if ( kinfo->dom0less_enhanced ) +if ( kinfo->dom0less_feature &DOM0LESS_ENHANCED_NO_XS ) { ret =make_hypervisor_node (d, kinfo, addrcells, sizecells);if ( ret )
@@ -3209,10 +3209,12 @@ static int __init construct_domU(struct domain *d, (rc == 0 && !strcmp(dom0less_enhanced, "enabled")) ) {if ( hardware_domain ) - kinfo.dom0less_enhanced = true; + kinfo.dom0less_feature =DOM0LESS_ENHANCED ;else -panic ("Tried to use xen,enhanced without dom0\n" ); +panic ("At the moment, Xenstore support requires dom0 to be present\n" ); } + else if ( rc == 0 && !strcmp(dom0less_enhanced, "no-xenstore") ) + kinfo.dom0less_feature =DOM0LESS_ENHANCED_NO_XS ;if (vcpu_create (d,0 ) ==NULL )return -ENOMEM ;
@@ -3252,7 +3254,7 @@ static int __init construct_domU(struct domain *d,if ( rc <0 )return rc; -if ( kinfo.dom0less_enhanced ) +if ( kinfo.dom0less_feature &DOM0LESS_XENSTORE ) {ASSERT (hardware_domain); rc =alloc_xenstore_evtchn (d);
xen/arch/arm/include/asm/kernel.h +21 -2
@@ -9,6 +9,25 @@#include <xen/device_tree.h> #include <asm/setup.h> +/* +* List of possible features for dom0less domUs +* +* DOM0LESS_ENHANCED_NO_XS: Notify the OS it is running on top of Xen. All the +* default features (excluding Xenstore) will be +* available. Note that an OS *must* not rely on the +* availability of Xen features if this is not set. +* DOM0LESS_XENSTORE: Xenstore will be enabled for the VM. This feature +* can't be enabled without the +* DOM0LESS_ENHANCED_NO_XS. +* DOM0LESS_ENHANCED: Notify the OS it is running on top of Xen. All the +* default features (including Xenstore) will be +* available. Note that an OS *must* not rely on the +* availability of Xen features if this is not set. +*/ +#define DOM0LESS_ENHANCED_NO_XS BIT(0, U) +#define DOM0LESS_XENSTORE BIT(1, U) +#define DOM0LESS_ENHANCED (DOM0LESS_ENHANCED_NO_XS | DOM0LESS_XENSTORE) +struct kernel_info {#ifdef CONFIG_ARM_64 enum domain_type type;
@@ -36,8 +55,8 @@ struct kernel_info {/* Enable pl011 emulation */ bool vpl011; -/* Enable PV drivers */ -bool dom0less_enhanced; +/* Enable/Disable PV drivers interface,grant table, evtchn or xenstore */ +uint32_t dom0less_feature;/* GIC phandle */ uint32_t phandle_gic;
Signature · 1 line
2.25.1
Re: [PATCH v4 6/7] xen/arm: introduce new xen,enhanced property value
Quoted 20 lines · Rahul Singh
Introduce a new "xen,enhanced" dom0less property value "no-xenstore" to disable xenstore interface for dom0less guests.
Signed-off-by Rahul Singh <[email protected]>---
Changes in v4:
- Implement defines for dom0less features
Changes in v3:
- new patch in this version--- docs/misc/arm/device-tree/booting.txt | 4 ++++ xen/arch/arm/domain_build.c | 10 ++++++---- xen/arch/arm/include/asm/kernel.h | 23 +++++++++++++++++++++-- 3 files changed, 31 insertions(+), 6 deletions(-)docs/misc/arm/device-tree/booting.txt +0
-0
docs/misc/arm/device-tree/booting.txt with the following properties: · line 209
Quoted 6 lines
docs/misc/arm/device-tree/booting.txt +3
-0@@ -204,6 +204,10 @@ with the following properties: - "disabled" Xen PV interfaces are disabled. + - no-xenstore + Xen PV interfaces, including grant-table will be enabled but xenstore + will be disabled for the VM.
Please use "" for consistency:
- "no-xenstore"
Quoted 71 lines
docs/misc/arm/device-tree/booting.txt +0
-0If the xen,enhanced property is present with no value, it defaults to "enabled". If the xen,enhanced property is not present, PV interfaces are disabled.xen/arch/arm/domain_build.c +6
-4@@ -2891,7 +2891,7 @@ static int __init prepare_dtb_domU(struct domain *d, struct kernel_info *kinfo) goto err; } -if ( kinfo->dom0less_enhanced ) +if ( kinfo->dom0less_feature &DOM0LESS_ENHANCED_NO_XS ) { ret =make_hypervisor_node (d, kinfo, addrcells, sizecells);if ( ret )@@ -3209,10 +3209,12 @@ static int __init construct_domU(struct domain *d, (rc == 0 && !strcmp(dom0less_enhanced, "enabled")) ) {if ( hardware_domain ) - kinfo.dom0less_enhanced = true; + kinfo.dom0less_feature =DOM0LESS_ENHANCED ;else -panic ("Tried to use xen,enhanced without dom0\n" ); +panic ("At the moment, Xenstore support requires dom0 to be present\n" ); } + else if ( rc == 0 && !strcmp(dom0less_enhanced, "no-xenstore") ) + kinfo.dom0less_feature =DOM0LESS_ENHANCED_NO_XS ;if (vcpu_create (d,0 ) ==NULL )return -ENOMEM ;@@ -3252,7 +3254,7 @@ static int __init construct_domU(struct domain *d,if ( rc <0 )return rc; -if ( kinfo.dom0less_enhanced ) +if ( kinfo.dom0less_feature &DOM0LESS_XENSTORE ) {ASSERT (hardware_domain); rc =alloc_xenstore_evtchn (d);xen/arch/arm/include/asm/kernel.h +19
-0@@ -9,6 +9,25 @@#include <xen/device_tree.h> #include <asm/setup.h> +/* +* List of possible features for dom0less domUs +* +* DOM0LESS_ENHANCED_NO_XS: Notify the OS it is running on top of Xen. All the +* default features (excluding Xenstore) will be +* available. Note that an OS *must* not rely on the +* availability of Xen features if this is not set. +* DOM0LESS_XENSTORE: Xenstore will be enabled for the VM. This feature +* can't be enabled without the +* DOM0LESS_ENHANCED_NO_XS. +* DOM0LESS_ENHANCED: Notify the OS it is running on top of Xen. All the +* default features (including Xenstore) will be +* available. Note that an OS *must* not rely on the +* availability of Xen features if this is not set. +*/ +#define DOM0LESS_ENHANCED_NO_XS BIT(0, U) +#define DOM0LESS_XENSTORE BIT(1, U) +#define DOM0LESS_ENHANCED (DOM0LESS_ENHANCED_NO_XS | DOM0LESS_XENSTORE) +struct kernel_info {#ifdef CONFIG_ARM_64 enum domain_type type;
xen/arch/arm/include/asm/kernel.h struct kernel_info { · line 58
Quoted 6 lines
xen/arch/arm/include/asm/kernel.h +1
-2@@ -36,8 +55,8 @@ struct kernel_info {/* Enable pl011 emulation */ bool vpl011; -/* Enable PV drivers */ -bool dom0less_enhanced; +/* Enable/Disable PV drivers interface,grant table, evtchn or xenstore */
missing a whitespace
xen/arch/arm/include/asm/kernel.h struct kernel_info { · line 59
Quoted 1 line
xen/arch/arm/include/asm/kernel.h +1
-0+uint32_t dom0less_feature;
Given that we only really need 2 bits today, and given that uint8_t and uint16_t are free but uint32_t increases the size of the struct, could we just use uint16_t dom0less_feature ?
Everything else looks good, these are just minor things.
Quoted 5 lines
xen/arch/arm/include/asm/kernel.h +0
-0/* GIC phandle */ uint32_t phandle_gic;Signature · 1 line
2.25.1
Re: [PATCH v4 6/7] xen/arm: introduce new xen,enhanced property value
Hi Stefano,
Quoted 26 lines · Stefano Stabellini
Quoted 23 lines · Rahul Singh
Introduce a new "xen,enhanced" dom0less property value "no-xenstore" to disable xenstore interface for dom0less guests.
Signed-off-by Rahul Singh <[email protected]>---
Changes in v4:
- Implement defines for dom0less features
Changes in v3:
- new patch in this version
---docs/misc/arm/device-tree/booting.txt | 4 ++++ xen/arch/arm/domain_build.c | 10 ++++++---- xen/arch/arm/include/asm/kernel.h | 23 +++++++++++++++++++++-- 3 files changed, 31 insertions(+), 6 deletions(-)docs/misc/arm/device-tree/booting.txt +0
-0@@ -204,6 +204,10 @@ with the following properties: - "disabled" Xen PV interfaces are disabled.
Quoted 8 lines
docs/misc/arm/device-tree/booting.txt with the following properties: · line 209
Quoted 3 lines
docs/misc/arm/device-tree/booting.txt +3
-0+ - no-xenstore + Xen PV interfaces, including grant-table will be enabled but xenstore + will be disabled for the VM.Please use "" for consistency:
- "no-xenstore"
Ack.
Quoted 75 lines
Quoted 75 lines
docs/misc/arm/device-tree/booting.txt +0
-0If the xen,enhanced property is present with no value, it defaults to "enabled". If the xen,enhanced property is not present, PV interfaces are disabled.xen/arch/arm/domain_build.c +6
-4@@ -2891,7 +2891,7 @@ static int __init prepare_dtb_domU(struct domain *d, struct kernel_info *kinfo) goto err; } -if ( kinfo->dom0less_enhanced ) +if ( kinfo->dom0less_feature &DOM0LESS_ENHANCED_NO_XS ) { ret =make_hypervisor_node (d, kinfo, addrcells, sizecells);if ( ret )@@ -3209,10 +3209,12 @@ static int __init construct_domU(struct domain *d, (rc == 0 && !strcmp(dom0less_enhanced, "enabled")) ) {if ( hardware_domain ) - kinfo.dom0less_enhanced = true; + kinfo.dom0less_feature =DOM0LESS_ENHANCED ;else -panic ("Tried to use xen,enhanced without dom0\n" ); +panic ("At the moment, Xenstore support requires dom0 to be present\n" ); } + else if ( rc == 0 && !strcmp(dom0less_enhanced, "no-xenstore") ) + kinfo.dom0less_feature =DOM0LESS_ENHANCED_NO_XS ;if (vcpu_create (d,0 ) ==NULL )return -ENOMEM ;@@ -3252,7 +3254,7 @@ static int __init construct_domU(struct domain *d,if ( rc <0 )return rc; -if ( kinfo.dom0less_enhanced ) +if ( kinfo.dom0less_feature &DOM0LESS_XENSTORE ) {ASSERT (hardware_domain); rc =alloc_xenstore_evtchn (d);xen/arch/arm/include/asm/kernel.h +19
-0@@ -9,6 +9,25 @@#include <xen/device_tree.h> #include <asm/setup.h> +/* +* List of possible features for dom0less domUs +* +* DOM0LESS_ENHANCED_NO_XS: Notify the OS it is running on top of Xen. All the +* default features (excluding Xenstore) will be +* available. Note that an OS *must* not rely on the +* availability of Xen features if this is not set. +* DOM0LESS_XENSTORE: Xenstore will be enabled for the VM. This feature +* can't be enabled without the +* DOM0LESS_ENHANCED_NO_XS. +* DOM0LESS_ENHANCED: Notify the OS it is running on top of Xen. All the +* default features (including Xenstore) will be +* available. Note that an OS *must* not rely on the +* availability of Xen features if this is not set. +*/ +#define DOM0LESS_ENHANCED_NO_XS BIT(0, U) +#define DOM0LESS_XENSTORE BIT(1, U) +#define DOM0LESS_ENHANCED (DOM0LESS_ENHANCED_NO_XS | DOM0LESS_XENSTORE) +struct kernel_info {#ifdef CONFIG_ARM_64 enum domain_type type;@@ -36,8 +55,8 @@ struct kernel_info {/* Enable pl011 emulation */ bool vpl011;
Quoted 5 lines
xen/arch/arm/include/asm/kernel.h struct kernel_info { · line 58
Quoted 3 lines
xen/arch/arm/include/asm/kernel.h +1
-2-/* Enable PV drivers */ -bool dom0less_enhanced; +/* Enable/Disable PV drivers interface,grant table, evtchn or xenstore */ missing a whitespace
Ack.
Quoted 7 lines
xen/arch/arm/include/asm/kernel.h struct kernel_info { · line 59
Quoted 3 lines
xen/arch/arm/include/asm/kernel.h +1
-0+uint32_t dom0less_feature;Given that we only really need 2 bits today, and given that
uint8_tanduint16_tare free butuint32_tincreases the size of the struct, could we just useuint16_tdom0less_feature?
Yes, I will change to uint16_t in next version.
Regards,
Rahul
Re: [PATCH v4 6/7] xen/arm: introduce new xen,enhanced property value
In reply to Rahul SinghHi Rahul
Quoted 20 lines · Rahul Singh
Introduce a new "xen,enhanced" dom0less property value "no-xenstore" to disable xenstore interface for dom0less guests.
Signed-off-by Rahul Singh <[email protected]>---
Changes in v4:
- Implement defines for dom0less features
Changes in v3:
- new patch in this version--- docs/misc/arm/device-tree/booting.txt | 4 ++++ xen/arch/arm/domain_build.c | 10 ++++++---- xen/arch/arm/include/asm/kernel.h | 23 +++++++++++++++++++++-- 3 files changed, 31 insertions(+), 6 deletions(-)docs/misc/arm/device-tree/booting.txt +0
-0
docs/misc/arm/device-tree/booting.txt with the following properties: · line 208
Quoted 5 lines
docs/misc/arm/device-tree/booting.txt +2
-0@@ -204,6 +204,10 @@ with the following properties: - "disabled" Xen PV interfaces are disabled. + - no-xenstore + Xen PV interfaces, including grant-table will be enabled but xenstore
Please use "All default" in front. So it is clear that everything is enabled but xenstore.
Quoted 73 lines
docs/misc/arm/device-tree/booting.txt +2
-0+ will be disabled for the VM. + If the xen,enhanced property is present with no value, it defaults to "enabled". If the xen,enhanced property is not present, PV interfaces are disabled.xen/arch/arm/domain_build.c +6
-4@@ -2891,7 +2891,7 @@ static int __init prepare_dtb_domU(struct domain *d, struct kernel_info *kinfo) goto err; } -if ( kinfo->dom0less_enhanced ) +if ( kinfo->dom0less_feature &DOM0LESS_ENHANCED_NO_XS ) { ret =make_hypervisor_node (d, kinfo, addrcells, sizecells);if ( ret )@@ -3209,10 +3209,12 @@ static int __init construct_domU(struct domain *d, (rc == 0 && !strcmp(dom0less_enhanced, "enabled")) ) {if ( hardware_domain ) - kinfo.dom0less_enhanced = true; + kinfo.dom0less_feature =DOM0LESS_ENHANCED ;else -panic ("Tried to use xen,enhanced without dom0\n" ); +panic ("At the moment, Xenstore support requires dom0 to be present\n" ); } + else if ( rc == 0 && !strcmp(dom0less_enhanced, "no-xenstore") ) + kinfo.dom0less_feature =DOM0LESS_ENHANCED_NO_XS ;if (vcpu_create (d,0 ) ==NULL )return -ENOMEM ;@@ -3252,7 +3254,7 @@ static int __init construct_domU(struct domain *d,if ( rc <0 )return rc; -if ( kinfo.dom0less_enhanced ) +if ( kinfo.dom0less_feature &DOM0LESS_XENSTORE ) {ASSERT (hardware_domain); rc =alloc_xenstore_evtchn (d);xen/arch/arm/include/asm/kernel.h +19
-0@@ -9,6 +9,25 @@#include <xen/device_tree.h> #include <asm/setup.h> +/* +* List of possible features for dom0less domUs +* +* DOM0LESS_ENHANCED_NO_XS: Notify the OS it is running on top of Xen. All the +* default features (excluding Xenstore) will be +* available. Note that an OS *must* not rely on the +* availability of Xen features if this is not set. +* DOM0LESS_XENSTORE: Xenstore will be enabled for the VM. This feature +* can't be enabled without the +* DOM0LESS_ENHANCED_NO_XS. +* DOM0LESS_ENHANCED: Notify the OS it is running on top of Xen. All the +* default features (including Xenstore) will be +* available. Note that an OS *must* not rely on the +* availability of Xen features if this is not set. +*/ +#define DOM0LESS_ENHANCED_NO_XS BIT(0, U) +#define DOM0LESS_XENSTORE BIT(1, U) +#define DOM0LESS_ENHANCED (DOM0LESS_ENHANCED_NO_XS | DOM0LESS_XENSTORE) +struct kernel_info {#ifdef CONFIG_ARM_64 enum domain_type type;
xen/arch/arm/include/asm/kernel.h struct kernel_info { · line 58
Quoted 6 lines
xen/arch/arm/include/asm/kernel.h +1
-2@@ -36,8 +55,8 @@ struct kernel_info {/* Enable pl011 emulation */ bool vpl011; -/* Enable PV drivers */ -bool dom0less_enhanced; +/* Enable/Disable PV drivers interface,grant table, evtchn or xenstore */
The part after "," is technically wrong because it also affects other interfaces. But I would drop it to avoid any stale comment (we may add new one in the futures).
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v4 6/7] xen/arm: introduce new xen,enhanced property value
Hi Julien,
Quoted 21 lines · Julien Grall
Hi Rahul
Quoted 16 lines · Rahul Singh
Introduce a new "xen,enhanced" dom0less property value "no-xenstore" to disable xenstore interface for dom0less guests.
Signed-off-by Rahul Singh <[email protected]>---
Changes in v4:
- Implement defines for dom0less features
Changes in v3:
- new patch in this version--- docs/misc/arm/device-tree/booting.txt | 4 ++++ xen/arch/arm/domain_build.c | 10 ++++++---- xen/arch/arm/include/asm/kernel.h | 23 +++++++++++++++++++++-- 3 files changed, 31 insertions(+), 6 deletions(-)docs/misc/arm/device-tree/booting.txt +0
-1--- a/docs/misc/arm/device-tree/booting.txt
Quoted 8 lines
docs/misc/arm/device-tree/booting.txt with the following properties: · line 207
Quoted 6 lines
+++
b/docs/misc/arm/device-tree/booting.txtdocs/misc/arm/device-tree/booting.txt +1
-0@@ -204,6 +204,10 @@ with the following properties: - "disabled" Xen PV interfaces are disabled. + - no-xenstore + Xen PV interfaces, including grant-table will be enabled but xenstorePlease use "All default" in front. So it is clear that everything is enabled but xenstore.
Ack.
Quoted 69 lines
Quoted 69 lines
docs/misc/arm/device-tree/booting.txt +2
-0+ will be disabled for the VM. + If the xen,enhanced property is present with no value, it defaults to "enabled". If the xen,enhanced property is not present, PV interfaces are disabled.xen/arch/arm/domain_build.c +6
-2@@ -2891,7 +2891,7 @@ static int __init prepare_dtb_domU(struct domain *d, struct kernel_info *kinfo) goto err; } - if ( kinfo->dom0less_enhanced ) +if ( kinfo->dom0less_feature &DOM0LESS_ENHANCED_NO_XS ) { ret =make_hypervisor_node (d, kinfo, addrcells, sizecells);if ( ret )@@ -3209,10 +3209,12 @@ static int __init construct_domU(struct domain *d, (rc == 0 && !strcmp(dom0less_enhanced, "enabled")) ) {if ( hardware_domain ) - kinfo.dom0less_enhanced = true; + kinfo.dom0less_feature =DOM0LESS_ENHANCED ;else -panic ("Tried to use xen,enhanced without dom0\n" ); +panic ("At the moment, Xenstore support requires dom0 to be present\n" ); } + else if ( rc == 0 && !strcmp(dom0less_enhanced, "no-xenstore") ) + kinfo.dom0less_feature =DOM0LESS_ENHANCED_NO_XS ;if (vcpu_create (d,0 ) ==NULL )return -ENOMEM ;@@ -3252,7 +3254,7 @@ static int __init construct_domU(struct domain *d,if ( rc <0 )return rc; - if ( kinfo.dom0less_enhanced ) +if ( kinfo.dom0less_feature &DOM0LESS_XENSTORE ) {ASSERT (hardware_domain); rc =alloc_xenstore_evtchn (d);xen/arch/arm/include/asm/kernel.h +18
-0@@ -9,6 +9,25 @@#include <xen/device_tree.h> #include <asm/setup.h> +/* +* List of possible features for dom0less domUs +* +* DOM0LESS_ENHANCED_NO_XS: Notify the OS it is running on top of Xen. All the +* default features (excluding Xenstore) will be +* available. Note that an OS *must* not rely on the +* availability of Xen features if this is not set. +* DOM0LESS_XENSTORE: Xenstore will be enabled for the VM. This feature +* can't be enabled without the +* DOM0LESS_ENHANCED_NO_XS. +* DOM0LESS_ENHANCED: Notify the OS it is running on top of Xen. All the +* default features (including Xenstore) will be +* available. Note that an OS *must* not rely on the +* availability of Xen features if this is not set. +*/ +#define DOM0LESS_ENHANCED_NO_XS BIT(0, U) +#define DOM0LESS_XENSTORE BIT(1, U) +#define DOM0LESS_ENHANCED (DOM0LESS_ENHANCED_NO_XS | DOM0LESS_XENSTORE) +struct kernel_info {#ifdef CONFIG_ARM_64 enum domain_type type;
Quoted 8 lines
xen/arch/arm/include/asm/kernel.h struct kernel_info { · line 58
Quoted 6 lines
xen/arch/arm/include/asm/kernel.h +1
-1@@ -36,8 +55,8 @@ struct kernel_info {/* Enable pl011 emulation */ bool vpl011; - /* Enable PV drivers */ - bool dom0less_enhanced; +/* Enable/Disable PV drivers interface,grant table, evtchn or xenstore */ The part after "," is technically wrong because it also affects other interfaces. But I would drop it to avoid any stale comment (we may add new one in the futures).
Ok . I will remove and will comment like this:
/* Enable/Disable PV drivers interfaces */
Regards,
Rahul
PATCH v4 7/7 xen/arm: introduce xen-evtchn dom0less property
In reply to Rahul SinghIntroduce a new sub-node under /chosen node to establish static event channel communication between domains on dom0less systems.
An event channel will be created beforehand to allow the domains to send notifications to each other.
---
Changes in v4:
- move documentation to common place for evtchn node in booting.txt
- Add comment why we use dt_device_static_evtchn_created()
- check if dt_get_parent() returns NULL
- fold process_static_evtchn_node() in alloc_static_evtchn()
Changes in v3:
- use device-tree used_by to find the domain id of the evtchn node.
- add new static_evtchn_create variable in struct dt_device_node to hold the information if evtchn is already created.
- fix minor comments
Changes in v2:
- no change
--- docs/misc/arm/device-tree/booting.txt | 98 +++++++++++++++++ xen/arch/arm/domain_build.c | 147 ++++++++++++++++++++++++++ xen/arch/arm/include/asm/setup.h | 1 + xen/arch/arm/setup.c | 2 + xen/include/xen/device_tree.h | 16 +++ 5 files changed, 264 insertions(+)
docs/misc/arm/device-tree/booting.txt +98 -0
@@ -382,3 +382,101 @@ device-tree: This will reserve a 512MB region starting at the host physical address 0x30000000 to be exclusively used by DomU1. + +Static Event Channel +==================== +The event channel communication will be established statically between two +domains (dom0 and domU also). Event channel connection information between +domains will be passed to Xen via the device tree node. The event channel +will be created and established in Xen before the domain started. The domain +doesn’t need to do any operation to establish a connection. Domain only +needs hypercall EVTCHNOP_send(local port) to send notifications to the +remote guest. + +There is no need to describe the static event channel info in the domU device +tree. Static event channels are only useful in fully static configurations, +and in those configurations, the domU device tree dynamically generated by Xen +is not needed. + +To enable the event-channel interface for domU guests include the +"xen,enhanced = "no-xenstore"" property in the domU Xen device tree node. + +Under the "xen,domain" compatible node for domU, there needs to be sub-nodes +with compatible "xen,evtchn" that describe the event channel connection +between two domUs. For dom0, there needs to be sub-nodes with compatible +"xen,evtchn" under the chosen node. + +The static event channel node has the following properties: + +- compatible + + "xen,evtchn" + +- xen,evtchn + + The property is tuples of two numbers + (local-evtchn link-to-foreign-evtchn) where: + + local-evtchn is an integer value that will be used to allocate local port + for a domain to send and receive event notifications to/from the remote + domain. Maximum supported value is 2^17 for FIFO ABI and 4096 for 2L ABI. + It is recommended to use low event channel IDs. + + link-to-foreign-evtchn is a single phandle to a remote evtchn to which + local-evtchn will be connected. + +Example +======= + +chosen { + + /* one sub-node per local event channel */ + ec1: evtchn@1 { + compatible = "xen,evtchn-v1"; + /* local-evtchn link-to-foreign-evtchn */ + xen,evtchn = <0xa &ec2>; + }; + + domU1 { + compatible = "xen,domain"; + #address-cells = <0x2>; + #size-cells = <0x1>; + xen,enhanced = "no-xenstore"; + + /* one sub-node per local event channel */ + ec2: evtchn@2 { + compatible = "xen,evtchn-v1"; + /* local-evtchn link-to-foreign-evtchn */ + xen,evtchn = <0xa &ec1>; + }; + + ec3: evtchn@3 { + compatible = "xen,evtchn-v1"; + xen,evtchn = <0xb &ec5>; + }; + + ec4: evtchn@4 { + compatible = "xen,evtchn-v1"; + xen,evtchn = <0xc &ec6>; + }; + }; + + domU2 { + compatible = "xen,domain"; + #address-cells = <0x2>; + #size-cells = <0x1>; + xen,enhanced = "no-xenstore"; + + /* one sub-node per local event channel */ + ec5: evtchn@5 { + compatible = "xen,evtchn-v1"; + /* local-evtchn link-to-foreign-evtchn */ + xen,evtchn = <0xb &ec3>; + }; + + ec6: evtchn@6 { + compatible = "xen,evtchn-v1"; + xen,evtchn = <0xd &ec4>; + }; + }; +};
xen/arch/arm/domain_build.c +147 -0
165 lines not on this page · raw message
xen/arch/arm/include/asm/setup.h +1 -0
@@ -106,6 +106,7 @@ int acpi_make_efi_nodes(void *fdt, struct membank tbl_add[]);void create_domUs (void );void create_dom0 (void ); +void alloc_static_evtchn (void );void discard_initial_modules (void ); void fw_unreserved_regions(paddr_t s, paddr_t e,
xen/arch/arm/setup.c +2 -0
@@ -1077,6 +1077,8 @@ void __init start_xen(unsigned long boot_phys_offset,if ( acpi_disabled )create_domUs (); +alloc_static_evtchn (); +/* * This needs to be called **before** heap_init_late() so modules * will be scrubbed (unless suppressed).
xen/include/xen/device_tree.h +16 -0
@@ -92,6 +92,10 @@ struct dt_device_node {/* IOMMU specific fields */ bool is_protected; + +/* HACK: Remove this if there is a need of space */ +bool_t static_evtchn_created; +/* * The main purpose of this list is to link the structure in the list * of devices assigned to domain.
@@ -317,6 +321,18 @@ static inline bool_t dt_property_name_is_equal(const struct dt_property *pp,return !dt_prop_cmp (pp->name, name); } +static inline void +dt_device_set_static_evtchn_created (struct dt_device_node *device) +{ + device->static_evtchn_created = true; +} + +static inline bool_t +dt_device_static_evtchn_created (const struct dt_device_node *device) +{ +return device->static_evtchn_created; +} +/** * dt_find_compatible_node - Find a node based on type and one of the * tokens in its "compatible" property
Signature · 1 line
2.25.1
Re: [PATCH v4 7/7] xen/arm: introduce xen-evtchn dom0less property
Quoted 20 lines · Rahul Singh
Introduce a new sub-node under /chosen node to establish static event channel communication between domains on dom0less systems.
An event channel will be created beforehand to allow the domains to send notifications to each other.
Signed-off-by Rahul Singh <[email protected]>---
Changes in v4:
- move documentation to common place for evtchn node in booting.txt
- Add comment why we usedt_device_static_evtchn_created()
- check ifdt_get_parent()returns NULL
- foldprocess_static_evtchn_node()inalloc_static_evtchn()
Changes in v3:
- use device-treeused_byto find the domain id of the evtchn node.
- add newstatic_evtchn_createvariable in structdt_device_nodeto hold the information if evtchn is already created.
- fix minor comments
Changes in v2:
- no change
Quoted 2 lines
--- docs/misc/arm/device-tree/booting.txt | 98 +++++++++++++++++
I have just reviewed the binding, only three minor comments below. Everything looks good.
Quoted 12 lines
xen/arch/arm/domain_build.c | 147 ++++++++++++++++++++++++++ xen/arch/arm/include/asm/setup.h | 1 + xen/arch/arm/setup.c | 2 + xen/include/xen/device_tree.h | 16 +++ 5 files changed, 264 insertions(+)docs/misc/arm/device-tree/booting.txt +0
-0@@ -382,3 +382,101 @@ device-tree:
docs/misc/arm/device-tree/booting.txt device-tree: · line 392
Quoted 10 lines
docs/misc/arm/device-tree/booting.txt +8
-0This will reserve a 512MB region starting at the host physical address 0x30000000 to be exclusively used by DomU1. + +Static Event Channel +==================== +The event channel communication will be established statically between two +domains (dom0 and domU also). Event channel connection information between +domains will be passed to Xen via the device tree node. The event channel +will be created and established in Xen before the domain started. The domain +doesn???t need to do any operation to establish a connection. Domain only
doesn't
better to use ASCII if possible
docs/misc/arm/device-tree/booting.txt device-tree: · line 402
Quoted 10 lines
docs/misc/arm/device-tree/booting.txt +10
-0+needs hypercall EVTCHNOP_send(local port) to send notifications to the +remote guest. + +There is no need to describe the static event channel info in the domU device +tree. Static event channels are only useful in fully static configurations, +and in those configurations, the domU device tree dynamically generated by Xen +is not needed. + +To enable the event-channel interface for domU guests include the +"xen,enhanced = "no-xenstore"" property in the domU Xen device tree node.
double ""
Quoted 21 lines
docs/misc/arm/device-tree/booting.txt +21
-0+ +Under the "xen,domain" compatible node for domU, there needs to be sub-nodes +with compatible "xen,evtchn" that describe the event channel connection +between two domUs. For dom0, there needs to be sub-nodes with compatible +"xen,evtchn" under the chosen node. + +The static event channel node has the following properties: + +- compatible + + "xen,evtchn" + +- xen,evtchn + + The property is tuples of two numbers + (local-evtchn link-to-foreign-evtchn) where: + + local-evtchn is an integer value that will be used to allocate local port + for a domain to send and receive event notifications to/from the remote + domain. Maximum supported value is 2^17 for FIFO ABI and 4096 for 2L ABI. + It is recommended to use low event channel IDs.
docs/misc/arm/device-tree/booting.txt device-tree: · line 433
Quoted 10 lines
docs/misc/arm/device-tree/booting.txt +10
-0+ + link-to-foreign-evtchn is a single phandle to a remote evtchn to which + local-evtchn will be connected. + +Example +======= + +chosen { + + /* one sub-node per local event channel */
It would be good to say that this is for dom0 in the comment, e.g.:
/* this is for Dom0 */
Quoted 49 lines
docs/misc/arm/device-tree/booting.txt +49
-0+ ec1: evtchn@1 { + compatible = "xen,evtchn-v1"; + /* local-evtchn link-to-foreign-evtchn */ + xen,evtchn = <0xa &ec2>; + }; + + domU1 { + compatible = "xen,domain"; + #address-cells = <0x2>; + #size-cells = <0x1>; + xen,enhanced = "no-xenstore"; + + /* one sub-node per local event channel */ + ec2: evtchn@2 { + compatible = "xen,evtchn-v1"; + /* local-evtchn link-to-foreign-evtchn */ + xen,evtchn = <0xa &ec1>; + }; + + ec3: evtchn@3 { + compatible = "xen,evtchn-v1"; + xen,evtchn = <0xb &ec5>; + }; + + ec4: evtchn@4 { + compatible = "xen,evtchn-v1"; + xen,evtchn = <0xc &ec6>; + }; + }; + + domU2 { + compatible = "xen,domain"; + #address-cells = <0x2>; + #size-cells = <0x1>; + xen,enhanced = "no-xenstore"; + + /* one sub-node per local event channel */ + ec5: evtchn@5 { + compatible = "xen,evtchn-v1"; + /* local-evtchn link-to-foreign-evtchn */ + xen,evtchn = <0xb &ec3>; + }; + + ec6: evtchn@6 { + compatible = "xen,evtchn-v1"; + xen,evtchn = <0xd &ec4>; + }; + }; +};
Re: [PATCH v4 7/7] xen/arm: introduce xen-evtchn dom0less property
Hi Stefano,
Quoted 26 lines · Stefano Stabellini
Quoted 7 lines · Rahul Singh
Introduce a new sub-node under /chosen node to establish static event channel communication between domains on dom0less systems.
An event channel will be created beforehand to allow the domains to send notifications to each other.
Signed-off-by Rahul Singh <[email protected]>Quoted 15 lines
---
Changes in v4:
- move documentation to common place for evtchn node in booting.txt
- Add comment why we usedt_device_static_evtchn_created()
- check ifdt_get_parent()returns NULL
- foldprocess_static_evtchn_node()inalloc_static_evtchn()Changes in v3:
- use device-treeused_byto find the domain id of the evtchn node.
- add newstatic_evtchn_createvariable in structdt_device_nodeto hold the information if evtchn is already created.
- fix minor comments
Changes in v2:
- no change
---docs/misc/arm/device-tree/booting.txt| 98 +++++++++++++++++
Quoted 2 lines
I have just reviewed the binding, only three minor comments below. Everything looks good.
Thanks for reviewing the code.
Quoted 27 lines
Quoted 16 lines
xen/arch/arm/domain_build.c | 147 ++++++++++++++++++++++++++ xen/arch/arm/include/asm/setup.h | 1 + xen/arch/arm/setup.c | 2 + xen/include/xen/device_tree.h | 16 +++ 5 files changed, 264 insertions(+)docs/misc/arm/device-tree/booting.txt +0
-0@@ -382,3 +382,101 @@ device-tree:This will reserve a 512MB region starting at the host physical address
0x30000000to be exclusively used by DomU1.docs/misc/arm/device-tree/booting.txt device-tree:
Quoted 8 lines
docs/misc/arm/device-tree/booting.txt +8
-0+ +Static Event Channel +==================== +The event channel communication will be established statically between two +domains (dom0 and domU also). Event channel connection information between +domains will be passed to Xen via the device tree node. The event channel +will be created and established in Xen before the domain started. The domain +doesn???t need to do any operation to establish a connection. Domain onlydoesn't
Quoted 1 line
better to use ASCII if possible
Ack.
Quoted 14 lines
docs/misc/arm/device-tree/booting.txt device-tree: · line 402
Quoted 12 lines
docs/misc/arm/device-tree/booting.txt +10
-0+needs hypercall EVTCHNOP_send(local port) to send notifications to the +remote guest. + +There is no need to describe the static event channel info in the domU device +tree. Static event channels are only useful in fully static configurations, +and in those configurations, the domU device tree dynamically generated by Xen +is not needed. + +To enable the event-channel interface for domU guests include the +"xen,enhanced = "no-xenstore"" property in the domU Xen device tree node.double ""
Ack.
Quoted 36 lines
Quoted 23 lines
docs/misc/arm/device-tree/booting.txt +21
-0+ +Under the "xen,domain" compatible node for domU, there needs to be sub-nodes +with compatible "xen,evtchn" that describe the event channel connection +between two domUs. For dom0, there needs to be sub-nodes with compatible +"xen,evtchn" under the chosen node. + +The static event channel node has the following properties: + +- compatible + + "xen,evtchn" + +- xen,evtchn + + The property is tuples of two numbers + (local-evtchn link-to-foreign-evtchn) where: + + local-evtchn is an integer value that will be used to allocate local port + for a domain to send and receive event notifications to/from the remote + domain. Maximum supported value is 2^17 for FIFO ABI and 4096 for 2L ABI. + It is recommended to use low event channel IDs.docs/misc/arm/device-tree/booting.txt device-tree: · line 433
Quoted 10 lines
docs/misc/arm/device-tree/booting.txt +10
-0+ + link-to-foreign-evtchn is a single phandle to a remote evtchn to which + local-evtchn will be connected. + +Example +======= + +chosen { + + /* one sub-node per local event channel */It would be good to say that this is for dom0 in the comment, e.g.:
Quoted 1 line
/* this is for Dom0 */
Ack.
Regards,
Rahul