All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Tian, Kevin" <kevin.tian@intel.com>
To: "Xu, Quan" <quan.xu@intel.com>, "jbeulich@suse.com" <jbeulich@suse.com>
Cc: "Wu, Feng" <feng.wu@intel.com>,
	"Dong, Eddie" <eddie.dong@intel.com>,
	"george.dunlap@eu.citrix.com" <george.dunlap@eu.citrix.com>,
	"andrew.cooper3@citrix.com" <andrew.cooper3@citrix.com>,
	"tim@xen.org" <tim@xen.org>,
	"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>,
	"Nakajima, Jun" <jun.nakajima@intel.com>,
	"keir@xen.org" <keir@xen.org>
Subject: Re: [PATCH v2 2/2] VT-d: Fix vt-d flush timeout issue.
Date: Fri, 11 Dec 2015 07:27:43 +0000	[thread overview]
Message-ID: <AADFC41AFE54684AB9EE6CBC0274A5D15F741EDA@SHSMSX101.ccr.corp.intel.com> (raw)
In-Reply-To: <1449739990-66155-3-git-send-email-quan.xu@intel.com>

> From: Xu, Quan
> Sent: Thursday, December 10, 2015 5:33 PM
> 
> If IOTLB/Context/IETC flush is timeout, we should think
> all devices under this IOMMU cannot function correctly.
> So for each device under this IOMMU we'll mark it as
> unassignable and kill the domain owning the device.
> 
> If Device-TLB flush is timeout, we'll mark the target
> ATS device as unassignable and kill the domain owning
> this device.
> 
> If impacted domain is hardware domain, just throw out
> a warning. It's an open here whether we want to kill
> hardware domain (or directly panic hypervisor). Comments
> are welcomed.
> 
> Device marked as unassignable will be disallowed to be
> further assigned to any domain.
> 
> Signed-off-by: Quan Xu <quan.xu@intel.com>
> ---
>  xen/drivers/passthrough/vtd/extern.h  |  4 ++
>  xen/drivers/passthrough/vtd/iommu.c   |  6 +++
>  xen/drivers/passthrough/vtd/iommu.h   |  5 ++
>  xen/drivers/passthrough/vtd/qinval.c  | 86
> ++++++++++++++++++++++++++++++++++-
>  xen/drivers/passthrough/vtd/x86/ats.c | 16 +++++++
>  xen/include/xen/pci.h                 |  7 +++
>  6 files changed, 122 insertions(+), 2 deletions(-)
> 
[...]
> diff --git a/xen/drivers/passthrough/vtd/iommu.h
> b/xen/drivers/passthrough/vtd/iommu.h
> index ac71ed1..c3beaa6 100644
> --- a/xen/drivers/passthrough/vtd/iommu.h
> +++ b/xen/drivers/passthrough/vtd/iommu.h
> @@ -452,6 +452,11 @@ struct qinval_entry {
> 
>  #define RESERVED_VAL        0
> 
> +#define INVALID_DID    ((u16)~0)
> +#define INVALID_SEG    ((u16)~0)
> +#define INVALID_BUS    ((u8)~0)
> +#define INVALID_DEVFN  ((u8)~0)
> +

Are those invalid values defined by specification? Or if they
are software defined, does related mgmt. code guarantee
that they won't be allocated?

>  #define TYPE_INVAL_CONTEXT      0x1
>  #define TYPE_INVAL_IOTLB        0x2
>  #define TYPE_INVAL_DEVICE_IOTLB 0x3
> diff --git a/xen/drivers/passthrough/vtd/qinval.c b/xen/drivers/passthrough/vtd/qinval.c
> index 990baf2..bf7f5b0 100644
> --- a/xen/drivers/passthrough/vtd/qinval.c
> +++ b/xen/drivers/passthrough/vtd/qinval.c
> @@ -27,12 +27,62 @@
>  #include "dmar.h"
>  #include "vtd.h"
>  #include "extern.h"
> +#include "../ats.h"
> 
>  static int __read_mostly iommu_qi_timeout_ms = 1;
>  integer_param("iommu_qi_timeout_ms", iommu_qi_timeout_ms);
> 
>  #define IOMMU_QI_TIMEOUT (iommu_qi_timeout_ms * MILLISECS(1))
> 
> +void invalidate_timeout(struct iommu *iommu, int type, u16 did,
> +                        u16 seg, u8 bus, u8 devfn)
> +{
> +    struct domain *d;
> +    unsigned long nr_dom, i;
> +    struct pci_dev *pdev;
> +
> +    switch (type) {
> +    case TYPE_INVAL_IOTLB:
> +    case TYPE_INVAL_CONTEXT:
> +    case TYPE_INVAL_IEC:
> +        nr_dom = cap_ndoms(iommu->cap);
> +        i = find_first_bit(iommu->domid_bitmap, nr_dom);
> +        while ( i < nr_dom ) {
> +            d = rcu_lock_domain_by_id(iommu->domid_map[i]);
> +            ASSERT(d);
> +
> +            /* Mark the devices as unassignable. */
> +            for_each_pdev(d, pdev)
> +                mark_pdev_unassignable(pdev);
> +            if ( d != hardware_domain )
> +                domain_kill(d);
> +
> +            rcu_unlock_domain(d);
> +            i = find_next_bit(iommu->domid_bitmap, nr_dom, i + 1);
> +        }
> +        break;
> +
> +    case TYPE_INVAL_DEVICE_IOTLB:
> +        d = rcu_lock_domain_by_id(iommu->domid_map[did]);
> +        ASSERT(d);
> +        for_each_pdev(d, pdev)
> +            if ( (pdev->seg == seg) &&
> +                 (pdev->bus == bus) &&
> +                 (pdev->devfn == devfn) )
> +                mark_pdev_unassignable(pdev);

Once found you can break the for loop immediately since BDF is unique.

Thanks
Kevin

  parent reply	other threads:[~2015-12-11  7:27 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-10  9:33 [PATCH v2 0/2] VT-d flush issue Quan Xu
2015-12-10  9:33 ` [PATCH v2 1/2] VT-d: Reduce spin timeout to 1ms, which can be boot-time changed Quan Xu
2015-12-10 19:03   ` Andrew Cooper
2015-12-11  2:09     ` Xu, Quan
2015-12-11  7:00       ` Tian, Kevin
2015-12-11  7:29         ` Xu, Quan
2015-12-11  8:37       ` Andrew Cooper
2015-12-11  8:45         ` Xu, Quan
2015-12-11 10:01   ` Jan Beulich
2015-12-11 14:03     ` Xu, Quan
2015-12-12  9:03     ` Xu, Quan
2015-12-14  8:18       ` Jan Beulich
2015-12-14  8:31         ` Xu, Quan
2015-12-14  8:49           ` Jan Beulich
2015-12-10  9:33 ` [PATCH v2 2/2] VT-d: Fix vt-d flush timeout issue Quan Xu
2015-12-10 19:05   ` Andrew Cooper
2015-12-11  5:37     ` Xu, Quan
2015-12-11  8:38       ` Andrew Cooper
2015-12-11  8:42         ` Xu, Quan
2015-12-11  7:27   ` Tian, Kevin [this message]
2015-12-11  8:01     ` Xu, Quan
2015-12-11 10:04       ` Jan Beulich
2015-12-11 14:00         ` Xu, Quan
2015-12-11 14:12           ` Xu, Quan

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=AADFC41AFE54684AB9EE6CBC0274A5D15F741EDA@SHSMSX101.ccr.corp.intel.com \
    --to=kevin.tian@intel.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=eddie.dong@intel.com \
    --cc=feng.wu@intel.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=jun.nakajima@intel.com \
    --cc=keir@xen.org \
    --cc=quan.xu@intel.com \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xen.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.