Message ID | 20220113005855.1180101-3-sstabellini@kernel.org (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | dom0less PV drivers | expand |
Hi Stefano, + Penny in CC for the question. > On 13 Jan 2022, at 00:58, Stefano Stabellini <sstabellini@kernel.org> wrote: > > From: Luca Miccio <lucmiccio@gmail.com> > > If "xen,enhanced" is enabled, then add to dom0less domains: > > - the hypervisor node in device tree > - the xenstore event channel > > The xenstore event channel is also used for the first notification to > let the guest know that xenstore has become available. > > Signed-off-by: Luca Miccio <lucmiccio@gmail.com> > Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com> > CC: Julien Grall <julien@xen.org> > CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com> > CC: Bertrand Marquis <bertrand.marquis@arm.com> Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com> Just one question: GUEST_GNTTAB_BASE is fixed but could it be a problem for a direct map guest in the future ? Regards Bertrand > > --- > Changes in v2: > - set HVM_PARAM_STORE_PFN to ~0ULL at domain creation > - in alloc_xenstore_evtchn do not call _evtchn_alloc_unbound > --- > xen/arch/arm/domain_build.c | 43 +++++++++++++++++++++++++++++++++++++ > 1 file changed, 43 insertions(+) > > diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c > index 9144d6c0b6..251d933c8e 100644 > --- a/xen/arch/arm/domain_build.c > +++ b/xen/arch/arm/domain_build.c > @@ -27,6 +27,7 @@ > #include <asm/setup.h> > #include <asm/cpufeature.h> > #include <asm/domain_build.h> > +#include <xen/event.h> > > #include <xen/irq.h> > #include <xen/grant_table.h> > @@ -2619,6 +2620,8 @@ static int __init prepare_dtb_domU(struct domain *d, struct kernel_info *kinfo) > int ret; > > kinfo->phandle_gic = GUEST_PHANDLE_GIC; > + kinfo->gnttab_start = GUEST_GNTTAB_BASE; > + kinfo->gnttab_size = GUEST_GNTTAB_SIZE; > > addrcells = GUEST_ROOT_ADDRESS_CELLS; > sizecells = GUEST_ROOT_SIZE_CELLS; > @@ -2693,6 +2696,13 @@ static int __init prepare_dtb_domU(struct domain *d, struct kernel_info *kinfo) > goto err; > } > > + if ( kinfo->dom0less_enhanced ) > + { > + ret = make_hypervisor_node(d, kinfo, addrcells, sizecells); > + if ( ret ) > + goto err; > + } > + > ret = fdt_end_node(kinfo->fdt); > if ( ret < 0 ) > goto err; > @@ -2959,6 +2969,27 @@ static int __init construct_domain(struct domain *d, struct kernel_info *kinfo) > return 0; > } > > +static int __init alloc_xenstore_evtchn(struct domain *d) > +{ > + struct evtchn *chn; > + int port; > + > + if ( (port = get_free_port(d)) < 0 ) > + { > + printk("Failed allocating event channel for domain\n"); > + return port; > + } > + chn = evtchn_from_port(d, port); > + > + chn->state = ECS_UNBOUND; > + chn->u.unbound.remote_domid = hardware_domain->domain_id; > + evtchn_port_init(d, chn); > + > + d->arch.hvm.params[HVM_PARAM_STORE_EVTCHN] = chn->port; > + > + return 0; > +} > + > static int __init construct_domU(struct domain *d, > const struct dt_device_node *node) > { > @@ -3014,7 +3045,19 @@ static int __init construct_domU(struct domain *d, > return rc; > > if ( kinfo.vpl011 ) > + { > rc = domain_vpl011_init(d, NULL); > + if ( rc < 0 ) > + return rc; > + } > + > + if ( kinfo.dom0less_enhanced ) > + { > + rc = alloc_xenstore_evtchn(d); > + if ( rc < 0 ) > + return rc; > + d->arch.hvm.params[HVM_PARAM_STORE_PFN] = ~0ULL; > + } > > return rc; > } > -- > 2.25.1 >
Hi, On 13/01/2022 14:15, Bertrand Marquis wrote: > Hi Stefano, > > + Penny in CC for the question. > >> On 13 Jan 2022, at 00:58, Stefano Stabellini <sstabellini@kernel.org> wrote: >> >> From: Luca Miccio <lucmiccio@gmail.com> >> >> If "xen,enhanced" is enabled, then add to dom0less domains: >> >> - the hypervisor node in device tree >> - the xenstore event channel >> >> The xenstore event channel is also used for the first notification to >> let the guest know that xenstore has become available. >> >> Signed-off-by: Luca Miccio <lucmiccio@gmail.com> >> Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com> >> CC: Julien Grall <julien@xen.org> >> CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com> >> CC: Bertrand Marquis <bertrand.marquis@arm.com> > > Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com> > > Just one question: GUEST_GNTTAB_BASE is fixed but could it be a problem for a direct map guest in the future ? It will be an issue. I think we can re-use the same method as we do in dom0 (see find_gnttab_region()). Cheers,
On Sun, 23 Jan 2022, Julien Grall wrote: > On 13/01/2022 14:15, Bertrand Marquis wrote: > > Hi Stefano, > > > > + Penny in CC for the question. > > > > > On 13 Jan 2022, at 00:58, Stefano Stabellini <sstabellini@kernel.org> > > > wrote: > > > > > > From: Luca Miccio <lucmiccio@gmail.com> > > > > > > If "xen,enhanced" is enabled, then add to dom0less domains: > > > > > > - the hypervisor node in device tree > > > - the xenstore event channel > > > > > > The xenstore event channel is also used for the first notification to > > > let the guest know that xenstore has become available. > > > > > > Signed-off-by: Luca Miccio <lucmiccio@gmail.com> > > > Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com> > > > CC: Julien Grall <julien@xen.org> > > > CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com> > > > CC: Bertrand Marquis <bertrand.marquis@arm.com> > > > > Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com> > > > > Just one question: GUEST_GNTTAB_BASE is fixed but could it be a problem for > > a direct map guest in the future ? > It will be an issue. I think we can re-use the same method as we do in dom0 > (see find_gnttab_region()). Good idea. I prototyped it and it works fine. I am not going to add the patch to this series because it needs Penny's but I can easily provide a patch to her for it.
diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 9144d6c0b6..251d933c8e 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -27,6 +27,7 @@ #include <asm/setup.h> #include <asm/cpufeature.h> #include <asm/domain_build.h> +#include <xen/event.h> #include <xen/irq.h> #include <xen/grant_table.h> @@ -2619,6 +2620,8 @@ static int __init prepare_dtb_domU(struct domain *d, struct kernel_info *kinfo) int ret; kinfo->phandle_gic = GUEST_PHANDLE_GIC; + kinfo->gnttab_start = GUEST_GNTTAB_BASE; + kinfo->gnttab_size = GUEST_GNTTAB_SIZE; addrcells = GUEST_ROOT_ADDRESS_CELLS; sizecells = GUEST_ROOT_SIZE_CELLS; @@ -2693,6 +2696,13 @@ static int __init prepare_dtb_domU(struct domain *d, struct kernel_info *kinfo) goto err; } + if ( kinfo->dom0less_enhanced ) + { + ret = make_hypervisor_node(d, kinfo, addrcells, sizecells); + if ( ret ) + goto err; + } + ret = fdt_end_node(kinfo->fdt); if ( ret < 0 ) goto err; @@ -2959,6 +2969,27 @@ static int __init construct_domain(struct domain *d, struct kernel_info *kinfo) return 0; } +static int __init alloc_xenstore_evtchn(struct domain *d) +{ + struct evtchn *chn; + int port; + + if ( (port = get_free_port(d)) < 0 ) + { + printk("Failed allocating event channel for domain\n"); + return port; + } + chn = evtchn_from_port(d, port); + + chn->state = ECS_UNBOUND; + chn->u.unbound.remote_domid = hardware_domain->domain_id; + evtchn_port_init(d, chn); + + d->arch.hvm.params[HVM_PARAM_STORE_EVTCHN] = chn->port; + + return 0; +} + static int __init construct_domU(struct domain *d, const struct dt_device_node *node) { @@ -3014,7 +3045,19 @@ static int __init construct_domU(struct domain *d, return rc; if ( kinfo.vpl011 ) + { rc = domain_vpl011_init(d, NULL); + if ( rc < 0 ) + return rc; + } + + if ( kinfo.dom0less_enhanced ) + { + rc = alloc_xenstore_evtchn(d); + if ( rc < 0 ) + return rc; + d->arch.hvm.params[HVM_PARAM_STORE_PFN] = ~0ULL; + } return rc; }