Commit 1876dd6
committed
KVM: x86: Add fastpath handling of HLT VM-Exits
Add a fastpath for HLT VM-Exits by immediately re-entering the guest if
it has a pending wake event. When virtual interrupt delivery is enabled,
i.e. when KVM doesn't need to manually inject interrupts, this allows KVM
to stay in the fastpath run loop when a vIRQ arrives between the guest
doing CLI and STI;HLT. Without AMD's Idle HLT-intercept support, the CPU
generates a HLT VM-Exit even though KVM will immediately resume the guest.
Note, on bare metal, it's relatively uncommon for a modern guest kernel to
actually trigger this scenario, as the window between the guest checking
for a wake event and committing to HLT is quite small. But in a nested
environment, the timings change significantly, e.g. rudimentary testing
showed that ~50% of HLT exits where HLT-polling was successful would be
serviced by this fastpath, i.e. ~50% of the time that a nested vCPU gets
a wake event before KVM schedules out the vCPU, the wake event was pending
even before the VM-Exit.
Link: https://lore.kernel.org/all/[email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Sean Christopherson <[email protected]>1 parent 70cdd23 commit 1876dd6
4 files changed
+36
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4147 | 4147 | | |
4148 | 4148 | | |
4149 | 4149 | | |
| 4150 | + | |
| 4151 | + | |
4150 | 4152 | | |
4151 | 4153 | | |
4152 | 4154 | | |
4153 | | - | |
4154 | | - | |
| 4155 | + | |
| 4156 | + | |
| 4157 | + | |
| 4158 | + | |
4155 | 4159 | | |
| 4160 | + | |
| 4161 | + | |
| 4162 | + | |
| 4163 | + | |
| 4164 | + | |
4156 | 4165 | | |
4157 | 4166 | | |
4158 | 4167 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7265 | 7265 | | |
7266 | 7266 | | |
7267 | 7267 | | |
| 7268 | + | |
| 7269 | + | |
7268 | 7270 | | |
7269 | 7271 | | |
7270 | 7272 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11363 | 11363 | | |
11364 | 11364 | | |
11365 | 11365 | | |
11366 | | - | |
| 11366 | + | |
| 11367 | + | |
| 11368 | + | |
| 11369 | + | |
11367 | 11370 | | |
11368 | 11371 | | |
11369 | 11372 | | |
| |||
11388 | 11391 | | |
11389 | 11392 | | |
11390 | 11393 | | |
| 11394 | + | |
| 11395 | + | |
| 11396 | + | |
| 11397 | + | |
| 11398 | + | |
| 11399 | + | |
| 11400 | + | |
| 11401 | + | |
| 11402 | + | |
| 11403 | + | |
| 11404 | + | |
| 11405 | + | |
| 11406 | + | |
| 11407 | + | |
| 11408 | + | |
| 11409 | + | |
| 11410 | + | |
| 11411 | + | |
11391 | 11412 | | |
11392 | 11413 | | |
11393 | 11414 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
334 | 334 | | |
335 | 335 | | |
336 | 336 | | |
| 337 | + | |
337 | 338 | | |
338 | 339 | | |
339 | 340 | | |
| |||
0 commit comments