All of lore.kernel.org
 help / color / mirror / Atom feed
* ARM: access to iomem and HW IRQ
@ 2014-02-26 15:43 Viktor Kleinik
  2014-02-27 10:14 ` Dario Faggioli
  0 siblings, 1 reply; 10+ messages in thread
From: Viktor Kleinik @ 2014-02-26 15:43 UTC (permalink / raw)
  To: xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 249 bytes --]

Hi all,

Does anyone knows something about future plans to implement
xc_domain_memory_mapping/XEN_DOMCTL_memory_mapping and
xc_physdev_map_pirq/PHYSDEVOP_map_pirq calls for ARM?

Is their implementation expected in the near future?

Regards,
Victor

[-- Attachment #1.2: Type: text/html, Size: 324 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: ARM: access to iomem and HW IRQ
  2014-02-26 15:43 ARM: access to iomem and HW IRQ Viktor Kleinik
@ 2014-02-27 10:14 ` Dario Faggioli
  2014-02-27 13:15   ` Stefano Stabellini
  0 siblings, 1 reply; 10+ messages in thread
From: Dario Faggioli @ 2014-02-27 10:14 UTC (permalink / raw)
  To: Viktor Kleinik
  Cc: Julien Grall, Arianna Avanzini, Stefano Stabellini, xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 713 bytes --]

On mer, 2014-02-26 at 15:43 +0000, Viktor Kleinik wrote:
> Hi all,
> 
Hi,

> Does anyone knows something about future plans to implement
> xc_domain_memory_mapping/XEN_DOMCTL_memory_mapping and
> xc_physdev_map_pirq/PHYSDEVOP_map_pirq calls for ARM?
>
I think Arianna is working on an implementation of the former
(XEN_DOMCTL_memory_mapping), and she should be sending patches to this
list soon, isn't it so, Arianna?

Regards,
Dario

-- 
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)


[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: ARM: access to iomem and HW IRQ
  2014-02-27 10:14 ` Dario Faggioli
@ 2014-02-27 13:15   ` Stefano Stabellini
  2014-02-27 14:11     ` Eric Trudeau
  0 siblings, 1 reply; 10+ messages in thread
From: Stefano Stabellini @ 2014-02-27 13:15 UTC (permalink / raw)
  To: Dario Faggioli
  Cc: Stefano Stabellini, xen-devel, Julien Grall, etrudeau,
	Arianna Avanzini, Viktor Kleinik

On Thu, 27 Feb 2014, Dario Faggioli wrote:
> On mer, 2014-02-26 at 15:43 +0000, Viktor Kleinik wrote:
> > Hi all,
> > 
> Hi,
> 
> > Does anyone knows something about future plans to implement
> > xc_domain_memory_mapping/XEN_DOMCTL_memory_mapping and
> > xc_physdev_map_pirq/PHYSDEVOP_map_pirq calls for ARM?
> >
> I think Arianna is working on an implementation of the former
> (XEN_DOMCTL_memory_mapping), and she should be sending patches to this
> list soon, isn't it so, Arianna?

Eric Trudeau did some work in the area too:

http://marc.info/?l=xen-devel&m=137338996422503
http://marc.info/?l=xen-devel&m=137365750318936

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: ARM: access to iomem and HW IRQ
  2014-02-27 13:15   ` Stefano Stabellini
@ 2014-02-27 14:11     ` Eric Trudeau
  2014-02-27 17:11       ` Viktor Kleinik
  0 siblings, 1 reply; 10+ messages in thread
From: Eric Trudeau @ 2014-02-27 14:11 UTC (permalink / raw)
  To: Stefano Stabellini, Dario Faggioli
  Cc: Julien Grall, Arianna Avanzini, Viktor Kleinik, xen-devel

> -----Original Message-----
> From: Stefano Stabellini [mailto:stefano.stabellini@eu.citrix.com]
> Sent: Thursday, February 27, 2014 8:16 AM
> To: Dario Faggioli
> Cc: Viktor Kleinik; xen-devel@lists.xen.org; Arianna Avanzini; Stefano Stabellini;
> Julien Grall; Eric Trudeau
> Subject: Re: [Xen-devel] ARM: access to iomem and HW IRQ
> 
> On Thu, 27 Feb 2014, Dario Faggioli wrote:
> > On mer, 2014-02-26 at 15:43 +0000, Viktor Kleinik wrote:
> > > Hi all,
> > >
> > Hi,
> >
> > > Does anyone knows something about future plans to implement
> > > xc_domain_memory_mapping/XEN_DOMCTL_memory_mapping and
> > > xc_physdev_map_pirq/PHYSDEVOP_map_pirq calls for ARM?
> > >
> > I think Arianna is working on an implementation of the former
> > (XEN_DOMCTL_memory_mapping), and she should be sending patches to this
> > list soon, isn't it so, Arianna?
> 
> Eric Trudeau did some work in the area too:
> 
> http://marc.info/?l=xen-devel&m=137338996422503
> http://marc.info/?l=xen-devel&m=137365750318936

I checked our repo and the route IRQ changes to DomUs in the second patch URL Stefano provided below are up-to-date with what we have been using on our platforms.  We made no further changes after that patch, i.e. we left the 100 msec max wait for a domain to finish an ISR when destroying it.

We also added support for a DomU to map in I/O memory with the iomem configuration parameter.  Unfortunately, I don't have time to provide an official patch on recent Xen upstream code due to time constraints, but below is a patch based on last October, :( , commit d70d87d2ccf93e3d5302bb034c0a1ae1d6fc1d29.
I hope this is helpful, because that is the best I can do at this time.

-----------------

tools/libxl/libxl_create.c |  5 +++--
 xen/arch/arm/domctl.c      | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 76 insertions(+), 3 deletions(-)

diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index 1b320d3..53ed52e 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -976,8 +976,9 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev,
         LOG(DEBUG, "dom%d iomem %"PRIx64"-%"PRIx64,
             domid, io->start, io->start + io->number - 1);
 
-        ret = xc_domain_iomem_permission(CTX->xch, domid,
-                                          io->start, io->number, 1);
+        ret = xc_domain_memory_mapping(CTX->xch, domid,
+                                       io->start, io->start,
+                                       io->number, 1);
         if (ret < 0) {
             LOGE(ERROR,
                  "failed give dom%d access to iomem range %"PRIx64"-%"PRIx64,
diff --git a/xen/arch/arm/domctl.c b/xen/arch/arm/domctl.c
index 851ee40..222aac9 100644
--- a/xen/arch/arm/domctl.c
+++ b/xen/arch/arm/domctl.c
@@ -10,11 +10,83 @@
 #include <xen/errno.h>
 #include <xen/sched.h>
 #include <public/domctl.h>
+#include <xen/iocap.h>
+#include <xsm/xsm.h>
+#include <xen/paging.h>
+#include <xen/guest_access.h>
 
 long arch_do_domctl(struct xen_domctl *domctl, struct domain *d,
                     XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
 {
-    return -ENOSYS;
+    long ret = 0;
+    bool_t copyback = 0;
+
+    switch ( domctl->cmd )
+    {
+    case XEN_DOMCTL_memory_mapping:
+    {
+        unsigned long gfn = domctl->u.memory_mapping.first_gfn;
+        unsigned long mfn = domctl->u.memory_mapping.first_mfn;
+        unsigned long nr_mfns = domctl->u.memory_mapping.nr_mfns;
+        int add = domctl->u.memory_mapping.add_mapping;
+
+        /* removing i/o memory is not implemented yet */
+        if (!add) {
+            ret = -ENOSYS;
+            break;
+        }
+        ret = -EINVAL;
+        if ( (mfn + nr_mfns - 1) < mfn || /* wrap? */
+             /* x86 checks wrap based on paddr_bits which is not implemented on ARM? */
+             /* ((mfn | (mfn + nr_mfns - 1)) >> (paddr_bits - PAGE_SHIFT)) || */
+             (gfn + nr_mfns - 1) < gfn ) /* wrap? */
+            break;
+
+        ret = -EPERM;
+        if ( current->domain->domain_id != 0 )
+            break;
+
+        ret = xsm_iomem_mapping(XSM_HOOK, d, mfn, mfn + nr_mfns - 1, add);
+        if ( ret )
+            break;
+
+        if ( add )
+        {
+            printk(XENLOG_G_INFO
+                   "memory_map:add: dom%d gfn=%lx mfn=%lx nr=%lx\n",
+                   d->domain_id, gfn, mfn, nr_mfns);
+
+            ret = iomem_permit_access(d, mfn, mfn + nr_mfns - 1);
+            if ( !ret && paging_mode_translate(d) )
+            {
+                ret = map_mmio_regions(d, gfn << PAGE_SHIFT,
+                                       (gfn + nr_mfns) << PAGE_SHIFT,
+                                       mfn << PAGE_SHIFT);
+                if ( ret )
+                {
+                    printk(XENLOG_G_WARNING
+                           "memory_map:fail: dom%d gfn=%lx mfn=%lx nr=%lx\n",
+                           d->domain_id, gfn, mfn, nr_mfns);
+                    if ( iomem_deny_access(d, mfn, mfn + nr_mfns - 1) &&
+                         is_hardware_domain(current->domain) )
+                        printk(XENLOG_ERR
+                               "memory_map: failed to deny dom%d access to [%lx,%lx]\n",
+                               d->domain_id, mfn, mfn + nr_mfns - 1);
+                }
+            }
+        }
+    }
+    break;
+
+    default:
+        ret = -ENOSYS;
+        break;
+    }
+
+    if ( copyback && __copy_to_guest(u_domctl, domctl, 1) )
+        ret = -EFAULT;
+
+    return ret;
 }
 
 void arch_get_info_guest(struct vcpu *v, vcpu_guest_context_u c)

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: ARM: access to iomem and HW IRQ
  2014-02-27 14:11     ` Eric Trudeau
@ 2014-02-27 17:11       ` Viktor Kleinik
  2014-02-27 23:03         ` Eric Trudeau
  0 siblings, 1 reply; 10+ messages in thread
From: Viktor Kleinik @ 2014-02-27 17:11 UTC (permalink / raw)
  To: Eric Trudeau
  Cc: Julien Grall, Dario Faggioli, xen-devel, Arianna Avanzini,
	Stefano Stabellini


[-- Attachment #1.1: Type: text/plain, Size: 6364 bytes --]

Thank you all for your responses.

I will try those changes on our platform.
Are you planning push the implementation of
xc_domain_memory_mapping/XEN_DOMCTL_memory_mapping and
xc_physdev_map_pirq/PHYSDEVOP_map_pirq hypercalls into
official Xen release?

Regards,
Victor


On Thu, Feb 27, 2014 at 2:11 PM, Eric Trudeau <etrudeau@broadcom.com> wrote:

> > -----Original Message-----
> > From: Stefano Stabellini [mailto:stefano.stabellini@eu.citrix.com]
> > Sent: Thursday, February 27, 2014 8:16 AM
> > To: Dario Faggioli
> > Cc: Viktor Kleinik; xen-devel@lists.xen.org; Arianna Avanzini; Stefano
> Stabellini;
> > Julien Grall; Eric Trudeau
> > Subject: Re: [Xen-devel] ARM: access to iomem and HW IRQ
> >
> > On Thu, 27 Feb 2014, Dario Faggioli wrote:
> > > On mer, 2014-02-26 at 15:43 +0000, Viktor Kleinik wrote:
> > > > Hi all,
> > > >
> > > Hi,
> > >
> > > > Does anyone knows something about future plans to implement
> > > > xc_domain_memory_mapping/XEN_DOMCTL_memory_mapping and
> > > > xc_physdev_map_pirq/PHYSDEVOP_map_pirq calls for ARM?
> > > >
> > > I think Arianna is working on an implementation of the former
> > > (XEN_DOMCTL_memory_mapping), and she should be sending patches to this
> > > list soon, isn't it so, Arianna?
> >
> > Eric Trudeau did some work in the area too:
> >
> > http://marc.info/?l=xen-devel&m=137338996422503
> > http://marc.info/?l=xen-devel&m=137365750318936
>
> I checked our repo and the route IRQ changes to DomUs in the second patch
> URL Stefano provided below are up-to-date with what we have been using on
> our platforms.  We made no further changes after that patch, i.e. we left
> the 100 msec max wait for a domain to finish an ISR when destroying it.
>
> We also added support for a DomU to map in I/O memory with the iomem
> configuration parameter.  Unfortunately, I don't have time to provide an
> official patch on recent Xen upstream code due to time constraints, but
> below is a patch based on last October, :( , commit
> d70d87d2ccf93e3d5302bb034c0a1ae1d6fc1d29.
> I hope this is helpful, because that is the best I can do at this time.
>
> -----------------
>
> tools/libxl/libxl_create.c |  5 +++--
>  xen/arch/arm/domctl.c      | 74
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>  2 files changed, 76 insertions(+), 3 deletions(-)
>
> diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
> index 1b320d3..53ed52e 100644
> --- a/tools/libxl/libxl_create.c
> +++ b/tools/libxl/libxl_create.c
> @@ -976,8 +976,9 @@ static void domcreate_launch_dm(libxl__egc *egc,
> libxl__multidev *multidev,
>          LOG(DEBUG, "dom%d iomem %"PRIx64"-%"PRIx64,
>              domid, io->start, io->start + io->number - 1);
>
> -        ret = xc_domain_iomem_permission(CTX->xch, domid,
> -                                          io->start, io->number, 1);
> +        ret = xc_domain_memory_mapping(CTX->xch, domid,
> +                                       io->start, io->start,
> +                                       io->number, 1);
>          if (ret < 0) {
>              LOGE(ERROR,
>                   "failed give dom%d access to iomem range
> %"PRIx64"-%"PRIx64,
> diff --git a/xen/arch/arm/domctl.c b/xen/arch/arm/domctl.c
> index 851ee40..222aac9 100644
> --- a/xen/arch/arm/domctl.c
> +++ b/xen/arch/arm/domctl.c
> @@ -10,11 +10,83 @@
>  #include <xen/errno.h>
>  #include <xen/sched.h>
>  #include <public/domctl.h>
> +#include <xen/iocap.h>
> +#include <xsm/xsm.h>
> +#include <xen/paging.h>
> +#include <xen/guest_access.h>
>
>  long arch_do_domctl(struct xen_domctl *domctl, struct domain *d,
>                      XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
>  {
> -    return -ENOSYS;
> +    long ret = 0;
> +    bool_t copyback = 0;
> +
> +    switch ( domctl->cmd )
> +    {
> +    case XEN_DOMCTL_memory_mapping:
> +    {
> +        unsigned long gfn = domctl->u.memory_mapping.first_gfn;
> +        unsigned long mfn = domctl->u.memory_mapping.first_mfn;
> +        unsigned long nr_mfns = domctl->u.memory_mapping.nr_mfns;
> +        int add = domctl->u.memory_mapping.add_mapping;
> +
> +        /* removing i/o memory is not implemented yet */
> +        if (!add) {
> +            ret = -ENOSYS;
> +            break;
> +        }
> +        ret = -EINVAL;
> +        if ( (mfn + nr_mfns - 1) < mfn || /* wrap? */
> +             /* x86 checks wrap based on paddr_bits which is not
> implemented on ARM? */
> +             /* ((mfn | (mfn + nr_mfns - 1)) >> (paddr_bits -
> PAGE_SHIFT)) || */
> +             (gfn + nr_mfns - 1) < gfn ) /* wrap? */
> +            break;
> +
> +        ret = -EPERM;
> +        if ( current->domain->domain_id != 0 )
> +            break;
> +
> +        ret = xsm_iomem_mapping(XSM_HOOK, d, mfn, mfn + nr_mfns - 1, add);
> +        if ( ret )
> +            break;
> +
> +        if ( add )
> +        {
> +            printk(XENLOG_G_INFO
> +                   "memory_map:add: dom%d gfn=%lx mfn=%lx nr=%lx\n",
> +                   d->domain_id, gfn, mfn, nr_mfns);
> +
> +            ret = iomem_permit_access(d, mfn, mfn + nr_mfns - 1);
> +            if ( !ret && paging_mode_translate(d) )
> +            {
> +                ret = map_mmio_regions(d, gfn << PAGE_SHIFT,
> +                                       (gfn + nr_mfns) << PAGE_SHIFT,
> +                                       mfn << PAGE_SHIFT);
> +                if ( ret )
> +                {
> +                    printk(XENLOG_G_WARNING
> +                           "memory_map:fail: dom%d gfn=%lx mfn=%lx
> nr=%lx\n",
> +                           d->domain_id, gfn, mfn, nr_mfns);
> +                    if ( iomem_deny_access(d, mfn, mfn + nr_mfns - 1) &&
> +                         is_hardware_domain(current->domain) )
> +                        printk(XENLOG_ERR
> +                               "memory_map: failed to deny dom%d access
> to [%lx,%lx]\n",
> +                               d->domain_id, mfn, mfn + nr_mfns - 1);
> +                }
> +            }
> +        }
> +    }
> +    break;
> +
> +    default:
> +        ret = -ENOSYS;
> +        break;
> +    }
> +
> +    if ( copyback && __copy_to_guest(u_domctl, domctl, 1) )
> +        ret = -EFAULT;
> +
> +    return ret;
>  }
>
>  void arch_get_info_guest(struct vcpu *v, vcpu_guest_context_u c)
>
<http://www.globallogic.com/email_disclaimer.txt>

[-- Attachment #1.2: Type: text/html, Size: 8336 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: ARM: access to iomem and HW IRQ
  2014-02-27 17:11       ` Viktor Kleinik
@ 2014-02-27 23:03         ` Eric Trudeau
  2014-02-27 23:39           ` R: " Dario Faggioli
  0 siblings, 1 reply; 10+ messages in thread
From: Eric Trudeau @ 2014-02-27 23:03 UTC (permalink / raw)
  To: Viktor Kleinik
  Cc: Julien Grall, Dario Faggioli, xen-devel, Arianna Avanzini,
	Stefano Stabellini


[-- Attachment #1.1: Type: text/plain, Size: 6523 bytes --]


On Feb 27, 2014, at 1:10 PM, "Viktor Kleinik" <viktor.kleinik@globallogic.com<mailto:viktor.kleinik@globallogic.com>> wrote:

Thank you all for your responses.

I will try those changes on our platform.
Are you planning push the implementation of
xc_domain_memory_mapping/XEN_DOMCTL_memory_mapping and
xc_physdev_map_pirq/PHYSDEVOP_map_pirq hypercalls into
official Xen release?

Regards,
Victor

I don't expect to push the changes up. If you want to submit, please go ahead.

On Thu, Feb 27, 2014 at 2:11 PM, Eric Trudeau <etrudeau@broadcom.com<mailto:etrudeau@broadcom.com>> wrote:
> -----Original Message-----
> From: Stefano Stabellini [mailto:stefano.stabellini@eu.citrix.com<mailto:stefano.stabellini@eu.citrix.com>]
> Sent: Thursday, February 27, 2014 8:16 AM
> To: Dario Faggioli
> Cc: Viktor Kleinik; xen-devel@lists.xen.org<mailto:xen-devel@lists.xen.org>; Arianna Avanzini; Stefano Stabellini;
> Julien Grall; Eric Trudeau
> Subject: Re: [Xen-devel] ARM: access to iomem and HW IRQ
>
> On Thu, 27 Feb 2014, Dario Faggioli wrote:
> > On mer, 2014-02-26 at 15:43 +0000, Viktor Kleinik wrote:
> > > Hi all,
> > >
> > Hi,
> >
> > > Does anyone knows something about future plans to implement
> > > xc_domain_memory_mapping/XEN_DOMCTL_memory_mapping and
> > > xc_physdev_map_pirq/PHYSDEVOP_map_pirq calls for ARM?
> > >
> > I think Arianna is working on an implementation of the former
> > (XEN_DOMCTL_memory_mapping), and she should be sending patches to this
> > list soon, isn't it so, Arianna?
>
> Eric Trudeau did some work in the area too:
>
> http://marc.info/?l=xen-devel&m=137338996422503
> http://marc.info/?l=xen-devel&m=137365750318936

I checked our repo and the route IRQ changes to DomUs in the second patch URL Stefano provided below are up-to-date with what we have been using on our platforms.  We made no further changes after that patch, i.e. we left the 100 msec max wait for a domain to finish an ISR when destroying it.

We also added support for a DomU to map in I/O memory with the iomem configuration parameter.  Unfortunately, I don't have time to provide an official patch on recent Xen upstream code due to time constraints, but below is a patch based on last October, :( , commit d70d87d2ccf93e3d5302bb034c0a1ae1d6fc1d29.
I hope this is helpful, because that is the best I can do at this time.

-----------------

tools/libxl/libxl_create.c |  5 +++--
 xen/arch/arm/domctl.c      | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 76 insertions(+), 3 deletions(-)

diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index 1b320d3..53ed52e 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -976,8 +976,9 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev,
         LOG(DEBUG, "dom%d iomem %"PRIx64"-%"PRIx64,
             domid, io->start, io->start + io->number - 1);

-        ret = xc_domain_iomem_permission(CTX->xch, domid,
-                                          io->start, io->number, 1);
+        ret = xc_domain_memory_mapping(CTX->xch, domid,
+                                       io->start, io->start,
+                                       io->number, 1);
         if (ret < 0) {
             LOGE(ERROR,
                  "failed give dom%d access to iomem range %"PRIx64"-%"PRIx64,
diff --git a/xen/arch/arm/domctl.c b/xen/arch/arm/domctl.c
index 851ee40..222aac9 100644
--- a/xen/arch/arm/domctl.c
+++ b/xen/arch/arm/domctl.c
@@ -10,11 +10,83 @@
 #include <xen/errno.h>
 #include <xen/sched.h>
 #include <public/domctl.h>
+#include <xen/iocap.h>
+#include <xsm/xsm.h>
+#include <xen/paging.h>
+#include <xen/guest_access.h>

 long arch_do_domctl(struct xen_domctl *domctl, struct domain *d,
                     XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
 {
-    return -ENOSYS;
+    long ret = 0;
+    bool_t copyback = 0;
+
+    switch ( domctl->cmd )
+    {
+    case XEN_DOMCTL_memory_mapping:
+    {
+        unsigned long gfn = domctl->u.memory_mapping.first_gfn;
+        unsigned long mfn = domctl->u.memory_mapping.first_mfn;
+        unsigned long nr_mfns = domctl->u.memory_mapping.nr_mfns;
+        int add = domctl->u.memory_mapping.add_mapping;
+
+        /* removing i/o memory is not implemented yet */
+        if (!add) {
+            ret = -ENOSYS;
+            break;
+        }
+        ret = -EINVAL;
+        if ( (mfn + nr_mfns - 1) < mfn || /* wrap? */
+             /* x86 checks wrap based on paddr_bits which is not implemented on ARM? */
+             /* ((mfn | (mfn + nr_mfns - 1)) >> (paddr_bits - PAGE_SHIFT)) || */
+             (gfn + nr_mfns - 1) < gfn ) /* wrap? */
+            break;
+
+        ret = -EPERM;
+        if ( current->domain->domain_id != 0 )
+            break;
+
+        ret = xsm_iomem_mapping(XSM_HOOK, d, mfn, mfn + nr_mfns - 1, add);
+        if ( ret )
+            break;
+
+        if ( add )
+        {
+            printk(XENLOG_G_INFO
+                   "memory_map:add: dom%d gfn=%lx mfn=%lx nr=%lx\n",
+                   d->domain_id, gfn, mfn, nr_mfns);
+
+            ret = iomem_permit_access(d, mfn, mfn + nr_mfns - 1);
+            if ( !ret && paging_mode_translate(d) )
+            {
+                ret = map_mmio_regions(d, gfn << PAGE_SHIFT,
+                                       (gfn + nr_mfns) << PAGE_SHIFT,
+                                       mfn << PAGE_SHIFT);
+                if ( ret )
+                {
+                    printk(XENLOG_G_WARNING
+                           "memory_map:fail: dom%d gfn=%lx mfn=%lx nr=%lx\n",
+                           d->domain_id, gfn, mfn, nr_mfns);
+                    if ( iomem_deny_access(d, mfn, mfn + nr_mfns - 1) &&
+                         is_hardware_domain(current->domain) )
+                        printk(XENLOG_ERR
+                               "memory_map: failed to deny dom%d access to [%lx,%lx]\n",
+                               d->domain_id, mfn, mfn + nr_mfns - 1);
+                }
+            }
+        }
+    }
+    break;
+
+    default:
+        ret = -ENOSYS;
+        break;
+    }
+
+    if ( copyback && __copy_to_guest(u_domctl, domctl, 1) )
+        ret = -EFAULT;
+
+    return ret;
 }

 void arch_get_info_guest(struct vcpu *v, vcpu_guest_context_u c)
<http://www.globallogic.com/email_disclaimer.txt>

[-- Attachment #1.2: Type: text/html, Size: 12144 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* R:  ARM: access to iomem and HW IRQ
  2014-02-27 23:03         ` Eric Trudeau
@ 2014-02-27 23:39           ` Dario Faggioli
  2014-02-28  0:24             ` Arianna Avanzini
  0 siblings, 1 reply; 10+ messages in thread
From: Dario Faggioli @ 2014-02-27 23:39 UTC (permalink / raw)
  To: Eric Trudeau, Viktor Kleinik
  Cc: Julien Grall, Arianna Avanzini, Stefano Stabellini, xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 7005 bytes --]

As I said, Arianna is doing something very similar... perhaps she can merge her and your work and try to upstream it properly, in the next few days... Arianna?

Regards,
Dario


Inviato da Samsung Mobile


-------- Messaggio originale --------
Da: Eric Trudeau
Data:28/02/2014 00:03 (GMT+01:00)
A: Viktor Kleinik
Cc: Stefano Stabellini ,Dario Faggioli ,xen-devel@lists.xen.org,Arianna Avanzini ,Julien Grall
Oggetto: Re: [Xen-devel] ARM: access to iomem and HW IRQ


On Feb 27, 2014, at 1:10 PM, "Viktor Kleinik" <viktor.kleinik@globallogic.com<mailto:viktor.kleinik@globallogic.com>> wrote:

Thank you all for your responses.

I will try those changes on our platform.
Are you planning push the implementation of
xc_domain_memory_mapping/XEN_DOMCTL_memory_mapping and
xc_physdev_map_pirq/PHYSDEVOP_map_pirq hypercalls into
official Xen release?

Regards,
Victor

I don't expect to push the changes up. If you want to submit, please go ahead.

On Thu, Feb 27, 2014 at 2:11 PM, Eric Trudeau <etrudeau@broadcom.com<mailto:etrudeau@broadcom.com>> wrote:
> -----Original Message-----
> From: Stefano Stabellini [mailto:stefano.stabellini@eu.citrix.com<mailto:stefano.stabellini@eu.citrix.com>]
> Sent: Thursday, February 27, 2014 8:16 AM
> To: Dario Faggioli
> Cc: Viktor Kleinik; xen-devel@lists.xen.org<mailto:xen-devel@lists.xen.org>; Arianna Avanzini; Stefano Stabellini;
> Julien Grall; Eric Trudeau
> Subject: Re: [Xen-devel] ARM: access to iomem and HW IRQ
>
> On Thu, 27 Feb 2014, Dario Faggioli wrote:
> > On mer, 2014-02-26 at 15:43 +0000, Viktor Kleinik wrote:
> > > Hi all,
> > >
> > Hi,
> >
> > > Does anyone knows something about future plans to implement
> > > xc_domain_memory_mapping/XEN_DOMCTL_memory_mapping and
> > > xc_physdev_map_pirq/PHYSDEVOP_map_pirq calls for ARM?
> > >
> > I think Arianna is working on an implementation of the former
> > (XEN_DOMCTL_memory_mapping), and she should be sending patches to this
> > list soon, isn't it so, Arianna?
>
> Eric Trudeau did some work in the area too:
>
> http://marc.info/?l=xen-devel&m=137338996422503
> http://marc.info/?l=xen-devel&m=137365750318936

I checked our repo and the route IRQ changes to DomUs in the second patch URL Stefano provided below are up-to-date with what we have been using on our platforms.  We made no further changes after that patch, i.e. we left the 100 msec max wait for a domain to finish an ISR when destroying it.

We also added support for a DomU to map in I/O memory with the iomem configuration parameter.  Unfortunately, I don't have time to provide an official patch on recent Xen upstream code due to time constraints, but below is a patch based on last October, :( , commit d70d87d2ccf93e3d5302bb034c0a1ae1d6fc1d29.
I hope this is helpful, because that is the best I can do at this time.

-----------------

tools/libxl/libxl_create.c |  5 +++--
 xen/arch/arm/domctl.c      | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 76 insertions(+), 3 deletions(-)

diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index 1b320d3..53ed52e 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -976,8 +976,9 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev,
         LOG(DEBUG, "dom%d iomem %"PRIx64"-%"PRIx64,
             domid, io->start, io->start + io->number - 1);

-        ret = xc_domain_iomem_permission(CTX->xch, domid,
-                                          io->start, io->number, 1);
+        ret = xc_domain_memory_mapping(CTX->xch, domid,
+                                       io->start, io->start,
+                                       io->number, 1);
         if (ret < 0) {
             LOGE(ERROR,
                  "failed give dom%d access to iomem range %"PRIx64"-%"PRIx64,
diff --git a/xen/arch/arm/domctl.c b/xen/arch/arm/domctl.c
index 851ee40..222aac9 100644
--- a/xen/arch/arm/domctl.c
+++ b/xen/arch/arm/domctl.c
@@ -10,11 +10,83 @@
 #include <xen/errno.h>
 #include <xen/sched.h>
 #include <public/domctl.h>
+#include <xen/iocap.h>
+#include <xsm/xsm.h>
+#include <xen/paging.h>
+#include <xen/guest_access.h>

 long arch_do_domctl(struct xen_domctl *domctl, struct domain *d,
                     XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
 {
-    return -ENOSYS;
+    long ret = 0;
+    bool_t copyback = 0;
+
+    switch ( domctl->cmd )
+    {
+    case XEN_DOMCTL_memory_mapping:
+    {
+        unsigned long gfn = domctl->u.memory_mapping.first_gfn;
+        unsigned long mfn = domctl->u.memory_mapping.first_mfn;
+        unsigned long nr_mfns = domctl->u.memory_mapping.nr_mfns;
+        int add = domctl->u.memory_mapping.add_mapping;
+
+        /* removing i/o memory is not implemented yet */
+        if (!add) {
+            ret = -ENOSYS;
+            break;
+        }
+        ret = -EINVAL;
+        if ( (mfn + nr_mfns - 1) < mfn || /* wrap? */
+             /* x86 checks wrap based on paddr_bits which is not implemented on ARM? */
+             /* ((mfn | (mfn + nr_mfns - 1)) >> (paddr_bits - PAGE_SHIFT)) || */
+             (gfn + nr_mfns - 1) < gfn ) /* wrap? */
+            break;
+
+        ret = -EPERM;
+        if ( current->domain->domain_id != 0 )
+            break;
+
+        ret = xsm_iomem_mapping(XSM_HOOK, d, mfn, mfn + nr_mfns - 1, add);
+        if ( ret )
+            break;
+
+        if ( add )
+        {
+            printk(XENLOG_G_INFO
+                   "memory_map:add: dom%d gfn=%lx mfn=%lx nr=%lx\n",
+                   d->domain_id, gfn, mfn, nr_mfns);
+
+            ret = iomem_permit_access(d, mfn, mfn + nr_mfns - 1);
+            if ( !ret && paging_mode_translate(d) )
+            {
+                ret = map_mmio_regions(d, gfn << PAGE_SHIFT,
+                                       (gfn + nr_mfns) << PAGE_SHIFT,
+                                       mfn << PAGE_SHIFT);
+                if ( ret )
+                {
+                    printk(XENLOG_G_WARNING
+                           "memory_map:fail: dom%d gfn=%lx mfn=%lx nr=%lx\n",
+                           d->domain_id, gfn, mfn, nr_mfns);
+                    if ( iomem_deny_access(d, mfn, mfn + nr_mfns - 1) &&
+                         is_hardware_domain(current->domain) )
+                        printk(XENLOG_ERR
+                               "memory_map: failed to deny dom%d access to [%lx,%lx]\n",
+                               d->domain_id, mfn, mfn + nr_mfns - 1);
+                }
+            }
+        }
+    }
+    break;
+
+    default:
+        ret = -ENOSYS;
+        break;
+    }
+
+    if ( copyback && __copy_to_guest(u_domctl, domctl, 1) )
+        ret = -EFAULT;
+
+    return ret;
 }

 void arch_get_info_guest(struct vcpu *v, vcpu_guest_context_u c)
<http://www.globallogic.com/email_disclaimer.txt>

[-- Attachment #1.2: Type: text/html, Size: 12851 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: R:  ARM: access to iomem and HW IRQ
  2014-02-27 23:39           ` R: " Dario Faggioli
@ 2014-02-28  0:24             ` Arianna Avanzini
  2014-03-03 14:00               ` Eric Trudeau
  0 siblings, 1 reply; 10+ messages in thread
From: Arianna Avanzini @ 2014-02-28  0:24 UTC (permalink / raw)
  To: Dario Faggioli, Eric Trudeau, Viktor Kleinik
  Cc: Julien Grall, Stefano Stabellini, xen-devel

On 02/28/2014 12:39 AM, Dario Faggioli wrote:
> As I said, Arianna is doing something very similar... perhaps she can merge her
> and your work and try to upstream it properly, in the next few days... Arianna?
> 

I'd be certainly happy to, once the patch is ready and if Eric Trudeau agrees.

Sorry for the delay,
Arianna


> Regards,
> Dario
> 
> 
> Inviato da Samsung Mobile
> 
> 
> -------- Messaggio originale --------
> Da: Eric Trudeau
> Data:28/02/2014 00:03 (GMT+01:00)
> A: Viktor Kleinik
> Cc: Stefano Stabellini ,Dario Faggioli ,xen-devel@lists.xen.org,Arianna Avanzini
> ,Julien Grall
> Oggetto: Re: [Xen-devel] ARM: access to iomem and HW IRQ
> 
> 
> On Feb 27, 2014, at 1:10 PM, "Viktor Kleinik" <viktor.kleinik@globallogic.com
> <mailto:viktor.kleinik@globallogic.com>> wrote:
> 
>> Thank you all for your responses.
>>
>> I will try those changes on our platform.
>> Are you planning push the implementation of
>> xc_domain_memory_mapping/XEN_DOMCTL_memory_mapping and
>> xc_physdev_map_pirq/PHYSDEVOP_map_pirq hypercalls into
>> official Xen release?
>>
>> Regards,
>> Victor
>>
> I don't expect to push the changes up. If you want to submit, please go ahead. 
>>
>> On Thu, Feb 27, 2014 at 2:11 PM, Eric Trudeau <etrudeau@broadcom.com
>> <mailto:etrudeau@broadcom.com>> wrote:
>>
>>     > -----Original Message-----
>>     > From: Stefano Stabellini [mailto:stefano.stabellini@eu.citrix.com
>>     <mailto:stefano.stabellini@eu.citrix.com>]
>>     > Sent: Thursday, February 27, 2014 8:16 AM
>>     > To: Dario Faggioli
>>     > Cc: Viktor Kleinik; xen-devel@lists.xen.org
>>     <mailto:xen-devel@lists.xen.org>; Arianna Avanzini; Stefano Stabellini;
>>     > Julien Grall; Eric Trudeau
>>     > Subject: Re: [Xen-devel] ARM: access to iomem and HW IRQ
>>     >
>>     > On Thu, 27 Feb 2014, Dario Faggioli wrote:
>>     > > On mer, 2014-02-26 at 15:43 +0000, Viktor Kleinik wrote:
>>     > > > Hi all,
>>     > > >
>>     > > Hi,
>>     > >
>>     > > > Does anyone knows something about future plans to implement
>>     > > > xc_domain_memory_mapping/XEN_DOMCTL_memory_mapping and
>>     > > > xc_physdev_map_pirq/PHYSDEVOP_map_pirq calls for ARM?
>>     > > >
>>     > > I think Arianna is working on an implementation of the former
>>     > > (XEN_DOMCTL_memory_mapping), and she should be sending patches to this
>>     > > list soon, isn't it so, Arianna?
>>     >
>>     > Eric Trudeau did some work in the area too:
>>     >
>>     > http://marc.info/?l=xen-devel&m=137338996422503
>>     > http://marc.info/?l=xen-devel&m=137365750318936
>>
>>     I checked our repo and the route IRQ changes to DomUs in the second patch
>>     URL Stefano provided below are up-to-date with what we have been using on
>>     our platforms.  We made no further changes after that patch, i.e. we left
>>     the 100 msec max wait for a domain to finish an ISR when destroying it.
>>
>>     We also added support for a DomU to map in I/O memory with the iomem
>>     configuration parameter.  Unfortunately, I don't have time to provide an
>>     official patch on recent Xen upstream code due to time constraints, but
>>     below is a patch based on last October, :( , commit
>>     d70d87d2ccf93e3d5302bb034c0a1ae1d6fc1d29.
>>     I hope this is helpful, because that is the best I can do at this time.
>>
>>     -----------------
>>
>>     tools/libxl/libxl_create.c |  5 +++--
>>      xen/arch/arm/domctl.c      | 74
>>     +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>>      2 files changed, 76 insertions(+), 3 deletions(-)
>>
>>     diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
>>     index 1b320d3..53ed52e 100644
>>     --- a/tools/libxl/libxl_create.c
>>     +++ b/tools/libxl/libxl_create.c
>>     @@ -976,8 +976,9 @@ static void domcreate_launch_dm(libxl__egc *egc,
>>     libxl__multidev *multidev,
>>              LOG(DEBUG, "dom%d iomem %"PRIx64"-%"PRIx64,
>>                  domid, io->start, io->start + io->number - 1);
>>
>>     -        ret = xc_domain_iomem_permission(CTX->xch, domid,
>>     -                                          io->start, io->number, 1);
>>     +        ret = xc_domain_memory_mapping(CTX->xch, domid,
>>     +                                       io->start, io->start,
>>     +                                       io->number, 1);
>>              if (ret < 0) {
>>                  LOGE(ERROR,
>>                       "failed give dom%d access to iomem range %"PRIx64"-%"PRIx64,
>>     diff --git a/xen/arch/arm/domctl.c b/xen/arch/arm/domctl.c
>>     index 851ee40..222aac9 100644
>>     --- a/xen/arch/arm/domctl.c
>>     +++ b/xen/arch/arm/domctl.c
>>     @@ -10,11 +10,83 @@
>>      #include <xen/errno.h>
>>      #include <xen/sched.h>
>>      #include <public/domctl.h>
>>     +#include <xen/iocap.h>
>>     +#include <xsm/xsm.h>
>>     +#include <xen/paging.h>
>>     +#include <xen/guest_access.h>
>>
>>      long arch_do_domctl(struct xen_domctl *domctl, struct domain *d,
>>                          XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
>>      {
>>     -    return -ENOSYS;
>>     +    long ret = 0;
>>     +    bool_t copyback = 0;
>>     +
>>     +    switch ( domctl->cmd )
>>     +    {
>>     +    case XEN_DOMCTL_memory_mapping:
>>     +    {
>>     +        unsigned long gfn = domctl->u.memory_mapping.first_gfn;
>>     +        unsigned long mfn = domctl->u.memory_mapping.first_mfn;
>>     +        unsigned long nr_mfns = domctl->u.memory_mapping.nr_mfns;
>>     +        int add = domctl->u.memory_mapping.add_mapping;
>>     +
>>     +        /* removing i/o memory is not implemented yet */
>>     +        if (!add) {
>>     +            ret = -ENOSYS;
>>     +            break;
>>     +        }
>>     +        ret = -EINVAL;
>>     +        if ( (mfn + nr_mfns - 1) < mfn || /* wrap? */
>>     +             /* x86 checks wrap based on paddr_bits which is not
>>     implemented on ARM? */
>>     +             /* ((mfn | (mfn + nr_mfns - 1)) >> (paddr_bits -
>>     PAGE_SHIFT)) || */
>>     +             (gfn + nr_mfns - 1) < gfn ) /* wrap? */
>>     +            break;
>>     +
>>     +        ret = -EPERM;
>>     +        if ( current->domain->domain_id != 0 )
>>     +            break;
>>     +
>>     +        ret = xsm_iomem_mapping(XSM_HOOK, d, mfn, mfn + nr_mfns - 1, add);
>>     +        if ( ret )
>>     +            break;
>>     +
>>     +        if ( add )
>>     +        {
>>     +            printk(XENLOG_G_INFO
>>     +                   "memory_map:add: dom%d gfn=%lx mfn=%lx nr=%lx\n",
>>     +                   d->domain_id, gfn, mfn, nr_mfns);
>>     +
>>     +            ret = iomem_permit_access(d, mfn, mfn + nr_mfns - 1);
>>     +            if ( !ret && paging_mode_translate(d) )
>>     +            {
>>     +                ret = map_mmio_regions(d, gfn << PAGE_SHIFT,
>>     +                                       (gfn + nr_mfns) << PAGE_SHIFT,
>>     +                                       mfn << PAGE_SHIFT);
>>     +                if ( ret )
>>     +                {
>>     +                    printk(XENLOG_G_WARNING
>>     +                           "memory_map:fail: dom%d gfn=%lx mfn=%lx nr=%lx\n",
>>     +                           d->domain_id, gfn, mfn, nr_mfns);
>>     +                    if ( iomem_deny_access(d, mfn, mfn + nr_mfns - 1) &&
>>     +                         is_hardware_domain(current->domain) )
>>     +                        printk(XENLOG_ERR
>>     +                               "memory_map: failed to deny dom%d access
>>     to [%lx,%lx]\n",
>>     +                               d->domain_id, mfn, mfn + nr_mfns - 1);
>>     +                }
>>     +            }
>>     +        }
>>     +    }
>>     +    break;
>>     +
>>     +    default:
>>     +        ret = -ENOSYS;
>>     +        break;
>>     +    }
>>     +
>>     +    if ( copyback && __copy_to_guest(u_domctl, domctl, 1) )
>>     +        ret = -EFAULT;
>>     +
>>     +    return ret;
>>      }
>>
>>      void arch_get_info_guest(struct vcpu *v, vcpu_guest_context_u c)
>>
>> <http://www.globallogic.com/email_disclaimer.txt>


-- 
/*
 * Arianna Avanzini
 * avanzini.arianna@gmail.com
 * 73628@studenti.unimore.it
 */

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: R:  ARM: access to iomem and HW IRQ
  2014-02-28  0:24             ` Arianna Avanzini
@ 2014-03-03 14:00               ` Eric Trudeau
  2014-03-03 14:17                 ` Dario Faggioli
  0 siblings, 1 reply; 10+ messages in thread
From: Eric Trudeau @ 2014-03-03 14:00 UTC (permalink / raw)
  To: Arianna Avanzini, Dario Faggioli, Viktor Kleinik
  Cc: Julien Grall, Stefano Stabellini, xen-devel

> -----Original Message-----
> From: Arianna Avanzini [mailto:avanzini.arianna@gmail.com]
> Sent: Thursday, February 27, 2014 7:24 PM
> To: Dario Faggioli; Eric Trudeau; Viktor Kleinik
> Cc: Stefano Stabellini; xen-devel@lists.xen.org; Julien Grall
> Subject: Re: R: [Xen-devel] ARM: access to iomem and HW IRQ
> 
> On 02/28/2014 12:39 AM, Dario Faggioli wrote:
> > As I said, Arianna is doing something very similar... perhaps she can merge her
> > and your work and try to upstream it properly, in the next few days... Arianna?
> >
> 
> I'd be certainly happy to, once the patch is ready and if Eric Trudeau agrees.
> 
I agree.

> Sorry for the delay,
> Arianna
> 
> 
> > Regards,
> > Dario
> >
> >
> > Inviato da Samsung Mobile
> >
> >
> > -------- Messaggio originale --------
> > Da: Eric Trudeau
> > Data:28/02/2014 00:03 (GMT+01:00)
> > A: Viktor Kleinik
> > Cc: Stefano Stabellini ,Dario Faggioli ,xen-devel@lists.xen.org,Arianna Avanzini
> > ,Julien Grall
> > Oggetto: Re: [Xen-devel] ARM: access to iomem and HW IRQ
> >
> >
> > On Feb 27, 2014, at 1:10 PM, "Viktor Kleinik" <viktor.kleinik@globallogic.com
> > <mailto:viktor.kleinik@globallogic.com>> wrote:
> >
> >> Thank you all for your responses.
> >>
> >> I will try those changes on our platform.
> >> Are you planning push the implementation of
> >> xc_domain_memory_mapping/XEN_DOMCTL_memory_mapping and
> >> xc_physdev_map_pirq/PHYSDEVOP_map_pirq hypercalls into
> >> official Xen release?
> >>
> >> Regards,
> >> Victor
> >>
> > I don't expect to push the changes up. If you want to submit, please go ahead.
> >>
> >> On Thu, Feb 27, 2014 at 2:11 PM, Eric Trudeau <etrudeau@broadcom.com
> >> <mailto:etrudeau@broadcom.com>> wrote:
> >>
> >>     > -----Original Message-----
> >>     > From: Stefano Stabellini [mailto:stefano.stabellini@eu.citrix.com
> >>     <mailto:stefano.stabellini@eu.citrix.com>]
> >>     > Sent: Thursday, February 27, 2014 8:16 AM
> >>     > To: Dario Faggioli
> >>     > Cc: Viktor Kleinik; xen-devel@lists.xen.org
> >>     <mailto:xen-devel@lists.xen.org>; Arianna Avanzini; Stefano Stabellini;
> >>     > Julien Grall; Eric Trudeau
> >>     > Subject: Re: [Xen-devel] ARM: access to iomem and HW IRQ
> >>     >
> >>     > On Thu, 27 Feb 2014, Dario Faggioli wrote:
> >>     > > On mer, 2014-02-26 at 15:43 +0000, Viktor Kleinik wrote:
> >>     > > > Hi all,
> >>     > > >
> >>     > > Hi,
> >>     > >
> >>     > > > Does anyone knows something about future plans to implement
> >>     > > > xc_domain_memory_mapping/XEN_DOMCTL_memory_mapping and
> >>     > > > xc_physdev_map_pirq/PHYSDEVOP_map_pirq calls for ARM?
> >>     > > >
> >>     > > I think Arianna is working on an implementation of the former
> >>     > > (XEN_DOMCTL_memory_mapping), and she should be sending patches
> to this
> >>     > > list soon, isn't it so, Arianna?
> >>     >
> >>     > Eric Trudeau did some work in the area too:
> >>     >
> >>     > http://marc.info/?l=xen-devel&m=137338996422503
> >>     > http://marc.info/?l=xen-devel&m=137365750318936
> >>
> >>     I checked our repo and the route IRQ changes to DomUs in the second
> patch
> >>     URL Stefano provided below are up-to-date with what we have been using
> on
> >>     our platforms.  We made no further changes after that patch, i.e. we left
> >>     the 100 msec max wait for a domain to finish an ISR when destroying it.
> >>
> >>     We also added support for a DomU to map in I/O memory with the iomem
> >>     configuration parameter.  Unfortunately, I don't have time to provide an
> >>     official patch on recent Xen upstream code due to time constraints, but
> >>     below is a patch based on last October, :( , commit
> >>     d70d87d2ccf93e3d5302bb034c0a1ae1d6fc1d29.
> >>     I hope this is helpful, because that is the best I can do at this time.
> >>
> >>     -----------------
> >>
> >>     tools/libxl/libxl_create.c |  5 +++--
> >>      xen/arch/arm/domctl.c      | 74
> >>
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> ++++++++-
> >>      2 files changed, 76 insertions(+), 3 deletions(-)
> >>
> >>     diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
> >>     index 1b320d3..53ed52e 100644
> >>     --- a/tools/libxl/libxl_create.c
> >>     +++ b/tools/libxl/libxl_create.c
> >>     @@ -976,8 +976,9 @@ static void domcreate_launch_dm(libxl__egc *egc,
> >>     libxl__multidev *multidev,
> >>              LOG(DEBUG, "dom%d iomem %"PRIx64"-%"PRIx64,
> >>                  domid, io->start, io->start + io->number - 1);
> >>
> >>     -        ret = xc_domain_iomem_permission(CTX->xch, domid,
> >>     -                                          io->start, io->number, 1);
> >>     +        ret = xc_domain_memory_mapping(CTX->xch, domid,
> >>     +                                       io->start, io->start,
> >>     +                                       io->number, 1);
> >>              if (ret < 0) {
> >>                  LOGE(ERROR,
> >>                       "failed give dom%d access to iomem range %"PRIx64"-%"PRIx64,
> >>     diff --git a/xen/arch/arm/domctl.c b/xen/arch/arm/domctl.c
> >>     index 851ee40..222aac9 100644
> >>     --- a/xen/arch/arm/domctl.c
> >>     +++ b/xen/arch/arm/domctl.c
> >>     @@ -10,11 +10,83 @@
> >>      #include <xen/errno.h>
> >>      #include <xen/sched.h>
> >>      #include <public/domctl.h>
> >>     +#include <xen/iocap.h>
> >>     +#include <xsm/xsm.h>
> >>     +#include <xen/paging.h>
> >>     +#include <xen/guest_access.h>
> >>
> >>      long arch_do_domctl(struct xen_domctl *domctl, struct domain *d,
> >>                          XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
> >>      {
> >>     -    return -ENOSYS;
> >>     +    long ret = 0;
> >>     +    bool_t copyback = 0;
> >>     +
> >>     +    switch ( domctl->cmd )
> >>     +    {
> >>     +    case XEN_DOMCTL_memory_mapping:
> >>     +    {
> >>     +        unsigned long gfn = domctl->u.memory_mapping.first_gfn;
> >>     +        unsigned long mfn = domctl->u.memory_mapping.first_mfn;
> >>     +        unsigned long nr_mfns = domctl->u.memory_mapping.nr_mfns;
> >>     +        int add = domctl->u.memory_mapping.add_mapping;
> >>     +
> >>     +        /* removing i/o memory is not implemented yet */
> >>     +        if (!add) {
> >>     +            ret = -ENOSYS;
> >>     +            break;
> >>     +        }
> >>     +        ret = -EINVAL;
> >>     +        if ( (mfn + nr_mfns - 1) < mfn || /* wrap? */
> >>     +             /* x86 checks wrap based on paddr_bits which is not
> >>     implemented on ARM? */
> >>     +             /* ((mfn | (mfn + nr_mfns - 1)) >> (paddr_bits -
> >>     PAGE_SHIFT)) || */
> >>     +             (gfn + nr_mfns - 1) < gfn ) /* wrap? */
> >>     +            break;
> >>     +
> >>     +        ret = -EPERM;
> >>     +        if ( current->domain->domain_id != 0 )
> >>     +            break;
> >>     +
> >>     +        ret = xsm_iomem_mapping(XSM_HOOK, d, mfn, mfn + nr_mfns - 1,
> add);
> >>     +        if ( ret )
> >>     +            break;
> >>     +
> >>     +        if ( add )
> >>     +        {
> >>     +            printk(XENLOG_G_INFO
> >>     +                   "memory_map:add: dom%d gfn=%lx mfn=%lx nr=%lx\n",
> >>     +                   d->domain_id, gfn, mfn, nr_mfns);
> >>     +
> >>     +            ret = iomem_permit_access(d, mfn, mfn + nr_mfns - 1);
> >>     +            if ( !ret && paging_mode_translate(d) )
> >>     +            {
> >>     +                ret = map_mmio_regions(d, gfn << PAGE_SHIFT,
> >>     +                                       (gfn + nr_mfns) << PAGE_SHIFT,
> >>     +                                       mfn << PAGE_SHIFT);
> >>     +                if ( ret )
> >>     +                {
> >>     +                    printk(XENLOG_G_WARNING
> >>     +                           "memory_map:fail: dom%d gfn=%lx mfn=%lx nr=%lx\n",
> >>     +                           d->domain_id, gfn, mfn, nr_mfns);
> >>     +                    if ( iomem_deny_access(d, mfn, mfn + nr_mfns - 1) &&
> >>     +                         is_hardware_domain(current->domain) )
> >>     +                        printk(XENLOG_ERR
> >>     +                               "memory_map: failed to deny dom%d access
> >>     to [%lx,%lx]\n",
> >>     +                               d->domain_id, mfn, mfn + nr_mfns - 1);
> >>     +                }
> >>     +            }
> >>     +        }
> >>     +    }
> >>     +    break;
> >>     +
> >>     +    default:
> >>     +        ret = -ENOSYS;
> >>     +        break;
> >>     +    }
> >>     +
> >>     +    if ( copyback && __copy_to_guest(u_domctl, domctl, 1) )
> >>     +        ret = -EFAULT;
> >>     +
> >>     +    return ret;
> >>      }
> >>
> >>      void arch_get_info_guest(struct vcpu *v, vcpu_guest_context_u c)
> >>
> >> <http://www.globallogic.com/email_disclaimer.txt>
> 
> 
> --
> /*
>  * Arianna Avanzini
>  * avanzini.arianna@gmail.com
>  * 73628@studenti.unimore.it
>  */

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: R:  ARM: access to iomem and HW IRQ
  2014-03-03 14:00               ` Eric Trudeau
@ 2014-03-03 14:17                 ` Dario Faggioli
  0 siblings, 0 replies; 10+ messages in thread
From: Dario Faggioli @ 2014-03-03 14:17 UTC (permalink / raw)
  To: Eric Trudeau
  Cc: Julien Grall, xen-devel, Stefano Stabellini, Viktor Kleinik,
	Arianna Avanzini


[-- Attachment #1.1: Type: text/plain, Size: 1140 bytes --]

On lun, 2014-03-03 at 14:00 +0000, Eric Trudeau wrote:
> > -----Original Message-----
> > From: Arianna Avanzini [mailto:avanzini.arianna@gmail.com]
> > Sent: Thursday, February 27, 2014 7:24 PM
> > To: Dario Faggioli; Eric Trudeau; Viktor Kleinik
> > Cc: Stefano Stabellini; xen-devel@lists.xen.org; Julien Grall
> > Subject: Re: R: [Xen-devel] ARM: access to iomem and HW IRQ
> > 
> > On 02/28/2014 12:39 AM, Dario Faggioli wrote:
> > > As I said, Arianna is doing something very similar... perhaps she can merge her
> > > and your work and try to upstream it properly, in the next few days... Arianna?
> > >
> > 
> > I'd be certainly happy to, once the patch is ready and if Eric Trudeau agrees.
> > 
> I agree.
> 
Cool! Check this (and the rest of the thread) out then:

http://www.gossamer-threads.com/lists/xen/devel/318927?page=last

:-D

Dario

-- 
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)


[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-03-03 14:17 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-26 15:43 ARM: access to iomem and HW IRQ Viktor Kleinik
2014-02-27 10:14 ` Dario Faggioli
2014-02-27 13:15   ` Stefano Stabellini
2014-02-27 14:11     ` Eric Trudeau
2014-02-27 17:11       ` Viktor Kleinik
2014-02-27 23:03         ` Eric Trudeau
2014-02-27 23:39           ` R: " Dario Faggioli
2014-02-28  0:24             ` Arianna Avanzini
2014-03-03 14:00               ` Eric Trudeau
2014-03-03 14:17                 ` Dario Faggioli

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.