Hi , > On 13 Jul 2022, at 1:29 pm, Julien Grall <jul...@xen.org> wrote: > > > > On 13/07/2022 13:12, Bertrand Marquis wrote: >>> On 13 Jul 2022, at 12:31, Julien Grall <jul...@xen.org> wrote: >>>> I can't >>>> see why it would be wrong to have a more tight limit on static ports >>>> than on traditional ("dynamic") ones. Even if only to make sure so >>>> many dynamic ones are left. >>> >>> This is similar to Xen forbidding to close a static port: it is not the >>> hypervisor business to check that there are enough event channel ports >>> freed for dynamic allocation. >> On other side we need to be cautious not to add too much complexity in the >> code by trying to make things always magically work. >> If you want Xen to be accessible to non expert by magically working all the >> time, there would be a lot of work to do. > > It is not clear to me whether you are referring to a developper or admin here. > > On the admin side, we need to make sure they have an easy way to configure > event channels. One knob is always going to easier than two knobs. > > On the developper side, this could be resolved by better documentation in the > code/interface. > > Cheers,
To conclude the discussion, If everyone agree I will add the below patch or similar in the next version to restrict the max number of evtchn supported as suggested. diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 532e50e321..a8c5825a4f 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -3422,7 +3422,7 @@ 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, + .max_evtchn_port = MAX_EVTCHNS_PORT, .max_grant_frames = -1, .max_maptrack_frames = -1, .grant_opts = XEN_DOMCTL_GRANT_version(opt_gnttab_max_version), @@ -3582,7 +3582,7 @@ void __init create_dom0(void) struct domain *dom0; struct xen_domctl_createdomain dom0_cfg = { .flags = XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap, - .max_evtchn_port = -1, + .max_evtchn_port = MAX_EVTCHNS_PORT, .max_grant_frames = gnttab_dom0_frames(), .max_maptrack_frames = -1, .grant_opts = XEN_DOMCTL_GRANT_version(opt_gnttab_max_version), diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index f08b07b8de..b1f95fbe1a 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -763,7 +763,7 @@ static struct domain *__init create_dom0(const module_t *image, { struct xen_domctl_createdomain dom0_cfg = { .flags = IS_ENABLED(CONFIG_TBOOT) ? XEN_DOMCTL_CDF_s3_integrity : 0, - .max_evtchn_port = -1, + .max_evtchn_port = MAX_EVTCHNS_PORT, .max_grant_frames = -1, .max_maptrack_frames = -1, .grant_opts = XEN_DOMCTL_GRANT_version(opt_gnttab_max_version), diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index d6c029020f..783359f733 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -76,6 +76,8 @@ extern domid_t hardware_domid; /* Maximum number of event channels for any ABI. */ #define MAX_NR_EVTCHNS MAX(EVTCHN_2L_NR_CHANNELS, EVTCHN_FIFO_NR_CHANNELS) +#define MAX_EVTCHNS_PORT 4096 + #define EVTCHNS_PER_BUCKET (PAGE_SIZE / next_power_of_2(sizeof(struct evtchn))) #define EVTCHNS_PER_GROUP (BUCKETS_PER_GROUP * EVTCHNS_PER_BUCKET) #define NR_EVTCHN_GROUPS DIV_ROUND_UP(MAX_NR_EVTCHNS, EVTCHNS_PER_GROUP Regards, Rahul