From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Grall Subject: Re: [PATCH RESEND v9 11/14] tools/libxl: handle the iomem parameter with the memory_mapping hcall Date: Thu, 24 Jul 2014 15:12:20 +0100 Message-ID: <53D11444.3040206@linaro.org> References: <53BFEBFB.1090602@linaro.org> <1405299035-2988-1-git-send-email-avanzini.arianna@gmail.com> <1405299035-2988-12-git-send-email-avanzini.arianna@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1405299035-2988-12-git-send-email-avanzini.arianna@gmail.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Arianna Avanzini , xen-devel@lists.xen.org Cc: julien.grall@citrix.com, paolo.valente@unimore.it, keir@xen.org, stefano.stabellini@eu.citrix.com, tim@xen.org, dario.faggioli@citrix.com, Ian.Jackson@eu.citrix.com, Ian.Campbell@eu.citrix.com, etrudeau@broadcom.com, JBeulich@suse.com, andrew.cooper3@citrix.com, viktor.kleinik@globallogic.com List-Id: xen-devel@lists.xenproject.org Hi Arianna, On 07/14/2014 01:50 AM, Arianna Avanzini wrote: > Currently, the configuration-parsing code concerning the handling of the > iomem parameter only invokes the XEN_DOMCTL_iomem_permission hypercall. > This commit lets the XEN_DOMCTL_memory_mapping hypercall be invoked > after XEN_DOMCTL_iomem_permission when the iomem parameter is parsed > from a domU configuration file, so that the address range can be mapped > to the address space of the domU. The hypercall is invoked only in case > of domains using an auto-translated physmap. > > Signed-off-by: Arianna Avanzini > Acked-by: Ian Campbell Acked-by: Julien Grall Regards, > Cc: Dario Faggioli > Cc: Paolo Valente > Cc: Stefano Stabellini > Cc: Julien Grall > Cc: Jan Beulich > Cc: Keir Fraser > Cc: Tim Deegan > Cc: Ian Jackson > Cc: Andrew Cooper > Cc: Eric Trudeau > Cc: Viktor Kleinik > > --- > > v9: > - Enforce checks on return value of xc_domain_getinfo() as it could > return information concerning the wrong domain. > - Don't use PERROR for xc_core_* functions. > - Avoid emitting an error message if xc_core_auto_translated_physmap() > fails. > > v8: > - Fix wrong error message emitted when the memory_mapping DOMCTL is > called by a domain that is not auto-translated. > > v7: > - Move the check for an auto-translated physmap to xc to avoid having > to expose the information to libxl. > > v4: > - Let the hypercall be called only in case the guest uses an > auto-translated physmap. > > v3: > - Add ifdefs to let the hypercall be called only by ARM or x86 > HVM guests, with a whitelist approach. > - Remove the NOTE comment. > > v2: > - Add a comment explaining outstanding issues. > > --- > tools/libxc/xc_domain.c | 10 ++++++++++ > tools/libxl/libxl_create.c | 11 +++++++++++ > 2 files changed, 21 insertions(+) > > diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c > index 0230c6c..27fe3b6 100644 > --- a/tools/libxc/xc_domain.c > +++ b/tools/libxc/xc_domain.c > @@ -1959,6 +1959,16 @@ int xc_domain_memory_mapping( > uint32_t add_mapping) > { > DECLARE_DOMCTL; > + xc_dominfo_t info; > + > + if ( xc_domain_getinfo(xch, domid, 1, &info) != 1 || > + info.domid != domid ) > + { > + PERROR("Could not get info for domain"); > + return -EINVAL; > + } > + if ( !xc_core_arch_auto_translated_physmap(&info) ) > + return 0; > > domctl.cmd = XEN_DOMCTL_memory_mapping; > domctl.domain = domid; > diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c > index 3bfe65b..1217310 100644 > --- a/tools/libxl/libxl_create.c > +++ b/tools/libxl/libxl_create.c > @@ -1158,6 +1158,17 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev, > "failed give dom%d access to iomem range %"PRIx64"-%"PRIx64, > domid, io->start, io->start + io->number - 1); > ret = ERROR_FAIL; > + continue; > + } > + ret = xc_domain_memory_mapping(CTX->xch, domid, > + io->gfn, io->start, > + io->number, 1); > + if (ret < 0) { > + LOGE(ERROR, > + "failed to map to dom%d iomem range %"PRIx64"-%"PRIx64 > + " to guest address %"PRIx64, > + domid, io->start, io->start + io->number - 1, io->gfn); > + ret = ERROR_FAIL; > } > } > > -- Julien Grall