Skip to content

Commit 432baf6

Browse files
Sean Christophersonbonzini
authored andcommitted
KVM: VMX: use kvm_fast_pio_in for handling IN I/O
Fast emulation of processor I/O for IN was disabled on x86 (both VMX and SVM) some years ago due to a buggy implementation. The addition of kvm_fast_pio_in(), used by SVM, re-introduced (functional!) fast emulation of IN. Piggyback SVM's work and use kvm_fast_pio_in() on VMX instead of performing full emulation of IN. Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 2bb8caf commit 432baf6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

arch/x86/kvm/vmx.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6270,23 +6270,26 @@ static int handle_io(struct kvm_vcpu *vcpu)
62706270

62716271
exit_qualification = vmcs_readl(EXIT_QUALIFICATION);
62726272
string = (exit_qualification & 16) != 0;
6273-
in = (exit_qualification & 8) != 0;
62746273

62756274
++vcpu->stat.io_exits;
62766275

6277-
if (string || in)
6276+
if (string)
62786277
return emulate_instruction(vcpu, 0) == EMULATE_DONE;
62796278

62806279
port = exit_qualification >> 16;
62816280
size = (exit_qualification & 7) + 1;
6281+
in = (exit_qualification & 8) != 0;
62826282

62836283
ret = kvm_skip_emulated_instruction(vcpu);
62846284

62856285
/*
62866286
* TODO: we might be squashing a KVM_GUESTDBG_SINGLESTEP-triggered
62876287
* KVM_EXIT_DEBUG here.
62886288
*/
6289-
return kvm_fast_pio_out(vcpu, size, port) && ret;
6289+
if (in)
6290+
return kvm_fast_pio_in(vcpu, size, port) && ret;
6291+
else
6292+
return kvm_fast_pio_out(vcpu, size, port) && ret;
62906293
}
62916294

62926295
static void

0 commit comments

Comments
 (0)