From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH] KVM: dirty all pages in kvm_write_guest_cached() Date: Wed, 08 Apr 2015 10:49:59 +0200 Message-ID: <5524EBB7.3080906@redhat.com> References: <1428438897-22206-1-git-send-email-rkrcmar@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: kvm@vger.kernel.org To: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , linux-kernel@vger.kernel.org Return-path: In-Reply-To: <1428438897-22206-1-git-send-email-rkrcmar@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 07/04/2015 22:34, Radim Kr=C4=8Dm=C3=A1=C5=99 wrote: > We dirtied only one page because writes originally couldn't span more= =2E > Use improved syntax for '>> PAGE_SHIFT' while at it. >=20 > Fixes: 8f964525a121 ("KVM: Allow cross page reads and writes from cac= hed translations.") > Signed-off-by: Radim Kr=C4=8Dm=C3=A1=C5=99 Cross-page reads and writes should never get here; they have ghc->memslot set to NULL and go through the slow path in kvm_write_gues= t. What am I missing? Paolo > --- > The function handles cross memslot writes in a different path. >=20 > I think we should dirty pages after partial writes too (r < len), > but it probably won't happen and I already started refactoring :) >=20 > virt/kvm/kvm_main.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) >=20 > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index aadef264bed1..863df9dcab6f 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -1665,6 +1665,7 @@ int kvm_write_guest_cached(struct kvm *kvm, str= uct gfn_to_hva_cache *ghc, > { > struct kvm_memslots *slots =3D kvm_memslots(kvm); > int r; > + gfn_t gfn; > =20 > BUG_ON(len > ghc->len); > =20 > @@ -1680,7 +1681,10 @@ int kvm_write_guest_cached(struct kvm *kvm, st= ruct gfn_to_hva_cache *ghc, > r =3D __copy_to_user((void __user *)ghc->hva, data, len); > if (r) > return -EFAULT; > - mark_page_dirty_in_slot(kvm, ghc->memslot, ghc->gpa >> PAGE_SHIFT); > + > + for (gfn =3D gpa_to_gfn(ghc->gpa); > + gfn <=3D gpa_to_gfn(ghc->gpa + len - 1); gfn++) > + mark_page_dirty_in_slot(kvm, ghc->memslot, gfn); > =20 > return 0; > } >=20