xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Paul Durrant <Paul.Durrant@citrix.com>
To: 'Jan Beulich' <JBeulich@suse.com>
Cc: Kevin Tian <kevin.tian@intel.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Wei Liu <wei.liu2@citrix.com>,
	Julien Grall <julien.grall@arm.com>,
	Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
	xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH v8 1/7] iommu: introduce the concept of DFN...
Date: Thu, 13 Sep 2018 13:09:28 +0000	[thread overview]
Message-ID: <7dc3f0b19c7a42e9b871b7aeb7cf3dc8@AMSPEX02CL03.citrite.net> (raw)
In-Reply-To: <5B9A5BEF02000078001E8378@prv1-mh.provo.novell.com>

> -----Original Message-----
> From: Jan Beulich [mailto:JBeulich@suse.com]
> Sent: 13 September 2018 13:46
> To: Paul Durrant <Paul.Durrant@citrix.com>
> Cc: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>; Julien Grall
> <julien.grall@arm.com>; Wei Liu <wei.liu2@citrix.com>; Kevin Tian
> <kevin.tian@intel.com>; Stefano Stabellini <sstabellini@kernel.org>; xen-
> devel <xen-devel@lists.xenproject.org>
> Subject: Re: [PATCH v8 1/7] iommu: introduce the concept of DFN...
> 
> >>> On 13.09.18 at 12:31, <paul.durrant@citrix.com> wrote:
> > ...meaning 'device DMA frame number' i.e. a frame number mapped in the
> IOMMU
> > (rather than the MMU) and hence used for DMA address translation.
> >
> > This patch is a largely cosmetic change that substitutes the terms 'gfn'
> > and 'gaddr' for 'dfn' and 'daddr' in all the places where the frame
> number
> > or address relate to a device rather than the CPU.
> >
> > The parts that are not purely cosmetic are:
> >
> >  - the introduction of a type-safe declaration of dfn_t and definition
> of
> >    INVALID_DFN to make the substitution of gfn_x(INVALID_GFN)
> mechanical.
> >  - the introduction of __dfn_to_daddr and __daddr_to_dfn (and type-safe
> >    variants without the leading __) with some use of the former.
> 
> The latter is rather unfortunate, but presumably unavoidable,
> both because of the name space issue and the fact that the other
> non-type-safe variants are intended to go away as well).
> 
> > --- 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(~0ULL)
> > +
> > +#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
> 
> Is this correct for ARM in all cases?

Looks like there's no fixed page size so these may actually be better off in an x86 header. They just got pulled here when I made the code common.

> 
> > +#define IOMMU_PAGE_SIZE  (1 << IOMMU_PAGE_SHIFT)
> > +#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))
> 
> Please could at least the latter of the two casts be omitted? Also
> daddr needed parenthesizing.
> 

Ok.

> > --- 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.
> 
> While the names have been changed, the test still talks about "IOMMU
> address space". In particular for the IOMMU there very clear are two
> address spaces (incoming and outgoing), so this needs disambiguation.
> 
> With these minor issues taken care of
> Acked-by: Jan Beulich <jbeulich@suse.com>
> 

Thanks. Do you want me to move the page size definitions and re-submit with the other things fixed up?

  Paul

> Jan
> 


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

  reply	other threads:[~2018-09-13 13:09 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-13 10:31 [PATCH v8 0/6] paravirtual IOMMU pre-requisites and clean-up Paul Durrant
2018-09-13 10:31 ` [PATCH v8 1/7] iommu: introduce the concept of DFN Paul Durrant
2018-09-13 12:45   ` Jan Beulich
2018-09-13 13:09     ` Paul Durrant [this message]
2018-09-13 13:21       ` Paul Durrant
2018-09-13 13:40       ` Jan Beulich
2018-09-13 13:46         ` Paul Durrant
2018-09-13 14:14           ` Paul Durrant
2018-09-13 10:31 ` [PATCH v8 2/7] iommu: make use of type-safe DFN and MFN in exported functions Paul Durrant
2018-09-13 10:31 ` [PATCH v8 3/7] iommu: push use of type-safe DFN and MFN into iommu_ops Paul Durrant
2018-09-13 10:31 ` [PATCH v8 4/7] iommu: don't domain_crash() inside iommu_map/unmap_page() Paul Durrant
2018-09-13 10:31 ` [PATCH v8 5/7] memory: add check_get_page_from_gfn() as a wrapper Paul Durrant
2018-09-13 13:22   ` Jan Beulich
2018-09-13 13:43     ` Paul Durrant
2018-09-13 10:31 ` [PATCH v7 6/6] vtd: add lookup_page method to iommu_ops Paul Durrant
2018-09-13 10:31 ` [PATCH v8 6/7] vtd: add missing check for shared EPT Paul Durrant
2018-09-13 10:31 ` [PATCH v8 7/7] vtd: add lookup_page method to iommu_ops Paul Durrant
2018-09-13 13:29   ` Jan Beulich
2018-09-13 13:34     ` Paul Durrant
2018-09-13 13:44       ` Jan Beulich
2018-09-13 13:50         ` Paul Durrant
2018-09-13 13:56           ` Jan Beulich
2018-09-13 14:04             ` Paul Durrant
2018-09-13 14:50               ` Jan Beulich
2018-09-13 14:53                 ` Paul Durrant
2018-09-14  7:58                   ` Jan Beulich
2018-09-14  8:11                     ` Paul Durrant
2018-09-14  8:28                       ` Jan Beulich
2018-09-14  8:48                         ` Paul Durrant

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7dc3f0b19c7a42e9b871b7aeb7cf3dc8@AMSPEX02CL03.citrite.net \
    --to=paul.durrant@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=julien.grall@arm.com \
    --cc=kevin.tian@intel.com \
    --cc=sstabellini@kernel.org \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).