Re: [PATCH v6 03/14] KVM: X86: Don't track dirty for KVM_SET_[TSS_ADDR|IDENTITY_MAP_ADDR]

From: Sean Christopherson
Date: Wed Mar 11 2020 - 12:11:56 EST


On Wed, Mar 11, 2020 at 12:01:19PM -0400, Peter Xu wrote:
> On Tue, Mar 10, 2020 at 08:06:37AM -0700, Sean Christopherson wrote:
> > On Mon, Mar 09, 2020 at 05:44:13PM -0400, Peter Xu wrote:
> > > - idx = srcu_read_lock(&kvm->srcu);
> > > - fn = to_kvm_vmx(kvm)->tss_addr >> PAGE_SHIFT;
> > > - r = kvm_clear_guest_page(kvm, fn, 0, PAGE_SIZE);
> > > - if (r < 0)
> > > - goto out;
> > > + for (idx = 0; idx < 3; idx++) {
> > > + r = __copy_to_user(ua + PAGE_SIZE * idx, zero_page, PAGE_SIZE);
> > > + if (r)
> > > + return -EFAULT;
> > > + }
> >
> > Can this be done in a single __copy_to_user(), or do those helpers not like
> > crossing page boundaries?
>
> Maybe because the zero_page is only PAGE_SIZE long? :)

Ha, yeah, that'd be a good reason to loop.

> [...]