Commit dab285e
committed
KVM: x86/mmu: Alloc TDP MMU roots while holding mmu_lock for read
Allocate TDP MMU roots while holding mmu_lock for read, and instead use
tdp_mmu_pages_lock to guard against duplicate roots. This allows KVM to
create new roots without forcing kvm_tdp_mmu_zap_invalidated_roots() to
yield, e.g. allows vCPUs to load new roots after memslot deletion without
forcing the zap thread to detect contention and yield (or complete if the
kernel isn't preemptible).
Note, creating a new TDP MMU root as an mmu_lock reader is safe for two
reasons: (1) paths that must guarantee all roots/SPTEs are *visited* take
mmu_lock for write and so are still mutually exclusive, e.g. mmu_notifier
invalidations, and (2) paths that require all roots/SPTEs to *observe*
some given state without holding mmu_lock for write must ensure freshness
through some other means, e.g. toggling dirty logging must first wait for
SRCU readers to recognize the memslot flags change before processing
existing roots/SPTEs.
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Sean Christopherson <[email protected]>1 parent f5238c2 commit dab285e
1 file changed
+22
-33
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | 226 | | |
242 | 227 | | |
243 | 228 | | |
244 | 229 | | |
| 230 | + | |
245 | 231 | | |
246 | 232 | | |
247 | 233 | | |
248 | 234 | | |
249 | | - | |
| 235 | + | |
250 | 236 | | |
251 | 237 | | |
252 | 238 | | |
253 | 239 | | |
254 | 240 | | |
255 | | - | |
256 | | - | |
257 | 241 | | |
258 | | - | |
259 | | - | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
260 | 246 | | |
261 | | - | |
| 247 | + | |
262 | 248 | | |
263 | 249 | | |
264 | | - | |
265 | | - | |
266 | | - | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
267 | 256 | | |
268 | | - | |
269 | | - | |
270 | | - | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
271 | 262 | | |
272 | 263 | | |
273 | 264 | | |
| |||
280 | 271 | | |
281 | 272 | | |
282 | 273 | | |
283 | | - | |
284 | | - | |
285 | 274 | | |
286 | | - | |
287 | 275 | | |
288 | | - | |
289 | | - | |
290 | | - | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
291 | 280 | | |
292 | 281 | | |
293 | 282 | | |
| |||
0 commit comments