Skip to content

Commit 2ec1740

Browse files
joshtriplettwildea01
authored andcommitted
kvm__emulate_io: Don't fall through from IO in to IO out if no handler
If an IO port device has no io_in handler, kvm__emulate_io would fall through and call the io_out handler instead. Fix to only call the handler for the appropriate direction. If no handler exists, kvm__emulate_io will automatically treat it as an IO error (due to the default "ret = false"). Signed-off-by: Josh Triplett <[email protected]> Signed-off-by: Will Deacon <[email protected]>
1 parent e7b95bd commit 2ec1740

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ioport.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ bool kvm__emulate_io(struct kvm_cpu *vcpu, u16 port, void *data, int direction,
192192
while (count--) {
193193
if (direction == KVM_EXIT_IO_IN && ops->io_in)
194194
ret = ops->io_in(entry, vcpu, port, ptr, size);
195-
else if (ops->io_out)
195+
else if (direction == KVM_EXIT_IO_OUT && ops->io_out)
196196
ret = ops->io_out(entry, vcpu, port, ptr, size);
197197

198198
ptr += size;

0 commit comments

Comments
 (0)