From patchwork Thu Aug 18 03:06:54 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 1075502 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p7I352va001680 for ; Thu, 18 Aug 2011 03:05:02 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754846Ab1HRDEz (ORCPT ); Wed, 17 Aug 2011 23:04:55 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:55082 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1752976Ab1HRDEy (ORCPT ); Wed, 17 Aug 2011 23:04:54 -0400 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id 259A017011E; Thu, 18 Aug 2011 11:04:52 +0800 (CST) Received: from mailserver.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id p7I34pJV028544; Thu, 18 Aug 2011 11:04:51 +0800 Received: from localhost.localdomain ([10.167.225.99]) by mailserver.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.1FP4) with ESMTP id 2011081811034160-41507 ; Thu, 18 Aug 2011 11:03:41 +0800 Message-ID: <4E4C81CE.8030508@cn.fujitsu.com> Date: Thu, 18 Aug 2011 11:06:54 +0800 From: Xiao Guangrong User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc15 Thunderbird/3.1.10 MIME-Version: 1.0 To: Avi Kivity CC: Marcelo Tosatti , Ingo Molnar , LKML , KVM Subject: [PATCH 1/2] kvm tools: fix repeated io emulation X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2011-08-18 11:03:41, Serialize by Router on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2011-08-18 11:03:42, Serialize complete at 2011-08-18 11:03:42 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 18 Aug 2011 03:05:16 +0000 (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 --- 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();