From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, "Zhang,
Bernice" <bernice.zhang@intel.com>,
Jacob Pan <jacob.jun.pan@linux.intel.com>,
Yian Chen <yian.chen@intel.com>, Joerg Roedel <jroedel@suse.de>,
Zhang@vger.kernel.org
Subject: [PATCH 4.9 06/14] iommu/vt-d: Fix PCI bus rescan device hot add
Date: Mon, 11 Jul 2022 11:06:25 +0200 [thread overview]
Message-ID: <20220711090535.707526215@linuxfoundation.org> (raw)
In-Reply-To: <20220711090535.517697227@linuxfoundation.org>
From: Yian Chen <yian.chen@intel.com>
commit 316f92a705a4c2bf4712135180d56f3cca09243a upstream.
Notifier calling chain uses priority to determine the execution
order of the notifiers or listeners registered to the chain.
PCI bus device hot add utilizes the notification mechanism.
The current code sets low priority (INT_MIN) to Intel
dmar_pci_bus_notifier and postpones DMAR decoding after adding
new device into IOMMU. The result is that struct device pointer
cannot be found in DRHD search for the new device's DMAR/IOMMU.
Subsequently, the device is put under the "catch-all" IOMMU
instead of the correct one. This could cause system hang when
device TLB invalidation is sent to the wrong IOMMU. Invalidation
timeout error and hard lockup have been observed and data
inconsistency/crush may occur as well.
This patch fixes the issue by setting a positive priority(1) for
dmar_pci_bus_notifier while the priority of IOMMU bus notifier
uses the default value(0), therefore DMAR decoding will be in
advance of DRHD search for a new device to find the correct IOMMU.
Following is a 2-step example that triggers the bug by simulating
PCI device hot add behavior in Intel Sapphire Rapids server.
echo 1 > /sys/bus/pci/devices/0000:6a:01.0/remove
echo 1 > /sys/bus/pci/rescan
Fixes: 59ce0515cdaf ("iommu/vt-d: Update DRHD/RMRR/ATSR device scope")
Cc: stable@vger.kernel.org # v3.15+
Reported-by: Zhang, Bernice <bernice.zhang@intel.com>
Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
Signed-off-by: Yian Chen <yian.chen@intel.com>
Link: https://lore.kernel.org/r/20220521002115.1624069-1-yian.chen@intel.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/iommu/dmar.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/drivers/iommu/dmar.c
+++ b/drivers/iommu/dmar.c
@@ -373,7 +373,7 @@ static int dmar_pci_bus_notifier(struct
static struct notifier_block dmar_pci_bus_nb = {
.notifier_call = dmar_pci_bus_notifier,
- .priority = INT_MIN,
+ .priority = 1,
};
static struct dmar_drhd_unit *
next prev parent reply other threads:[~2022-07-11 9:07 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-11 9:06 [PATCH 4.9 00/14] 4.9.323-rc1 review Greg Kroah-Hartman
2022-07-11 9:06 ` [PATCH 4.9 01/14] mm/slub: add missing TID updates on slab deactivation Greg Kroah-Hartman
2022-07-11 9:06 ` [PATCH 4.9 02/14] can: grcan: grcan_probe(): remove extra of_node_get() Greg Kroah-Hartman
2022-07-11 9:06 ` [PATCH 4.9 03/14] can: gs_usb: gs_usb_open/close(): fix memory leak Greg Kroah-Hartman
2022-07-11 9:06 ` [PATCH 4.9 04/14] usbnet: fix memory leak in error case Greg Kroah-Hartman
2022-07-11 9:06 ` [PATCH 4.9 05/14] net: rose: fix UAF bug caused by rose_t0timer_expiry Greg Kroah-Hartman
2022-07-11 9:06 ` Greg Kroah-Hartman [this message]
2022-07-11 9:06 ` [PATCH 4.9 07/14] video: of_display_timing.h: include errno.h Greg Kroah-Hartman
2022-07-11 9:06 ` [PATCH 4.9 08/14] xfs: remove incorrect ASSERT in xfs_rename Greg Kroah-Hartman
2022-07-11 9:06 ` [PATCH 4.9 09/14] pinctrl: sunxi: a83t: Fix NAND function name for some pins Greg Kroah-Hartman
2022-07-11 9:06 ` [PATCH 4.9 10/14] i2c: cadence: Unregister the clk notifier in error path Greg Kroah-Hartman
2022-07-11 9:06 ` [PATCH 4.9 11/14] ida: dont use BUG_ON() for debugging Greg Kroah-Hartman
2022-07-11 9:06 ` [PATCH 4.9 12/14] dmaengine: at_xdma: handle errors of at_xdmac_alloc_desc() correctly Greg Kroah-Hartman
2022-07-11 9:06 ` [PATCH 4.9 13/14] dmaengine: ti: Fix refcount leak in ti_dra7_xbar_route_allocate Greg Kroah-Hartman
2022-07-11 9:06 ` [PATCH 4.9 14/14] dmaengine: ti: Add missing put_device " Greg Kroah-Hartman
2022-07-11 11:08 ` [PATCH 4.9 00/14] 4.9.323-rc1 review Pavel Machek
2022-07-11 17:55 ` Florian Fainelli
2022-07-12 1:11 ` Guenter Roeck
2022-07-12 2:46 ` Shuah Khan
2022-07-12 8:59 ` Naresh Kamboju
2022-07-12 9:18 ` Jon Hunter
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=20220711090535.707526215@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=Zhang@vger.kernel.org \
--cc=bernice.zhang@intel.com \
--cc=jacob.jun.pan@linux.intel.com \
--cc=jroedel@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=yian.chen@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox