From: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>
To: Iago Abal <iari-YidNj35/HaM@public.gmane.org>
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
Iago Abal <mail-nS/Qcn0WMKPsq35pWSNszA@public.gmane.org>
Subject: Re: [PATCH] iommu: fix double spin_lock_irqsave on `device_domain_lock'
Date: Thu, 3 Nov 2016 14:51:36 -0600 [thread overview]
Message-ID: <20161103205136.GA4930@suse.de> (raw)
In-Reply-To: <1476694480-4251-1-git-send-email-iari-YidNj35/HaM@public.gmane.org>
On Mon, Oct 17, 2016 at 10:54:40AM +0200, Iago Abal wrote:
> diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
> index a4407ea..05796a8 100644
> --- a/drivers/iommu/intel-iommu.c
> +++ b/drivers/iommu/intel-iommu.c
> @@ -1721,12 +1721,16 @@ static void disable_dmar_iommu(struct intel_iommu *iommu)
> if (!info->dev || !info->domain)
> continue;
>
> + spin_unlock_irqrestore(&device_domain_lock, flags);
> +
> domain = info->domain;
>
> dmar_remove_one_dev_info(domain, info->dev);
>
> if (!domain_type_is_vm_or_si(domain))
> domain_exit(domain);
> +
> + spin_lock_irqsave(&device_domain_lock, flags);
> }
> spin_unlock_irqrestore(&device_domain_lock, flags);
No, you can't just release the lock to re-aquire it in
dmar_remove_one_dev_info(). This introduces new races, as the list your
are walking is no longer protected by the lock. The right solution is to
call a variant of dmar_remove_one_dev_info() which does not take the
lock. It turns out this function already exists, so the patch looks like
below. Can you check if this is still correct and resubmit your patch?
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index a4407ea..3cadde2 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -1723,7 +1723,7 @@ static void disable_dmar_iommu(struct intel_iommu *iommu)
domain = info->domain;
- dmar_remove_one_dev_info(domain, info->dev);
+ __dmar_remove_one_dev_info(info);
if (!domain_type_is_vm_or_si(domain))
domain_exit(domain);
next prev parent reply other threads:[~2016-11-03 20:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-17 8:54 [PATCH] iommu: fix double spin_lock_irqsave on `device_domain_lock' Iago Abal
[not found] ` <1476694480-4251-1-git-send-email-iari-YidNj35/HaM@public.gmane.org>
2016-11-03 20:51 ` Joerg Roedel [this message]
[not found] ` <20161103205136.GA4930-l3A5Bk7waGM@public.gmane.org>
2016-11-04 9:38 ` Iago Abal
[not found] ` <CAGbDTvqDAEcLPNxHa6wvjTwpotDbZSSDL3MocVgj=LTMFG8Okw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-11-08 14:15 ` [PATCH] iommu/vt-d: Fix dead-locks in disable_dmar_iommu() path Joerg Roedel
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=20161103205136.GA4930@suse.de \
--to=jroedel-l3a5bk7wagm@public.gmane.org \
--cc=iari-YidNj35/HaM@public.gmane.org \
--cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=mail-nS/Qcn0WMKPsq35pWSNszA@public.gmane.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.