From: Paul Durrant <Paul.Durrant@citrix.com>
To: Roger Pau Monne <roger.pau@citrix.com>
Cc: Kevin Tian <kevin.tian@intel.com>,
Stefano Stabellini <sstabellini@kernel.org>,
Wei Liu <wei.liu2@citrix.com>, Jan Beulich <jbeulich@suse.com>,
Julien Grall <julien.grall@arm.com>,
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH v7 1/6] iommu: introduce the concept of DFN...
Date: Thu, 13 Sep 2018 09:36:44 +0000 [thread overview]
Message-ID: <8cfd12a4b4fe4bbf844091514cad6635@AMSPEX02CL03.citrite.net> (raw)
In-Reply-To: <20180912121440.iy7q3czgwbilbufp@mac.bytemobile.com>
> -----Original Message-----
> From: Roger Pau Monne
> Sent: 12 September 2018 13:15
> To: Paul Durrant <Paul.Durrant@citrix.com>
> Cc: xen-devel@lists.xenproject.org; Kevin Tian <kevin.tian@intel.com>;
> Stefano Stabellini <sstabellini@kernel.org>; Wei Liu <wei.liu2@citrix.com>;
> Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>; Julien Grall
> <julien.grall@arm.com>; Jan Beulich <jbeulich@suse.com>
> Subject: Re: [Xen-devel] [PATCH v7 1/6] iommu: introduce the concept of
> DFN...
>
> On Wed, Sep 12, 2018 at 12:30:23PM +0100, 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);
>
> Shouldn't this be unsigned long instead of uint64_t? (like gfn or mfn)
>
Also, there is no reason why a 32-bit domain can't use h/w capable of 64-bit DMA.
> > +#define PRI_dfn PRIx64
> > +#define INVALID_DFN _dfn(~0UL)
>
> Or if there's a reason for the above to be uint64_t, then INVALID_DFN
> should use ULL.
>
Yes, I missed that.
> > +
> > +#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)
>
> There's no need to use _AC?
>
Indeed.
> > +#define IOMMU_PAGE_MASK (~(IOMMU_PAGE_SIZE - 1))
> > +
> > +typedef uint64_t daddr_t;
>
> Use paddr_t instead of uint64_t directly?
>
No, I don't think paddr_t is the correct thing to use.
> > +
> > +#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;
> > @@ -60,9 +86,9 @@ void iommu_teardown(struct domain *d);
> > #define IOMMUF_readable (1u<<_IOMMUF_readable)
> > #define _IOMMUF_writable 1
> > #define IOMMUF_writable (1u<<_IOMMUF_writable)
> > -int __must_check iommu_map_page(struct domain *d, unsigned long
> gfn,
> > +int __must_check iommu_map_page(struct domain *d, unsigned long
> dfn,
> > unsigned long mfn, unsigned int flags);
> > -int __must_check iommu_unmap_page(struct domain *d, unsigned long
> gfn);
> > +int __must_check iommu_unmap_page(struct domain *d, unsigned long
> dfn);
> >
> > enum iommu_feature
> > {
> > @@ -150,9 +176,9 @@ struct iommu_ops {
> > #endif /* HAS_PCI */
> >
> > void (*teardown)(struct domain *d);
> > - int __must_check (*map_page)(struct domain *d, unsigned long gfn,
> > + int __must_check (*map_page)(struct domain *d, unsigned long dfn,
> > unsigned long mfn, unsigned int flags);
> > - int __must_check (*unmap_page)(struct domain *d, unsigned long
> gfn);
> > + int __must_check (*unmap_page)(struct domain *d, unsigned long
> dfn);
> > void (*free_page_table)(struct page_info *);
> > #ifdef CONFIG_X86
> > void (*update_ire_from_apic)(unsigned int apic, unsigned int reg,
> unsigned int value);
> > @@ -163,7 +189,7 @@ struct iommu_ops {
> > void (*resume)(void);
> > void (*share_p2m)(struct domain *d);
> > void (*crash_shutdown)(void);
> > - int __must_check (*iotlb_flush)(struct domain *d, unsigned long gfn,
> > + int __must_check (*iotlb_flush)(struct domain *d, unsigned long dfn,
> > unsigned int page_count);
> > int __must_check (*iotlb_flush_all)(struct domain *d);
> > int (*get_reserved_device_memory)(iommu_grdm_t *, void *);
> > @@ -185,7 +211,7 @@ int iommu_do_pci_domctl(struct xen_domctl *,
> struct domain *d,
> > int iommu_do_domctl(struct xen_domctl *, struct domain *d,
> > XEN_GUEST_HANDLE_PARAM(xen_domctl_t));
> >
> > -int __must_check iommu_iotlb_flush(struct domain *d, unsigned long
> gfn,
> > +int __must_check iommu_iotlb_flush(struct domain *d, unsigned long
> dfn,
>
> While doing this wholesale gfn to dfn replacement, it might be a good
> idea to also change unsigned long for dfn at the same time?
>
Not a lot of point. I'm going to replace these occurrences with type-safe dfn_t in a later patch.
Paul
> Thanks, Roger.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2018-09-13 9:36 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-12 11:30 [PATCH v7 0/6] paravirtual IOMMU pre-requisites and clean-up Paul Durrant
2018-09-12 11:30 ` [PATCH v7 1/6] iommu: introduce the concept of DFN Paul Durrant
2018-09-12 11:49 ` Andrew Cooper
2018-09-12 12:01 ` Paul Durrant
2018-09-12 12:14 ` Roger Pau Monné
2018-09-13 9:36 ` Paul Durrant [this message]
2018-09-12 11:30 ` [PATCH v7 2/6] iommu: make use of type-safe DFN and MFN in exported functions Paul Durrant
2018-09-13 8:09 ` Roger Pau Monné
2018-09-12 11:30 ` [PATCH v7 3/6] iommu: push use of type-safe DFN and MFN into iommu_ops Paul Durrant
2018-09-13 8:12 ` Roger Pau Monné
2018-09-12 11:30 ` [PATCH v7 4/6] iommu: don't domain_crash() inside iommu_map/unmap_page() Paul Durrant
2018-09-13 6:48 ` Tian, Kevin
2018-09-13 8:22 ` Roger Pau Monné
2018-09-13 8:27 ` Paul Durrant
2018-09-12 11:30 ` [PATCH v7 5/6] memory: add check_get_page_from_gfn() as a wrapper Paul Durrant
2018-09-13 8:30 ` Roger Pau Monné
2018-09-13 8:35 ` Paul Durrant
2018-09-12 11:30 ` [PATCH v7 6/6] vtd: add lookup_page method to iommu_ops Paul Durrant
2018-09-13 6:53 ` Tian, Kevin
2018-09-13 8:30 ` Paul Durrant
2018-09-13 8:50 ` Roger Pau Monné
2018-09-13 8:59 ` 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=8cfd12a4b4fe4bbf844091514cad6635@AMSPEX02CL03.citrite.net \
--to=paul.durrant@citrix.com \
--cc=jbeulich@suse.com \
--cc=julien.grall@arm.com \
--cc=kevin.tian@intel.com \
--cc=roger.pau@citrix.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).