From: Ian Campbell Subject: Re: [RFC PATCH v2 1/3] arch, arm: allow dom0 access to I/O memory of mapped devices Date: Thu, 13 Mar 2014 15:27:34 +0000 Message-ID: <1394724454.25873.102.camel@kazak.uk.xensource.com> References: <1394439953-5723-1-git-send-email-avanzini.arianna@gmail.com> <1394439953-5723-2-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: <1394439953-5723-2-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 Cc: paolo.valente@unimore.it, stefano.stabellini@eu.citrix.com, dario.faggioli@citrix.com, Ian.Jackson@eu.citrix.com, xen-devel@lists.xen.org, julien.grall@citrix.com, etrudeau@broadcom.com, viktor.kleinik@globallogic.com List-Id: xen-devel@lists.xenproject.org On Mon, 2014-03-10 at 09:25 +0100, Arianna Avanzini wrote: > Currently, dom0 is not allowed access to the I/O memory ranges > used to access devices exposed to it. This commit attempts > to give it access to those memory ranges during domain build > by adding the ranges to dom0's iomem_caps. Just to make sure I've got it straight: Strictly speaking dom0 is allowed this access, because we unconditionally create the required mappings. What this commit changes is to make sure that the bookkeeping actually reflects that reality. > Signed-off-by: Arianna Avanzini > Cc: Dario Faggioli > Cc: Paolo Valente > Cc: Stefano Stabellini > Cc: Julien Grall With Julien's comment addressed please add: Acked-by: Ian Campbell > Cc: Ian Jackson > Cc: Eric Trudeau > Cc: Viktor Kleinik > --- > xen/arch/arm/domain_build.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c > index 5ca2f15..0b283d8 100644 > --- a/xen/arch/arm/domain_build.c > +++ b/xen/arch/arm/domain_build.c > @@ -11,6 +11,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -733,6 +734,15 @@ static int map_device(struct domain *d, const struct dt_device_node *dev) > DPRINT("addr %u = 0x%"PRIx64" - 0x%"PRIx64"\n", > i, addr, addr + size - 1); > > + res = iomem_permit_access(d, paddr_to_pfn(addr & PAGE_MASK), > + paddr_to_pfn(PAGE_ALIGN(addr + size - 1))); > + if ( res ) > + { > + printk(XENLOG_ERR "Unable to permit to dom0 access to" > + " 0x%"PRIx64" - 0x%"PRIx64"\n", > + addr & PAGE_MASK, PAGE_ALIGN(addr + size) - 1); Not your fault but I wonder why we are using u64 here for addr and friends and not paddr_t. > + return res; > + } > res = map_mmio_regions(d, addr & PAGE_MASK, > PAGE_ALIGN(addr + size) - 1, > addr & PAGE_MASK);