* [PATCH 1/1] iommu/vt-d: Check identity map for hot-added devices
@ 2019-02-25 2:46 Lu Baolu
2019-02-26 10:56 ` Joerg Roedel
[not found] ` <20190226212401.7F17B21873@mail.kernel.org>
0 siblings, 2 replies; 4+ messages in thread
From: Lu Baolu @ 2019-02-25 2:46 UTC (permalink / raw)
To: joro, dwmw2
Cc: ashok.raj, jacob.jun.pan, jisben, xmdong, iommu, linux-kernel,
Lu Baolu, Fenghua Yu, stable
The Intel IOMMU driver will put devices into a static identity
mapped domain during boot if the kernel parameter "iommu=pt" is
used. That means the IOMMU hardware will translate a DMA address
into the same memory address.
Unfortunately, hot-added devices are not subject to this. That
results in some devices not working properly after hot added. A
quick way to reproduce this issue is to boot a system with
iommu=pt
and, remove then readd the pci device with
echo 1 > /sys/bus/pci/devices/[pci_source_id]/remove
echo 1 > /sys/bus/pci/rescan
You will find the identity mapped domain was replaced with a
normal domain.
Cc: Ashok Raj <ashok.raj@intel.com>
Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: stable@vger.kernel.org
Reported-by: Jis Ben <jisben@google.com>
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Tested-by: James Dong <xmdong@google.com>
---
drivers/iommu/intel-iommu.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index af23cfc2a05e..4f77657a9c25 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -4564,16 +4564,19 @@ static int device_notifier(struct notifier_block *nb,
if (iommu_dummy(dev))
return 0;
- if (action != BUS_NOTIFY_REMOVED_DEVICE)
- return 0;
-
- domain = find_domain(dev);
- if (!domain)
- return 0;
+ if (action == BUS_NOTIFY_REMOVED_DEVICE) {
+ domain = find_domain(dev);
+ if (!domain)
+ return 0;
- dmar_remove_one_dev_info(dev);
- if (!domain_type_is_vm_or_si(domain) && list_empty(&domain->devices))
- domain_exit(domain);
+ dmar_remove_one_dev_info(dev);
+ if (!domain_type_is_vm_or_si(domain) &&
+ list_empty(&domain->devices))
+ domain_exit(domain);
+ } else if (action == BUS_NOTIFY_ADD_DEVICE) {
+ if (iommu_should_identity_map(dev, 1))
+ domain_add_dev_info(si_domain, dev);
+ }
return 0;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] iommu/vt-d: Check identity map for hot-added devices
2019-02-25 2:46 [PATCH 1/1] iommu/vt-d: Check identity map for hot-added devices Lu Baolu
@ 2019-02-26 10:56 ` Joerg Roedel
[not found] ` <20190226212401.7F17B21873@mail.kernel.org>
1 sibling, 0 replies; 4+ messages in thread
From: Joerg Roedel @ 2019-02-26 10:56 UTC (permalink / raw)
To: Lu Baolu
Cc: dwmw2, ashok.raj, jacob.jun.pan, jisben, xmdong, iommu,
linux-kernel, Fenghua Yu, stable
On Mon, Feb 25, 2019 at 10:46:36AM +0800, Lu Baolu wrote:
> drivers/iommu/intel-iommu.c | 21 ++++++++++++---------
> 1 file changed, 12 insertions(+), 9 deletions(-)
Added a Fixes: tag and applied the patch, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] iommu/vt-d: Check identity map for hot-added devices
[not found] ` <20190226212401.7F17B21873@mail.kernel.org>
@ 2019-02-28 9:49 ` Joerg Roedel
2019-03-01 1:25 ` Lu Baolu
0 siblings, 1 reply; 4+ messages in thread
From: Joerg Roedel @ 2019-02-28 9:49 UTC (permalink / raw)
To: Sasha Levin, Lu Baolu; +Cc: dwmw2, ashok.raj, jacob.jun.pan, Fenghua Yu, stable
Hi Sasha,
Thanks for the heads-up!
On Tue, Feb 26, 2019 at 09:24:00PM +0000, Sasha Levin wrote:
> Hi,
>
> [This is an automated email]
>
> This commit has been processed because it contains a -stable tag.
> The stable tag indicates that it's relevant for the following trees: all
>
> The bot has tested the following trees: v4.20.12, v4.19.25, v4.14.103, v4.9.160, v4.4.176, v3.18.136.
>
Lu Baolu, can you please check for which stable trees this commit is
relevant and provide the backports of the patch (with dependencies if
necessary) to the relevant stable trees?
Thanks,
Joerg
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] iommu/vt-d: Check identity map for hot-added devices
2019-02-28 9:49 ` Joerg Roedel
@ 2019-03-01 1:25 ` Lu Baolu
0 siblings, 0 replies; 4+ messages in thread
From: Lu Baolu @ 2019-03-01 1:25 UTC (permalink / raw)
To: Joerg Roedel, Sasha Levin
Cc: baolu.lu, dwmw2, ashok.raj, jacob.jun.pan, Fenghua Yu, stable
Hi Joerg,
On 2/28/19 5:49 PM, Joerg Roedel wrote:
> Hi Sasha,
>
> Thanks for the heads-up!
>
> On Tue, Feb 26, 2019 at 09:24:00PM +0000, Sasha Levin wrote:
>> Hi,
>>
>> [This is an automated email]
>>
>> This commit has been processed because it contains a -stable tag.
>> The stable tag indicates that it's relevant for the following trees: all
>>
>> The bot has tested the following trees: v4.20.12, v4.19.25, v4.14.103, v4.9.160, v4.4.176, v3.18.136.
>>
>
> Lu Baolu, can you please check for which stable trees this commit is
> relevant and provide the backports of the patch (with dependencies if
> necessary) to the relevant stable trees?
>
Sure. Actually, I am doing this.
Best regards,
Lu Baolu
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-03-01 1:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-25 2:46 [PATCH 1/1] iommu/vt-d: Check identity map for hot-added devices Lu Baolu
2019-02-26 10:56 ` Joerg Roedel
[not found] ` <20190226212401.7F17B21873@mail.kernel.org>
2019-02-28 9:49 ` Joerg Roedel
2019-03-01 1:25 ` Lu Baolu
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.