diff mbox

[1/2] kvm tools: fix repeated io emulation

Message ID 4E4C81CE.8030508@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Xiao Guangrong Aug. 18, 2011, 3:06 a.m. UTC
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(-)

Comments

Pekka Enberg Aug. 18, 2011, 6:13 a.m. UTC | #1
Hi,

On Thu, Aug 18, 2011 at 6:06 AM, Xiao Guangrong
<xiaoguangrong@cn.fujitsu.com> wrote:
> 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>

The KVM tool is not actually maintained by Avi and Marcelo but by me
and few others. Our git repository is here:

https://github.com/penberg/linux-kvm

Ingo pulls that to -tip few times a week or so. Sasha, can you please
take a look at these patches and if you're OK with them, I'll apply
them.

                        Pekka
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sasha Levin Aug. 18, 2011, 7:35 a.m. UTC | #2
On Thu, 2011-08-18 at 09:13 +0300, Pekka Enberg wrote:
> Hi,
> 
> On Thu, Aug 18, 2011 at 6:06 AM, Xiao Guangrong
> <xiaoguangrong@cn.fujitsu.com> wrote:
> > 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>
> 
> The KVM tool is not actually maintained by Avi and Marcelo but by me
> and few others. Our git repository is here:
> 
> https://github.com/penberg/linux-kvm
> 
> Ingo pulls that to -tip few times a week or so. Sasha, can you please
> take a look at these patches and if you're OK with them, I'll apply
> them.

Pekka,

I can only assume they're right, 'count' isn't documented anywhere :)

If any of KVM maintainers could confirm it I'll add it into the docs.
Avi Kivity Aug. 18, 2011, 3:08 p.m. UTC | #3
On 08/18/2011 12:35 AM, Sasha Levin wrote:
> On Thu, 2011-08-18 at 09:13 +0300, Pekka Enberg wrote:
> >  Hi,
> >
> >  On Thu, Aug 18, 2011 at 6:06 AM, Xiao Guangrong
> >  <xiaoguangrong@cn.fujitsu.com>  wrote:
> >  >  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>
> >
> >  The KVM tool is not actually maintained by Avi and Marcelo but by me
> >  and few others. Our git repository is here:
> >
> >  https://github.com/penberg/linux-kvm
> >
> >  Ingo pulls that to -tip few times a week or so. Sasha, can you please
> >  take a look at these patches and if you're OK with them, I'll apply
> >  them.
>
> Pekka,
>
> I can only assume they're right, 'count' isn't documented anywhere :)
>
> If any of KVM maintainers could confirm it I'll add it into the docs.
>

Count is indeed the number of repetitions.
diff mbox

Patch

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();