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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jul 02, 2020 at 05:05:57PM -0700, Sean Christopherson wrote:
> >  	/* Set up identity-mapping pagetable for EPT in real mode */
> >  	for (i = 0; i < PT32_ENT_PER_PAGE; i++) {
> >  		tmp = (i << 22) + (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER |
> >  			_PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_PSE);
> > -		r = kvm_write_guest_page(kvm, identity_map_pfn,
> > -				&tmp, i * sizeof(tmp), sizeof(tmp));
> > -		if (r < 0)
> > +		r = __copy_to_user(uaddr + i * sizeof(tmp), &tmp, sizeof(tmp));
> > +		if (r) {
> > +			r = -EFAULT;
> 
> Another case where capturing the result is unnecessary.  I don't have a
> preference as to whether the result of __copy_{to,from}_user() is returned
> directly or morphed to -EFAULT, but we should be consistent, especially
> within a single patch.

OK, I'll clean all these __copy_to_user() callers in the next version.

> 
> >  			goto out;
> > +		}
> >  	}
> >  	kvm_vmx->ept_identity_pagetable_done = true;
> >  
> > @@ -3532,19 +3525,22 @@ static void seg_setup(int seg)
> >  static int alloc_apic_access_page(struct kvm *kvm)
> >  {
> >  	struct page *page;
> > -	int r = 0;
> > +	void __user *r;
> > +	int ret = 0;
> >  
> >  	mutex_lock(&kvm->slots_lock);
> >  	if (kvm->arch.apic_access_page_done)
> >  		goto out;
> >  	r = __x86_set_memory_region(kvm, APIC_ACCESS_PAGE_PRIVATE_MEMSLOT,
> >  				    APIC_DEFAULT_PHYS_BASE, PAGE_SIZE);
> 
> Naming the new 'void __user *hva' would yield a smaller differ and would
> probably help readers in the future.

OK.

> >  	} else {
> > -		if (!slot || !slot->npages)
> > -			return 0;
> > -
> >  		/*
> >  		 * Stuff a non-canonical value to catch use-after-delete.  This
> >  		 * ends up being 0 on 32-bit KVM, but there's no better
> >  		 * alternative.
> >  		 */
> >  		hva = (unsigned long)(0xdeadull << 48);
> > +
> > +		if (!slot || !slot->npages)
> > +			return (void __user *)hva;
> 
> My clever shenanigans got discarded, so this weirdness happily is gone. 

I'll see what I get when I rebase.  This series is easy to encounter conflicts
during previous rebases for misterious reasons.  I guess I'll just repost less
frequently so I suffer less from rebase too. :)

Thanks.

-- 
Peter Xu




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux