Commit 4346db6
KVM: x86: Force TLB flush on userspace changes to special registers
Userspace can directly modify the content of vCPU's CR0, CR3, and CR4 via
KVM_SYNC_X86_SREGS and KVM_SET_SREGS{,2}. Make sure that KVM flushes guest
TLB entries and paging-structure caches if a (partial) guest TLB flush is
architecturally required based on the CRn changes. To keep things simple,
flush whenever KVM resets the MMU context, i.e. if any bits in CR0, CR3,
CR4, or EFER are modified. This is extreme overkill, but stuffing state
from userspace is not such a hot path that preserving guest TLB state is a
priority.
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Michal Luczaj <mhal@rbox.co>
Link: https://lore.kernel.org/r/20230814222358.707877-3-mhal@rbox.co
[sean: call out that the flushing on MMU context resets is for simplicity]
Signed-off-by: Sean Christopherson <seanjc@google.com>1 parent 9dbb029 commit 4346db6
1 file changed
Lines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11564 | 11564 | | |
11565 | 11565 | | |
11566 | 11566 | | |
11567 | | - | |
| 11567 | + | |
11568 | 11568 | | |
| 11569 | + | |
| 11570 | + | |
11569 | 11571 | | |
11570 | 11572 | | |
11571 | 11573 | | |
| |||
11606 | 11608 | | |
11607 | 11609 | | |
11608 | 11610 | | |
11609 | | - | |
| 11611 | + | |
11610 | 11612 | | |
| 11613 | + | |
| 11614 | + | |
11611 | 11615 | | |
11612 | 11616 | | |
11613 | 11617 | | |
| |||
0 commit comments