Commit fdf8efb
committed
KVM: x86: do not report a vCPU as preempted outside instruction boundaries
jira VULN-8766
cve CVE-2022-39189
commit-author Paolo Bonzini <pbonzini@redhat.com>
commit 6cd8824
If a vCPU is outside guest mode and is scheduled out, it might be in the
process of making a memory access. A problem occurs if another vCPU uses
the PV TLB flush feature during the period when the vCPU is scheduled
out, and a virtual address has already been translated but has not yet
been accessed, because this is equivalent to using a stale TLB entry.
To avoid this, only report a vCPU as preempted if sure that the guest
is at an instruction boundary. A rescheduling request will be delivered
to the host physical CPU as an external interrupt, so for simplicity
consider any vmexit *not* instruction boundary except for external
interrupts.
It would in principle be okay to report the vCPU as preempted also
if it is sleeping in kvm_vcpu_block(): a TLB flush IPI will incur the
vmentry/vmexit overhead unnecessarily, and optimistic spinning is
also unlikely to succeed. However, leave it for later because right
now kvm_vcpu_check_block() is doing memory accesses. Even
though the TLB flush issue only applies to virtual memory address,
it's very much preferrable to be conservative.
Reported-by: Jann Horn <jannh@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 6cd8824)
Signed-off-by: Brett Mastbergen <bmastbergen@ciq.com>1 parent e1161ff commit fdf8efb
4 files changed
+28
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
644 | 644 | | |
645 | 645 | | |
646 | 646 | | |
| 647 | + | |
647 | 648 | | |
648 | 649 | | |
649 | 650 | | |
| |||
1282 | 1283 | | |
1283 | 1284 | | |
1284 | 1285 | | |
| 1286 | + | |
| 1287 | + | |
1285 | 1288 | | |
1286 | 1289 | | |
1287 | 1290 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4176 | 4176 | | |
4177 | 4177 | | |
4178 | 4178 | | |
| 4179 | + | |
| 4180 | + | |
4179 | 4181 | | |
4180 | 4182 | | |
4181 | 4183 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6631 | 6631 | | |
6632 | 6632 | | |
6633 | 6633 | | |
| 6634 | + | |
6634 | 6635 | | |
6635 | 6636 | | |
6636 | 6637 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
289 | 289 | | |
290 | 290 | | |
291 | 291 | | |
| 292 | + | |
| 293 | + | |
292 | 294 | | |
293 | 295 | | |
294 | 296 | | |
| |||
4607 | 4609 | | |
4608 | 4610 | | |
4609 | 4611 | | |
| 4612 | + | |
| 4613 | + | |
| 4614 | + | |
| 4615 | + | |
| 4616 | + | |
| 4617 | + | |
| 4618 | + | |
| 4619 | + | |
| 4620 | + | |
| 4621 | + | |
| 4622 | + | |
| 4623 | + | |
| 4624 | + | |
4610 | 4625 | | |
4611 | 4626 | | |
4612 | 4627 | | |
| |||
10367 | 10382 | | |
10368 | 10383 | | |
10369 | 10384 | | |
| 10385 | + | |
| 10386 | + | |
| 10387 | + | |
| 10388 | + | |
| 10389 | + | |
| 10390 | + | |
| 10391 | + | |
10370 | 10392 | | |
10371 | 10393 | | |
10372 | 10394 | | |
| |||
0 commit comments