xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Roman Shaposhnik <roman@zededa.com>
To: "Roger Pau Monné" <roger.pau@citrix.com>
Cc: "jgross@suse.com" <jgross@suse.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Paul Durrant <Paul.Durrant@citrix.com>,
	"jbeulich@suse.com" <jbeulich@suse.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	"boris.ostrovsky@oracle.com" <boris.ostrovsky@oracle.com>
Subject: Re: [Xen-devel] [BUG] After upgrade to Xen 4.12.0 iommu=no-igfx
Date: Thu, 1 Aug 2019 11:25:04 -0700	[thread overview]
Message-ID: <CAMmSBy9y6hHQfDgcDFmKiRw9QiRSgcxHAq6Qo=o7apTR2EuusA@mail.gmail.com> (raw)
In-Reply-To: <20190801081559.wruxck32h5bum2va@Air-de-Roger>

On Thu, Aug 1, 2019 at 1:16 AM Roger Pau Monné <roger.pau@citrix.com> wrote:
>
> On Wed, Jul 31, 2019 at 02:03:24PM -0700, Roman Shaposhnik wrote:
> > On Wed, Jul 31, 2019 at 12:46 PM Andrew Cooper
> > <andrew.cooper3@citrix.com> wrote:
> > >
> > > On 31/07/2019 20:35, Roman Shaposhnik wrote:
> > > > On Wed, Jul 31, 2019 at 1:43 AM Roger Pau Monné <roger.pau@citrix.com> wrote:
> > > >> On Wed, Jul 31, 2019 at 10:36:31AM +0200, Roger Pau Monné wrote:
> > > >>> On Tue, Jul 30, 2019 at 10:55:24AM -0700, Roman Shaposhnik wrote:
> > > >>>> Sorry -- got a bit distracted yesterday. Attached is the log with only
> > > >>>> your latest patch attached. Interestingly enough the box booted fine
> > > >>>> without screen artifacts. So I guess we're getting closer...
> > > >>>>
> > > >>>> Thanks for all the help!
> > > >>> That's quite weird, there's no functional changes between the
> > > >>> previous patches and this one, the only difference is that this patch
> > > >>> has more verbose output.
> > > >>>
> > > >>> Are you sure you didn't have any local patches on top of Xen that
> > > >>> could explain this difference in behaviour?
> > > >> FWIW, can you please try the plain patch again:
> > > >>
> > > >> https://lists.xenproject.org/archives/html/xen-devel/2019-07/msg01547.html
> > > >>
> > > >> And report back?
> > > >>
> > > >> I would like to get this committed ASAP if it does fix your issue.
> > > > I'd like to say that it did -- but I tried it again just now and it
> > > > still garbled screen and tons of:
> > > >
> > > > (XEN) printk: 26665 messages suppressed.
> > > > (XEN) [VT-D]DMAR:[DMA Read] Request device [0000:00:02.0] fault addr
> > > > 8e14c000, iommu reg = ffff82c0008de000
> > > >
> > > > I'm very much confused by what's going on, but it seems that's the
> > > > case -- adding those debug print statements make the issue go away
> > > >
> > > > Here are the patches that are being applied:
> > > >    NOT WORKING:
> > > > https://github.com/rvs/eve/blob/xen-bug/pkg/xen/01-iommu-mappings.patch
> > > >
> > > >    WORKING: https://github.com/rvs/eve/blob/a1291fcd4e669df2a63285afb5e8b4841f45c1c8/pkg/xen/01-iommu-mappings.patch
> > > >
> > > > At this point I'm really not sure what's going on.
> > >
> > > Ok.  seeing as you've double checked this, the mystery deepens.
> > >
> > > My bet is on the intel_iommu_lookup_page() call having side effects[1].
> > > If you take out the debugging in the middle of the loop in
> > > rmrr_identity_mapping(), does the problem reproduce again?
> > >
> > > ~Andrew
> > >
> > > [1] Looking at the internals of addr_to_dma_page_maddr(), it does 100%
> > > more memory allocation and higher-level PTE construction than looks wise
> > > for what is supposed to be a getter.
> >
> > Yup. That's what it is -- intel_iommu_lookup_page() seems to be the culprit.
> >
> > I've did the experiment in the other direction -- adding a dummy call:
> >      https://github.com/rvs/eve/blob/36aeeaa7c0a53474fb1ecef2ff587a86637df858/pkg/xen/01-iommu-mappings.patch#L23
> > on top of original Roger's patch makes system boot NORMALLY.
>
> I'm again quite lost, and I don't really understand why mappings added
> by arch_iommu_hwdom_init seems to work fine while mappings added by
> rmrr_identity_mapping don't.
>
> I have yet another patch for you to try, which attempts to mimic
> exactly what arch_iommu_hwdom_init does into rmrr_identity_mapping,
> can you please give it a try?
>
> This has the added bonus of limiting the use of
> {set/clear}_identity_p2m_entry to translated domains only, since
> rmrr_identity_mapping was the only caller against PV domains.
>
> Thanks, Roger.
> ---8<---
> diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
> index fef97c82f6..d36a58b1a6 100644
> --- a/xen/arch/x86/mm/p2m.c
> +++ b/xen/arch/x86/mm/p2m.c
> @@ -1341,10 +1341,8 @@ int set_identity_p2m_entry(struct domain *d, unsigned long gfn_l,
>
>      if ( !paging_mode_translate(p2m->domain) )
>      {
> -        if ( !need_iommu_pt_sync(d) )
> -            return 0;
> -        return iommu_legacy_map(d, _dfn(gfn_l), _mfn(gfn_l), PAGE_ORDER_4K,
> -                                IOMMUF_readable | IOMMUF_writable);
> +        ASSERT_UNREACHABLE();
> +        return -ENXIO;
>      }
>
>      gfn_lock(p2m, gfn, 0);
> @@ -1432,9 +1430,8 @@ int clear_identity_p2m_entry(struct domain *d, unsigned long gfn_l)
>
>      if ( !paging_mode_translate(d) )
>      {
> -        if ( !need_iommu_pt_sync(d) )
> -            return 0;
> -        return iommu_legacy_unmap(d, _dfn(gfn_l), PAGE_ORDER_4K);
> +        ASSERT_UNREACHABLE();
> +        return -ENXIO;
>      }
>
>      gfn_lock(p2m, gfn, 0);
> diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c
> index 5d72270c5b..62df5ca5aa 100644
> --- a/xen/drivers/passthrough/vtd/iommu.c
> +++ b/xen/drivers/passthrough/vtd/iommu.c
> @@ -1969,6 +1969,7 @@ static int rmrr_identity_mapping(struct domain *d, bool_t map,
>      unsigned long end_pfn = PAGE_ALIGN_4K(rmrr->end_address) >> PAGE_SHIFT_4K;
>      struct mapped_rmrr *mrmrr;
>      struct domain_iommu *hd = dom_iommu(d);
> +    unsigned int flush_flags = 0;
>
>      ASSERT(pcidevs_locked());
>      ASSERT(rmrr->base_address < rmrr->end_address);
> @@ -1982,7 +1983,7 @@ static int rmrr_identity_mapping(struct domain *d, bool_t map,
>          if ( mrmrr->base == rmrr->base_address &&
>               mrmrr->end == rmrr->end_address )
>          {
> -            int ret = 0;
> +            int ret = 0, err;
>
>              if ( map )
>              {
> @@ -1995,13 +1996,20 @@ static int rmrr_identity_mapping(struct domain *d, bool_t map,
>
>              while ( base_pfn < end_pfn )
>              {
> -                if ( clear_identity_p2m_entry(d, base_pfn) )
> -                    ret = -ENXIO;
> +                if ( paging_mode_translate(d) )
> +                    ret = clear_identity_p2m_entry(d, base_pfn);
> +                else
> +                    ret = iommu_unmap(d, _dfn(base_pfn), PAGE_ORDER_4K,
> +                                      &flush_flags);
>                  base_pfn++;
>              }
>
>              list_del(&mrmrr->list);
>              xfree(mrmrr);
> +            /* Keep the previous error code if there's one. */
> +            err = iommu_iotlb_flush_all(d, flush_flags);
> +            if ( !ret )
> +                ret = err;
>              return ret;
>          }
>      }
> @@ -2011,8 +2019,13 @@ static int rmrr_identity_mapping(struct domain *d, bool_t map,
>
>      while ( base_pfn < end_pfn )
>      {
> -        int err = set_identity_p2m_entry(d, base_pfn, p2m_access_rw, flag);
> +        int err;
>
> +        if ( paging_mode_translate(d) )
> +            err = set_identity_p2m_entry(d, base_pfn, p2m_access_rw, flag);
> +        else
> +            err = iommu_map(d, _dfn(base_pfn), _mfn(base_pfn), PAGE_ORDER_4K,
> +                            IOMMUF_readable | IOMMUF_writable, &flush_flags);
>          if ( err )
>              return err;
>          base_pfn++;
> @@ -2026,7 +2039,7 @@ static int rmrr_identity_mapping(struct domain *d, bool_t map,
>      mrmrr->count = 1;
>      list_add_tail(&mrmrr->list, &hd->arch.mapped_rmrrs);
>
> -    return 0;
> +    return iommu_iotlb_flush_all(d, flush_flags);
>  }
>
>  static int intel_iommu_add_device(u8 devfn, struct pci_dev *pdev)

This patch completely fixes the problem for me!

Thanks Roger! I'd love to see this in Xen 4.13

Thanks,
Roman.

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

  reply	other threads:[~2019-08-01 18:25 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-19 19:31 [Xen-devel] [BUG] After upgrade to Xen 4.12.0 iommu=no-igfx Roman Shaposhnik
2019-07-19 20:02 ` Roman Shaposhnik
2019-07-22  8:20   ` Paul Durrant
2019-07-22 11:48     ` Roger Pau Monné
2019-07-22 11:54       ` Paul Durrant
2019-07-22 13:48         ` Roger Pau Monné
2019-07-22 14:03           ` Paul Durrant
2019-07-22 14:39             ` Roger Pau Monné
2019-07-22 15:02               ` Paul Durrant
2019-07-22 15:21                 ` Roger Pau Monné
2019-07-22 23:36                   ` Roman Shaposhnik
2019-07-22 23:47                     ` Andrew Cooper
2019-07-23 17:32                       ` Roman Shaposhnik
2019-07-23 17:35                         ` Andrew Cooper
2019-07-23 17:48                           ` Roman Shaposhnik
2019-07-23 17:50                             ` Andrew Cooper
2019-07-23 17:58                               ` Roman Shaposhnik
2019-07-23 18:12                                 ` Andrew Cooper
2019-07-23 18:25                                   ` Roman Shaposhnik
2019-07-26  7:58                                     ` Jan Beulich
2019-07-30 17:56                                       ` Roman Shaposhnik
2019-07-31  8:34                                         ` Jan Beulich
2019-07-31  8:58                                           ` Andrew Cooper
2019-07-31  9:30                                             ` Jan Beulich
2019-07-31 19:37                                               ` Roman Shaposhnik
2019-07-24 12:00                                 ` Jan Beulich
2019-07-24 12:04                                   ` Jan Beulich
2019-07-24 11:23                         ` Andrew Cooper
2019-07-24 11:40                           ` Andrew Cooper
2019-07-24 14:11                         ` Roger Pau Monné
2019-07-26  0:47                           ` Roman Shaposhnik
2019-07-26  9:35                             ` Roger Pau Monné
2019-07-30  9:21                               ` Roger Pau Monné
2019-07-30 17:55                                 ` Roman Shaposhnik
2019-07-31  8:31                                   ` Jan Beulich
2019-07-31  8:36                                   ` Roger Pau Monné
2019-07-31  8:43                                     ` Roger Pau Monné
2019-07-31 19:35                                       ` Roman Shaposhnik
2019-07-31 19:46                                         ` Andrew Cooper
2019-07-31 21:03                                           ` Roman Shaposhnik
2019-08-01  8:15                                             ` Roger Pau Monné
2019-08-01 18:25                                               ` Roman Shaposhnik [this message]
2019-08-02  8:05                                                 ` Roger Pau Monné
2019-08-06 16:17                                                   ` Roger Pau Monné
2019-08-06 21:48                                                     ` Roman Shaposhnik
2019-08-07  7:08                                                       ` Jan Beulich
2019-08-07  9:57                                                         ` Roger Pau Monné
2019-08-07 10:03                                                           ` Jan Beulich
2019-08-07  7:35                                                       ` Roger Pau Monné
2019-08-07  8:31                                                         ` Jan Beulich
2019-08-07 10:17                                                           ` Roger Pau Monné
2019-08-12  8:57                                                         ` Roger Pau Monné
2019-08-13 19:24                                                           ` Roman Shaposhnik
2019-08-14  8:06                                                             ` Roger Pau Monné
2019-08-19  5:00                                                               ` Roman Shaposhnik
2019-08-19  8:16                                                                 ` Roger Pau Monné
2019-08-20  2:03                                                                   ` Roman Shaposhnik
2019-08-01  7:35                                           ` Jan Beulich
2019-07-31 19:30                                     ` Roman Shaposhnik
2019-08-01  8:45                                       ` Roger Pau Monné
2019-08-01 18:19                                         ` Roman Shaposhnik
2019-07-20 16:39 ` Andrew Cooper
2019-07-22  8:03   ` Paul Durrant
2019-07-24 17:42 ` Rich Persaud
2019-07-26  1:13   ` Roman Shaposhnik

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='CAMmSBy9y6hHQfDgcDFmKiRw9QiRSgcxHAq6Qo=o7apTR2EuusA@mail.gmail.com' \
    --to=roman@zededa.com \
    --cc=Paul.Durrant@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=jbeulich@suse.com \
    --cc=jgross@suse.com \
    --cc=roger.pau@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).