From: Pankaj Gupta <pagupta@redhat.com>
To: Peter Xu <peterx@redhat.com>
Cc: qemu-devel@nongnu.org, yi l liu <yi.l.liu@intel.com>,
"\\ Michael S . Tsirkin \"; \"Alex Williamson\"; \"Marcel
Apfelbaum\"; \"Jintack Lim" <marcel@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2] intel_iommu: check misordered init when realize
Date: Fri, 24 Feb 2017 03:42:29 -0500 (EST) [thread overview]
Message-ID: <627376359.26348799.1487925749952.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <20170224071001.GE10022@pxdev.xzpeter.org>
> On Fri, Feb 24, 2017 at 01:35:10AM -0500, Pankaj Gupta wrote:
> >
> > >
> > > On Fri, Feb 24, 2017 at 12:07:33AM -0500, Pankaj Gupta wrote:
> > > > Hello Peter,
> > >
> > > Hi, Pankaj!
> > >
> > > >
> > > > This solution looks to check dependency of 'vfio-pci' over
> > > > 'intel-iommu'
> > > > before 'intel-iommu' is not initialized.
> > > >
> > > > Overall it looks good to me, just a small nit below.
> > > >
> > > > >
> > > > > Intel vIOMMU devices are created with "-device" parameter, while here
> > > > > actually we need to make sure the dmar device be created before other
> > > > > PCI devices (like vfio-pci) so that we know iommu_fn will be setup
> > > > > correctly before realizations of those PCI devices (it is sensible
> > > > > that
> > > > > PCI device fetch these info during its realization). Now this
> > > > > ordering
> > > > > yet cannot be achieved elsewhere, and devices will be created in the
> > > > > order that user specified. That might be dangerous.
> > > > >
> > > > > Here we add one more function to detect this kind of misordering
> > > > > issue,
> > > > > then report to guest. Currently, the only known device that is
> > > > > affected
> > > > > by this VT-d defect is the vfio-pci typed devices. So for now we just
> > > > > check against it to make sure we are safe.
> > > > >
> > > > > Signed-off-by: Peter Xu <peterx@redhat.com>
> > > > > ---
> > > > > hw/i386/intel_iommu.c | 22 ++++++++++++++++++++++
> > > > > 1 file changed, 22 insertions(+)
> > > > >
> > > > > diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
> > > > > index 22d8226..b723ece 100644
> > > > > --- a/hw/i386/intel_iommu.c
> > > > > +++ b/hw/i386/intel_iommu.c
> > > > > @@ -2560,6 +2560,24 @@ static bool vtd_decide_config(IntelIOMMUState
> > > > > *s,
> > > > > Error **errp)
> > > > > return true;
> > > > > }
> > > > >
> > > > > +/*
> > > > > + * TODO: we should have a better way to achieve the ordering rather
> > > > > + * than this misorder check explicitly against vfio-pci. After all,
> > > > > no
> > > > > + * one should be blamed for this, and vfio-pci did nothing wrong.
> > > > > + */
> > > > > +static bool vtd_detected_misorder_init(Error **errp)
> > > > > +{
> > > > > + Object *dev = object_resolve_path_type("", "vfio-pci", NULL);
> > > > > +
> > > > > + if (dev) {
> > > > > + error_setg(errp, "Please specify \"intel-iommu\" before all
> > > > > the
> > > > > rest
> > > >
> > > > "before all the rest" does not give much clue to user. Do
> > > > you
> > > > think better
> > > > error message would help? just a thought.
> > >
> > > Yes this is my intention to emphasize that we should possibly put
> > > intel-iommu even before all the PCI devices. As mentioned above (and
> > > also in the commit message), although vfio-pci is the only one that is
> > > affected by this, we should probably put intel-iommu even before all
> > > the rest of PCI devices. E.g., in the future we can have new devices
> > > that need this dependency as well (that vt-d being inited before that
> > > device), which is still legal imho.
> >
> > yes, something like this can help "intel-iommu should be specified as first
> > device"?
>
> I can switch this description if you prefer this one. :) Not sure
> whether this can be touched up during merge if this patch is good for
> 2.9, or I'll just repost with yours if there is further comments.
Sure.
>
> > Or we can just check for "intel-iommu" as first device at the start in
> > place of
> > checking for "vfio-pci". This will also help us to check for all other
> > devices.
>
> Actually your suggestion is just what I did in version 1. The problem
> is that, it's not easy to let vt-d really be the first device to be
> inited... Please check pc_q35_init(), within that we have:
>
> pc_vga_init(isa_bus, host_bus);
> pc_nic_init(isa_bus, host_bus);
>
> These are integrated devices along with ICH9. Such devices are
> possibly pci devices as well, but they are created much earlier than
> vt-d device, since that's still during machine init.
o.k.
Thanks,
Pankaj
>
> Thanks,
>
> -- peterx
>
next prev parent reply other threads:[~2017-02-24 8:42 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-24 4:29 [Qemu-devel] [PATCH v2] intel_iommu: check misordered init when realize Peter Xu
2017-02-24 5:07 ` Pankaj Gupta
2017-02-24 5:50 ` Peter Xu
2017-02-24 6:35 ` Pankaj Gupta
2017-02-24 7:10 ` Peter Xu
2017-02-24 8:42 ` Pankaj Gupta [this message]
2017-02-28 14:42 ` Marcel Apfelbaum
2017-03-01 2:36 ` Peter Xu
2017-03-01 3:23 ` Michael S. Tsirkin
2017-03-01 4:14 ` Jason Wang
2017-03-01 7:03 ` Marcel Apfelbaum
2017-03-01 8:43 ` Jason Wang
2017-03-01 9:05 ` Marcel Apfelbaum
2017-03-01 9:18 ` Peter Xu
2017-03-01 9:29 ` Marcel Apfelbaum
2017-03-01 9:59 ` Peter Xu
2017-03-01 12:32 ` Marcel Apfelbaum
2017-03-02 3:45 ` Peter Xu
2017-03-02 3:39 ` Peter Xu
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=627376359.26348799.1487925749952.JavaMail.zimbra@redhat.com \
--to=pagupta@redhat.com \
--cc=marcel@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=yi.l.liu@intel.com \
/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.