From mboxrd@z Thu Jan 1 00:00:00 1970 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [PATCH] KVM: dirty all pages in kvm_write_guest_cached() Date: Wed, 8 Apr 2015 11:26:12 +0200 Message-ID: <20150408092611.GA2164@potion.brq.redhat.com> References: <1428438897-22206-1-git-send-email-rkrcmar@redhat.com> <5524EBB7.3080906@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org To: Paolo Bonzini Return-path: Content-Disposition: inline In-Reply-To: <5524EBB7.3080906@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org 2015-04-08 10:49+0200, Paolo Bonzini: > 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 mo= re. > > Use improved syntax for '>> PAGE_SHIFT' while at it. > >=20 > > Fixes: 8f964525a121 ("KVM: Allow cross page reads and writes from c= ached translations.") > > Signed-off-by: Radim Kr=C4=8Dm=C3=A1=C5=99 >=20 > 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_gu= est. Only cross-memslot writes have NULL memslot. > What am I missing? kvm_gfn_to_hva_cache_init() queries how many pages are remaining in the memslot and it compares it with the amount of needed pages. If the write will fit in memslot, it will be done without kvm_write_guest, regardless of the amount of written pages. The relevant code path in kvm_gfn_to_hva_cache_init(): gfn_t nr_pages_needed =3D end_gfn - start_gfn + 1; ghc->memslot =3D gfn_to_memslot(kvm, start_gfn); ghc->hva =3D gfn_to_hva_many(ghc->memslot, start_gfn, &nr_pages_avail= ); if (!kvm_is_error_hva(ghc->hva) && nr_pages_avail >=3D nr_pages_neede= d) ghc->hva +=3D offset; return 0;