public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
To: Avi Kivity <avi@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>,
	Ingo Molnar <mingo@elte.hu>, LKML <linux-kernel@vger.kernel.org>,
	KVM <kvm@vger.kernel.org>
Subject: [PATCH 1/2] kvm tools: fix repeated io emulation
Date: Thu, 18 Aug 2011 11:06:54 +0800	[thread overview]
Message-ID: <4E4C81CE.8030508@cn.fujitsu.com> (raw)

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 <xiaoguangrong@cn.fujitsu.com>
---
 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

             reply	other threads:[~2011-08-18  3:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-18  3:06 Xiao Guangrong [this message]
2011-08-18  3:07 ` [PATCH 2/2] kvm tools: remove count in io emulation callbacks Xiao Guangrong
2011-08-18  6:13 ` [PATCH 1/2] kvm tools: fix repeated io emulation Pekka Enberg
2011-08-18  7:35   ` Sasha Levin
2011-08-18 15:08     ` Avi Kivity
2011-09-09  2:26       ` Xiao Guangrong
2011-09-09 13:45         ` Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E4C81CE.8030508@cn.fujitsu.com \
    --to=xiaoguangrong@cn.fujitsu.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mtosatti@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox