lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4A280FE2.2090101@novell.com>
Date:	Thu, 04 Jun 2009 14:18:10 -0400
From:	Gregory Haskins <ghaskins@...ell.com>
To:	"Michael S. Tsirkin" <mst@...hat.com>
CC:	linux-kernel@...r.kernel.org, agraf@...e.de, pmullaney@...ell.com,
	pmorreale@...ell.com, anthony@...emonkey.ws, rusty@...tcorp.com.au,
	netdev@...r.kernel.org, kvm@...r.kernel.org, avi@...hat.com,
	bhutchings@...arflare.com, andi@...stfloor.org, gregkh@...e.de,
	herber@...dor.apana.org.au, chrisw@...s-sol.org,
	shemminger@...tta.com
Subject: Re: [RFC PATCH v2 03/19] vbus: add connection-client helper infrastructure

Michael S. Tsirkin wrote:
> On Thu, Apr 09, 2009 at 12:30:57PM -0400, Gregory Haskins wrote:
>   
>> +static unsigned long
>> +task_memctx_copy_to(struct vbus_memctx *ctx, void *dst, const void *src,
>> +		    unsigned long n)
>> +{
>> +	struct task_memctx *tm = to_task_memctx(ctx);
>> +	struct task_struct *p = tm->task;
>> +
>> +	while (n) {
>> +		unsigned long offset = ((unsigned long)dst)%PAGE_SIZE;
>> +		unsigned long len = PAGE_SIZE - offset;
>> +		int ret;
>> +		struct page *pg;
>> +		void *maddr;
>> +
>> +		if (len > n)
>> +			len = n;
>> +
>> +		down_read(&p->mm->mmap_sem);
>> +		ret = get_user_pages(p, p->mm,
>> +				     (unsigned long)dst, 1, 1, 0, &pg, NULL);
>> +
>> +		if (ret != 1) {
>> +			up_read(&p->mm->mmap_sem);
>> +			break;
>> +		}
>> +
>> +		maddr = kmap_atomic(pg, KM_USER0);
>> +		memcpy(maddr + offset, src, len);
>> +		kunmap_atomic(maddr, KM_USER0);
>> +		set_page_dirty_lock(pg);
>> +		put_page(pg);
>> +		up_read(&p->mm->mmap_sem);
>> +
>> +		src += len;
>> +		dst += len;
>> +		n -= len;
>> +	}
>> +
>> +	return n;
>> +}
>>     
>
> BTW, why did you decide to use get_user_pages?
> Would switch_mm + copy_to_user work as well
> avoiding page walk if all pages are present?
>   

Well, basic c_t_u() won't work because its likely not "current" if you
are updating the ring from some other task, but I think you have already
figured that out based on the switch_mm suggestion.  The simple truth is
I was not familiar with switch_mm at the time I wrote this (nor am I
now).  If this is a superior method that allows you to acquire
c_t_u(some_other_ctx) like behavior, I see no problem in changing.  I
will look into this, and thanks for the suggestion!

> Also - if we just had vmexit because a process executed
> io (or hypercall), can't we just do copy_to_user there?
> Avi, I think at some point you said that we can?
>   

Right, and yes that will work I believe.  We could always do a "if (p ==
current)" check to test for this.  To date, I don't typically do
anything mem-ops related directly in vcpu context so this wasn't an
issue...but that doesn't mean someone wont try in the future.  
Therefore, I agree we should strive to optimize it if we can.
>
>   

Thanks Michael,
-Greg


Download attachment "signature.asc" of type "application/pgp-signature" (267 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ