[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v8 4/4] xen/arm: grant: Add another entry to map MFN 1:1 in dom0 p2m



>>> On 19.05.14 at 18:24, <julien.grall@xxxxxxxxxx> wrote:
> Grant mapping can be used for DMA request. The dev_bus_addr returned by the
> hypercall is the MFN (not the IPA). Currently Linux is using this address (via
> swiotlb) to program the DMA.
> When the device is protected by IOMMU the request will fail. We have to
> add 1:1 mapping in the domain p2m to allow DMA request working.
> 
> This is valid because DOM0 has its memory mapped 1:1 and therefore we know
> that RAM and devices cannot clash.

Wasn't this 1:1 mapping meant as a temporary workaround? If so,
does it really make sense to base further code on it?

> --- a/xen/common/grant_table.c
> +++ b/xen/common/grant_table.c
> @@ -727,7 +727,7 @@ __gnttab_map_grant_ref(
>  
>      double_gt_lock(lgt, rgt);
>  
> -    if ( !paging_mode_translate(ld) && need_iommu(ld) )
> +    if ( gnttab_need_iommu_mapping(ld) && need_iommu(ld) )

I suppose that you want to keep the common bits of this condition
common, but the two "need_iommu" in here look sort of redundant:
With the name chosen, I think it would make more sense for the
second condition to be moved into gnttab_need_iommu_mapping().

> --- a/xen/include/asm-arm/grant_table.h
> +++ b/xen/include/asm-arm/grant_table.h
> @@ -33,6 +33,8 @@ static inline int replace_grant_supported(void)
>      ( ((i >= nr_grant_frames(d->grant_table)) &&                         \
>       (i < max_nr_grant_frames)) ? 0 : (d->arch.grant_table_gpfn[i]))
>  
> +#define gnttab_need_iommu_mapping(d)    is_domain_direct_mapped(d)

While this one indeed doesn't need extra parentheses, ...

> --- a/xen/include/asm-x86/grant_table.h
> +++ b/xen/include/asm-x86/grant_table.h
> @@ -65,6 +65,8 @@ static inline void gnttab_clear_flag(unsigned int nr, 
> uint16_t *st)
>  /* Done implicitly when page tables are destroyed. */
>  #define gnttab_release_host_mappings(domain) ( paging_mode_external(domain) )
>  
> +#define gnttab_need_iommu_mapping(d)    !paging_mode_translate(d)

... this one does.

Also, with all of this I don't see how other than Dom0 is being (or
going to be) handled in this regard.

Jan


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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.