diff options
| author | Sean Christopherson <seanjc@google.com> | 2026-10-28 10:36:38 -0700 |
|---|---|---|
| committer | Paolo Bonzini <pbonzini@redhat.com> | 2026-11-02 12:48:51 -0500 |
| commit | ae85ac25eb671d174811cc3101549448671fd505 (patch) | |
| tree | e3a185226980a65cb0c2992e14caf2b9ceeef7a9 /scripts/basic | |
| parent | b2691b3a6cd230209736c89684dab90d939aa56b (diff) | |
| download | linux-ae85ac25eb671d174811cc3101549448671fd505.tar.gz linux-ae85ac25eb671d174811cc3101549448671fd505.zip | |
KVM: x86: Conditionally resched when restarting REP string emulation
When restarting emulation, e.g. of a REP-prefixed string instruction,
conditionally reschedule as emulating guest writes can be deceptively slow
and expensive, e.g. when shadow paging is in use and each write can trigger
write tracking.
In a perfect world, restarting emulation (or not) would be less arbitrary,
e.g. would honor not only host events (NEED_RESCHED, signals, etc.) but
also guest events (e.g. by checking kvm_vcpu_has_events()). Unfortunately,
as pointed out by Sashiko, pio_in_emulated()'s read-ahead logic is baked
into the restart logic, as KVM relies on restarting emulation to drain the
cache and avoid duplicate reads from the I/O port. I.e. re-entering the
guest on kvm_vcpu_has_events() or __xfer_to_guest_mode_work_pending() would
introduce architecturally-incorrect, guest-visible changes.
Fixes: 5cd21917da24 ("KVM: x86 emulator: restart string instruction without going back to a guest.")
Cc: stable@vger.kernel.org
Cc: David Woodhouse <dwmw2@infradead.org>
Reported-by: Stefan Teodorescu <fane@google.com>
Suggested-by: Stefan Teodorescu <fane@google.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-ID: <20261028173638.1765329-1-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'scripts/basic')
0 files changed, 0 insertions, 0 deletions
