Commit 526606b
iommu/amd: Fix Invalid wait context issue
With commit c4cb231 ("iommu/amd: Add support for enable/disable IOPF")
we are hitting below issue. This happens because in IOPF enablement path
it holds spin lock with irq disable and then tries to take mutex lock.
dmesg:
-----
[ 0.938739] =============================
[ 0.938740] [ BUG: Invalid wait context ]
[ 0.938742] 6.10.0-rc1+ #1 Not tainted
[ 0.938745] -----------------------------
[ 0.938746] swapper/0/1 is trying to lock:
[ 0.938748] ffffffff8c9f01d8 (&port_lock_key){....}-{3:3}, at: serial8250_console_write+0x78/0x4a0
[ 0.938767] other info that might help us debug this:
[ 0.938768] context-{5:5}
[ 0.938769] 7 locks held by swapper/0/1:
[ 0.938772] #0: ffff888101a91310 (&group->mutex){+.+.}-{4:4}, at: bus_iommu_probe+0x70/0x160
[ 0.938790] #1: ffff888101d1f1b8 (&domain->lock){....}-{3:3}, at: amd_iommu_attach_device+0xa5/0x700
[ 0.938799] #2: ffff888101cc3d18 (&dev_data->lock){....}-{3:3}, at: amd_iommu_attach_device+0xc5/0x700
[ 0.938806] #3: ffff888100052830 (&iommu->lock){....}-{2:2}, at: amd_iommu_iopf_add_device+0x3f/0xa0
[ 0.938813] #4: ffffffff8945a340 (console_lock){+.+.}-{0:0}, at: _printk+0x48/0x50
[ 0.938822] #5: ffffffff8945a390 (console_srcu){....}-{0:0}, at: console_flush_all+0x58/0x4e0
[ 0.938867] #6: ffffffff82459f80 (console_owner){....}-{0:0}, at: console_flush_all+0x1f0/0x4e0
[ 0.938872] stack backtrace:
[ 0.938874] CPU: 2 PID: 1 Comm: swapper/0 Not tainted 6.10.0-rc1+ #1
[ 0.938877] Hardware name: HP HP EliteBook 745 G3/807E, BIOS N73 Ver. 01.39 04/16/2019
Fix above issue by re-arranging code in attach device path:
- move device PASID/IOPF enablement outside lock in AMD IOMMU driver.
This is safe as core layer holds group->mutex lock before calling
iommu_ops->attach_dev.
Reported-by: Borislav Petkov <bp@alien8.de>
Reported-by: Mikhail Gavrilov <mikhail.v.gavrilov@gmail.com>
Reported-by: Chris Bainbridge <chris.bainbridge@gmail.com>
Fixes: c4cb231 ("iommu/amd: Add support for enable/disable IOPF")
Tested-by: Borislav Petkov <bp@alien8.de>
Tested-by: Chris Bainbridge <chris.bainbridge@gmail.com>
Tested-by: Mikhail Gavrilov <mikhail.v.gavrilov@gmail.com>
Signed-off-by: Vasant Hegde <vasant.hegde@amd.com>
Link: https://lore.kernel.org/r/20240530084801.10758-1-vasant.hegde@amd.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>1 parent 48dc345 commit 526606b
2 files changed
+28
-42
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2032 | 2032 | | |
2033 | 2033 | | |
2034 | 2034 | | |
2035 | | - | |
2036 | 2035 | | |
2037 | 2036 | | |
2038 | 2037 | | |
| |||
2047 | 2046 | | |
2048 | 2047 | | |
2049 | 2048 | | |
2050 | | - | |
| 2049 | + | |
2051 | 2050 | | |
2052 | 2051 | | |
2053 | 2052 | | |
2054 | 2053 | | |
2055 | | - | |
2056 | | - | |
2057 | | - | |
2058 | | - | |
2059 | | - | |
2060 | | - | |
2061 | | - | |
2062 | | - | |
2063 | | - | |
2064 | | - | |
2065 | | - | |
2066 | | - | |
2067 | | - | |
2068 | | - | |
2069 | 2054 | | |
2070 | 2055 | | |
2071 | | - | |
2072 | | - | |
2073 | | - | |
2074 | 2056 | | |
2075 | 2057 | | |
2076 | 2058 | | |
| |||
2163 | 2145 | | |
2164 | 2146 | | |
2165 | 2147 | | |
| 2148 | + | |
| 2149 | + | |
| 2150 | + | |
| 2151 | + | |
| 2152 | + | |
2166 | 2153 | | |
2167 | 2154 | | |
2168 | 2155 | | |
2169 | 2156 | | |
2170 | 2157 | | |
2171 | 2158 | | |
2172 | 2159 | | |
2173 | | - | |
2174 | | - | |
2175 | | - | |
2176 | | - | |
2177 | 2160 | | |
2178 | 2161 | | |
2179 | 2162 | | |
| |||
2485 | 2468 | | |
2486 | 2469 | | |
2487 | 2470 | | |
| 2471 | + | |
2488 | 2472 | | |
2489 | 2473 | | |
2490 | 2474 | | |
| |||
2517 | 2501 | | |
2518 | 2502 | | |
2519 | 2503 | | |
2520 | | - | |
| 2504 | + | |
| 2505 | + | |
| 2506 | + | |
| 2507 | + | |
| 2508 | + | |
| 2509 | + | |
| 2510 | + | |
| 2511 | + | |
| 2512 | + | |
| 2513 | + | |
| 2514 | + | |
| 2515 | + | |
| 2516 | + | |
| 2517 | + | |
| 2518 | + | |
| 2519 | + | |
| 2520 | + | |
2521 | 2521 | | |
2522 | 2522 | | |
2523 | 2523 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
251 | | - | |
252 | 251 | | |
253 | 252 | | |
254 | 253 | | |
255 | 254 | | |
256 | 255 | | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
| 256 | + | |
| 257 | + | |
263 | 258 | | |
264 | 259 | | |
265 | 260 | | |
266 | | - | |
| 261 | + | |
267 | 262 | | |
268 | 263 | | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
| 264 | + | |
273 | 265 | | |
274 | 266 | | |
275 | 267 | | |
276 | 268 | | |
277 | 269 | | |
278 | 270 | | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | 271 | | |
284 | 272 | | |
285 | | - | |
286 | | - | |
287 | 273 | | |
0 commit comments