WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH 3/3] iommu: add xc_iommu_map_batch

To: Jean Guyader <jean.guyader@xxxxxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH 3/3] iommu: add xc_iommu_map_batch
From: Tim Deegan <Tim.Deegan@xxxxxxxxxx>
Date: Thu, 18 Nov 2010 12:00:44 +0000
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>, "Kay, Allen M" <allen.m.kay@xxxxxxxxx>
Delivery-date: Thu, 18 Nov 2010 04:03:32 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <20101115180022.GD10475@xxxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <20101115180022.GD10475@xxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.20 (2009-06-14)
At 18:00 +0000 on 15 Nov (1289844022), Jean Guyader wrote:
> diff -r 48256256333b xen/arch/x86/domctl.c
> --- a/xen/arch/x86/domctl.c   Mon Nov 15 11:54:43 2010 +0000
> +++ b/xen/arch/x86/domctl.c   Mon Nov 15 17:45:09 2010 +0000
> @@ -953,6 +953,44 @@
>      }
>      break;
>  
> +    case XEN_DOMCTL_iommu_map_batch:
> +    {
> +        struct domain *d;
> +        unsigned long gfn = domctl->u.iommu_map_batch.gfn;
> +        unsigned long nr = domctl->u.iommu_map_batch.nr;
> +        unsigned long mfn;
> +        int i = 0;
> +
> +        printk("iommu_map_batch: domid_to:%d gfn:0x%lx size:0x%lx\n",
> +                domctl->domain, gfn, nr);

This should be gdprintk, at most.

> +
> +        ret = -EINVAL;
> +        if ( (gfn + nr - 1) < gfn) /* wrap? */
> +            break;
> +
> +        ret = -ESRCH;
> +        if ( unlikely((d = rcu_lock_domain_by_id(domctl->domain)) == NULL) )
> +            break;

ITYM rcu_lock_target_domain_by_id, otherwise there are no privilege
checks on this call.  It needs xcp hooks too. 

> +        if (d != current->domain)
> +            domain_pause(d);
> +        for ( i = 0; i < nr; i++)
> +        {
> +            ret = -EFAULT;
> +            if (copy_from_guest_offset(&mfn, domctl->u.iommu_map_batch.mfns, 
> i, 1))

The hypercall interface defines the mfn list as uint64s but you're
copying them as unsigned longs.  That'll break on 32-bit builds.

> +                break;
> +            if ((ret = iommu_set_entry(d, gfn + i, mfn, 
> IOMMUF_readable|IOMMUF_writable, 1)) != 0)

For HVM guests, don't you want to keep the p2m in sync as well?

> +                break;
> +        }
> +        if (i)
> +            iommu_flush_iotlb(d, gfn, nr - ( nr - i));
> +        if (d != current->domain)
> +            domain_unpause(d);
> +
> +        rcu_unlock_domain(d);
> +    }
> +    break;
> +
>      case XEN_DOMCTL_memory_mapping:
>      {
>          struct domain *d;
> diff -r 48256256333b xen/include/public/domctl.h
> --- a/xen/include/public/domctl.h     Mon Nov 15 11:54:43 2010 +0000
> +++ b/xen/include/public/domctl.h     Mon Nov 15 17:45:09 2010 +0000
> @@ -517,6 +517,13 @@
>  typedef struct xen_domctl_memory_mapping xen_domctl_memory_mapping_t;
>  DEFINE_XEN_GUEST_HANDLE(xen_domctl_memory_mapping_t);
>  
> +struct xen_domctl_iommu_map_batch {
> +    uint64_aligned_t gfn;
> +    uint64_aligned_t nr;
> +    XEN_GUEST_HANDLE_64(uint64) mfns;
> +};
> +typedef struct xen_domctl_iommu_map_batch xen_domctl_iommu_map_batch_t;
> +DEFINE_XEN_GUEST_HANDLE(xen_domctl_iommu_map_batch_t);

Needs a comment describing what this hypercall does. 

>  /* Bind machine I/O port range -> HVM I/O port range. */
>  /* XEN_DOMCTL_ioport_mapping */
> @@ -868,6 +875,7 @@
>  #define XEN_DOMCTL_getpageframeinfo3             61
>  #define XEN_DOMCTL_setvcpuextstate               62
>  #define XEN_DOMCTL_getvcpuextstate               63
> +#define XEN_DOMCTL_iommu_map_batch               64
>  #define XEN_DOMCTL_gdbsx_guestmemio            1000
>  #define XEN_DOMCTL_gdbsx_pausevcpu             1001
>  #define XEN_DOMCTL_gdbsx_unpausevcpu           1002
> @@ -907,6 +915,7 @@
>          struct xen_domctl_assign_device     assign_device;
>          struct xen_domctl_bind_pt_irq       bind_pt_irq;
>          struct xen_domctl_memory_mapping    memory_mapping;
> +        struct xen_domctl_iommu_map_batch   iommu_map_batch;
>          struct xen_domctl_ioport_mapping    ioport_mapping;
>          struct xen_domctl_pin_mem_cacheattr pin_mem_cacheattr;
>          struct xen_domctl_ext_vcpucontext   ext_vcpucontext;

> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxxxxxxxx
> http://lists.xensource.com/xen-devel


-- 
Tim Deegan <Tim.Deegan@xxxxxxxxxx>
Principal Software Engineer, Xen Platform Team
Citrix Systems UK Ltd.  (Company #02937203, SL9 0BG)

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>