On 12/09/18 12:30, Paul Durrant wrote:
> diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h
> index e35d941f3c..19d5d55d79 100644
> --- a/xen/include/xen/iommu.h
> +++ b/xen/include/xen/iommu.h
> @@ -23,11 +23,37 @@
>  #include <xen/page-defs.h>
>  #include <xen/spinlock.h>
>  #include <xen/pci.h>
> +#include <xen/typesafe.h>
>  #include <public/hvm/ioreq.h>
>  #include <public/domctl.h>
>  #include <asm/device.h>
>  #include <asm/iommu.h>
>  
> +TYPE_SAFE(uint64_t, dfn);
> +#define PRI_dfn     PRIx64
> +#define INVALID_DFN _dfn(~0UL)

Presumably the use uint64_t as opposed to unsigned long is for ARM32's
benefit?

If so, INVALID_DFN needs to be ~0ULL to work as intended.

> +
> +#ifndef dfn_t
> +#define dfn_t /* Grep fodder: dfn_t, _dfn() and dfn_x() are defined above */
> +#define _dfn
> +#define dfn_x
> +#undef dfn_t
> +#undef _dfn
> +#undef dfn_x
> +#endif
> +
> +#define IOMMU_PAGE_SHIFT 12
> +#define IOMMU_PAGE_SIZE  (_AC(1,L) << IOMMU_PAGE_SHIFT)

"1, L", but this shouldn't need any _AC() at all.  1 << 12 is signed and
fits within an int so should be fine on its own.

> +#define IOMMU_PAGE_MASK  (~(IOMMU_PAGE_SIZE - 1))
> +
> +typedef uint64_t daddr_t;
> +
> +#define __dfn_to_daddr(dfn) ((daddr_t)(dfn) << IOMMU_PAGE_SHIFT)
> +#define __daddr_to_dfn(daddr) ((uint64_t)(daddr >> IOMMU_PAGE_SHIFT))
> +
> +#define dfn_to_daddr(dfn) __dfn_to_daddr(dfn_x(dfn))
> +#define daddr_to_dfn(daddr) _dfn(__daddr_to_dfn(daddr))
> +
>  extern bool_t iommu_enable, iommu_enabled;
>  extern bool_t force_iommu, iommu_dom0_strict, iommu_verbose;
>  extern bool_t iommu_workaround_bios_bug, iommu_igfx, iommu_passthrough;
> diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h
> index 24654e8e22..288dc77b85 100644
> --- a/xen/include/xen/mm.h
> +++ b/xen/include/xen/mm.h
> @@ -26,6 +26,11 @@
>   *   A linear idea of a guest physical address space. For an auto-translated
>   *   guest, pfn == gfn while for a non-translated guest, pfn != gfn.
>   *
> + * dfn: Device DMA Frame Number (definitions in include/xen/iommu.h)
> + *   The linear frame numbers of IOMMU address space. All initiators for 
> (i.e.
> + *   all devices assigned to) a guest share a single IOMMU address space and,
> + *   by default, Xen will ensure dfn == pfn.

ITYM gfn here?  PV-IOMMU is what a PV guest can use to program the IOMMU
with dfn = pfn, but that isn't the default in Xen.

~Andrew

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reply via email to