When kvm emulates repeation io read instruction, it can exit to user-space with
'count' > 1, we need to emulate io access for many times

Signed-off-by: Xiao Guangrong <[email protected]>
---
 tools/kvm/ioport.c |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/tools/kvm/ioport.c b/tools/kvm/ioport.c
index 2d69ae4..6b0bd30 100644
--- a/tools/kvm/ioport.c
+++ b/tools/kvm/ioport.c
@@ -129,6 +129,7 @@ bool kvm__emulate_io(struct kvm *kvm, u16 port, void *data, 
int direction, int s
        struct ioport_operations *ops;
        bool ret = false;
        struct ioport *entry;
+       void *ptr = data;
 
        br_read_lock();
        entry = ioport_search(&ioport_tree, port);
@@ -137,12 +138,16 @@ bool kvm__emulate_io(struct kvm *kvm, u16 port, void 
*data, int direction, int s
 
        ops     = entry->ops;
 
-       if (direction == KVM_EXIT_IO_IN) {
-               if (ops->io_in)
-                       ret = ops->io_in(entry, kvm, port, data, size, count);
-       } else {
-               if (ops->io_out)
-                       ret = ops->io_out(entry, kvm, port, data, size, count);
+       while (count--) {
+               if (direction == KVM_EXIT_IO_IN) {
+                       if (ops->io_in)
+                               ret = ops->io_in(entry, kvm, port, ptr, size, 
count);
+               } else {
+                       if (ops->io_out)
+                               ret = ops->io_out(entry, kvm, port, ptr, size, 
count);
+               }
+
+               ptr += size;
        }
 
        br_read_unlock();
-- 
1.7.5.4
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to