All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Durrant <Paul.Durrant@citrix.com>
To: Andrew Cooper <Andrew.Cooper3@citrix.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: Wei Liu <wei.liu2@citrix.com>, George Dunlap <George.Dunlap@citrix.com>
Subject: Re: [PATCH v14 7/9] vtd: add lookup_page method to iommu_ops
Date: Thu, 3 Jan 2019 08:58:05 +0000	[thread overview]
Message-ID: <380aff7acce54f81af1b8784c411b3ef@AMSPEX02CL03.citrite.net> (raw)
In-Reply-To: <1894d0b1-852e-992f-d81d-a68b3ef7195e@citrix.com>

> -----Original Message-----
> From: Andrew Cooper
> Sent: 24 December 2018 15:15
> To: Paul Durrant <Paul.Durrant@citrix.com>; xen-devel@lists.xenproject.org
> Cc: Wei Liu <wei.liu2@citrix.com>; George Dunlap
> <George.Dunlap@citrix.com>
> Subject: Re: [Xen-devel] [PATCH v14 7/9] vtd: add lookup_page method to
> iommu_ops
> 
> On 04/10/2018 11:45, Paul Durrant wrote:
> > This patch adds a new method to the VT-d IOMMU implementation to find
> the
> > MFN currently mapped by the specified DFN along with a wrapper function
> > in generic IOMMU code to call the implementation if it exists.
> >
> > NOTE: This patch only adds a Xen-internal interface. This will be used
> by
> >       a subsequent patch.
> >       Another subsequent patch will add similar functionality for AMD
> >       IOMMUs.
> >
> > Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> > Reviewed-by: Jan Beulich <jbeulich@suse.com>
> > Reviewed-by: Kevin Tian <kevin.tian@intel.com>
> > ---
> > Cc: Wei Liu <wei.liu2@citrix.com>
> > Cc: George Dunlap <george.dunlap@citrix.com>
> >
> > v11:
> >  - Fold in patch to change failure semantics (already ack-ed by Kevin).
> >
> > v10:
> >  - Adjust the locking comment.
> >
> > v9:
> >  - Add comment about locking in xen/iommu.h.
> >
> > v8:
> >  - Remove clean-up as this is now done by a prior patch.
> >  - Make intel_iommu_lookup_page() return dfn value if using shared EPT
> >    or iommu_passthrough is set, as requested by Kevin.
> >
> > v7:
> >  - Re-base and re-name BFN -> DFN.
> >  - Add missing checks for shared EPT and iommu_passthrough.
> >  - Remove unnecessary initializers and use array-style dereference.
> >  - Drop Wei's R-b because of code churn.
> >
> > v3:
> >  - Addressed comments from George.
> >
> > v2:
> >  - Addressed some comments from Jan.
> > ---
> >  xen/drivers/passthrough/iommu.c     | 11 ++++++++++
> >  xen/drivers/passthrough/vtd/iommu.c | 41
> +++++++++++++++++++++++++++++++++++++
> >  xen/drivers/passthrough/vtd/iommu.h |  3 +++
> >  xen/include/xen/iommu.h             | 10 +++++++++
> >  4 files changed, 65 insertions(+)
> >
> > diff --git a/xen/drivers/passthrough/vtd/iommu.c
> b/xen/drivers/passthrough/vtd/iommu.c
> > index 9187d50730..f94b522c73 100644
> > --- a/xen/drivers/passthrough/vtd/iommu.c
> > +++ b/xen/drivers/passthrough/vtd/iommu.c
> > @@ -1833,6 +1833,46 @@ static int __must_check
> intel_iommu_unmap_page(struct domain *d,
> >      return dma_pte_clear_one(d, dfn_to_daddr(dfn));
> >  }
> >
> > +static int intel_iommu_lookup_page(struct domain *d, dfn_t dfn, mfn_t
> *mfn,
> > +                                   unsigned int *flags)
> > +{
> > +    struct domain_iommu *hd = dom_iommu(d);
> > +    struct dma_pte *page, val;
> > +    u64 pg_maddr;
> > +
> > +    /*
> > +     * If VT-d shares EPT page table or if the domain is the hardware
> > +     * domain and iommu_passthrough is set then pass back the dfn.
> > +     */
> > +    if ( iommu_use_hap_pt(d) ||
> > +         (iommu_hwdom_passthrough && is_hardware_domain(d)) )
> > +        return -EOPNOTSUPP;
> 
> The patch as commented no longer behaves in the way described in the
> comment, or the v8 requested change.

The landscape is shifting too. I think this is going to need to pass back a base dfn and order once the the map and unmap ops gain an order parameter.

> 
> What is the verdict WRT returning dfn ?
> 

Passing back the dfn as the mfn is wrong for shared EPT as dfn == gfn and the code at this level does not have that information. I think it is much better to fail in some way... EOPNOTSUPP may not be the best errno but I can't think of a better one.

  Paul

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

  reply	other threads:[~2019-01-03  8:58 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-04 10:45 [PATCH v14 0/9] paravirtual IOMMU pre-requisites and clean-up Paul Durrant
2018-10-04 10:45 ` [PATCH v14 1/9] iommu: introduce the concept of DFN Paul Durrant
2018-10-04 10:45 ` [PATCH v14 2/9] iommu: make use of type-safe DFN and MFN in exported functions Paul Durrant
2018-10-04 15:14   ` George Dunlap
2018-10-04 10:45 ` [PATCH v14 3/9] iommu: push use of type-safe DFN and MFN into iommu_ops Paul Durrant
2018-10-04 13:04   ` Paul Durrant
2018-10-04 13:07     ` Julien Grall
2018-10-04 10:45 ` [PATCH v14 4/9] iommu: don't domain_crash() inside iommu_map/unmap_page() Paul Durrant
2018-10-04 16:29   ` George Dunlap
2018-10-04 16:36     ` Paul Durrant
2018-10-05  7:33       ` Jan Beulich
2018-10-05  9:02         ` Paul Durrant
     [not found]           ` <F5DD545D-610B-40C7-827C-4CEAA2DF5F04@citrix.com>
     [not found]             ` <8B147463-7834-4525-AC10-36922338876F@citrix.com>
     [not found]               ` <b6add5ff3b6647eaab63265dbaf923bd@AMSPEX02CL03.citrite.net>
2018-10-05 10:31                 ` Paul Durrant
     [not found]                 ` <28341D09-548F-460C-8B22-43CA61EA1308@citrix.com>
2018-10-05 10:37                   ` George Dunlap
2018-10-05 10:38                   ` Paul Durrant
2018-10-05 11:17                     ` Jan Beulich
2018-10-05 11:44                       ` Paul Durrant
2018-10-04 10:45 ` [PATCH v14 5/9] memory: add check_get_page_from_gfn() as a wrapper Paul Durrant
2018-10-04 16:02   ` George Dunlap
2018-10-04 10:45 ` [PATCH v14 6/9] vtd: add missing check for shared EPT Paul Durrant
2018-10-04 10:45 ` [PATCH v14 7/9] vtd: add lookup_page method to iommu_ops Paul Durrant
2018-12-24 15:15   ` Andrew Cooper
2019-01-03  8:58     ` Paul Durrant [this message]
2018-10-04 10:45 ` [PATCH v14 8/9] mm / iommu: include need_iommu() test in iommu_use_hap_pt() Paul Durrant
2018-10-04 14:02   ` Jan Beulich
2018-10-04 16:23   ` George Dunlap
2018-10-05 16:03   ` Wei Liu
2018-10-05 16:13     ` Paul Durrant
2018-10-04 10:45 ` [PATCH v14 9/9] mm / iommu: split need_iommu() into has_iommu_pt() and need_iommu_pt_sync() Paul Durrant
2018-10-04 14:11   ` Jan Beulich
2018-10-04 16:23   ` George Dunlap
2018-10-04 17:15   ` Julien Grall
2018-10-05 14:50   ` Jan Beulich
2018-10-05 15:19     ` 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=380aff7acce54f81af1b8784c411b3ef@AMSPEX02CL03.citrite.net \
    --to=paul.durrant@citrix.com \
    --cc=Andrew.Cooper3@citrix.com \
    --cc=George.Dunlap@citrix.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.