From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: Re: [PATCH 4/5] KVM: Fix compound mmio. Date: Tue, 12 Apr 2011 15:34:16 +0300 Message-ID: <20110412123416.GP17809@redhat.com> References: <1302600985-10704-1-git-send-email-gleb@redhat.com> <1302600985-10704-4-git-send-email-gleb@redhat.com> <4DA44334.2090905@redhat.com> <20110412122201.GN17809@redhat.com> <4DA4453C.2050309@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org, mtosatti@redhat.com To: Avi Kivity Return-path: Received: from mx1.redhat.com ([209.132.183.28]:41384 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755272Ab1DLMeS (ORCPT ); Tue, 12 Apr 2011 08:34:18 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p3CCYIBN011585 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 12 Apr 2011 08:34:18 -0400 Content-Disposition: inline In-Reply-To: <4DA4453C.2050309@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, Apr 12, 2011 at 03:27:40PM +0300, Avi Kivity wrote: > On 04/12/2011 03:22 PM, Gleb Natapov wrote: > >On Tue, Apr 12, 2011 at 03:19:00PM +0300, Avi Kivity wrote: > >> On 04/12/2011 12:36 PM, Gleb Natapov wrote: > >> >mmio_index should be taken into account when copying data from > >> >userspace. > >> > > >> >Signed-off-by: Gleb Natapov > >> >--- > >> > arch/x86/kvm/x86.c | 3 ++- > >> > 1 files changed, 2 insertions(+), 1 deletions(-) > >> > > >> >diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > >> >index b568779..609c7ab 100644 > >> >--- a/arch/x86/kvm/x86.c > >> >+++ b/arch/x86/kvm/x86.c > >> >@@ -5518,7 +5518,8 @@ static int complete_mmio(struct kvm_vcpu *vcpu) > >> > if (vcpu->mmio_needed) { > >> > vcpu->mmio_needed = 0; > >> > if (!vcpu->mmio_is_write) > >> >- memcpy(vcpu->mmio_data, run->mmio.data, 8); > >> >+ memcpy(vcpu->mmio_data + vcpu->mmio_index, > >> >+ run->mmio.data, 8); > >> > vcpu->mmio_index += 8; > >> > if (vcpu->mmio_index< vcpu->mmio_size) { > >> > run->exit_reason = KVM_EXIT_MMIO; > >> > >> Interesting, the code passed the emulator.flat sse test. Does it now? > >> > >It pass now and before. Probably by chance. > > I don't understand how. I explicitly set the values so that it > would fail in that case. > > Can you patch the test to fail with the current code? > If I understand correctly you've already found the explanation why test case worked? > >But if I change read_emulated() to do > > > > int n = min(size, (unsigned)KVM_MMIO_SIZE); > > > >instead of > > > > int n = min(size, 8u); > > > >emulator.flat fails to emulate far jump instruction. > > Ouch, looks like we have the multi-transaction support in two > places. I guess this is what made sse mmio work. > > Not sure what we should do (patch is fine, question is how to > resolve the duplication). > Multi-transaction works faster in complete_mmio, so read_emulated() should use it by doing int n = min(size, (unsigned)KVM_MMIO_SIZE). Other code in read_emulated() is still needed since it provides read re-play for multiple mmio reads during instruction emulation. -- Gleb.