From: Keir Fraser Subject: Re: perl hypervisor interface Date: Fri, 09 Jul 2004 19:32:17 +0100 Sender: xen-devel-admin@lists.sourceforge.net Message-ID: References: <20040709161800.GL2502@worldvisions.ca> Return-path: In-Reply-To: Your message of "Fri, 09 Jul 2004 12:18:00 EDT." <20040709161800.GL2502@worldvisions.ca> Errors-To: xen-devel-admin@lists.sourceforge.net List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , List-Archive: To: Avery Pennarun Cc: Keir Fraser , David Becker , xen-devel@lists.sourceforge.net List-Id: xen-devel@lists.xenproject.org > On Fri, Jul 09, 2004 at 05:02:27PM +0100, Keir Fraser wrote: > > > > One bit I left out from the libxc do_dom0_op() procedure, was calling mlock() > > > on the dom0_op struct before passing it into the ioctl(). > > > When does the mlock() come into play? > > > > Xen doesn't do paging, so any memory buffers you pass to the dom0_op > > hypercall (including the dom0_op_t structure itself) must be resident > > when Xen is entered. If the buffer is allocated in-kernel then this > > isn't a problem, as Linux doesn't page itself. In user space we must > > use mlock() to force the buffer to be resident. > > Wouldn't it be better to have the ioctl() auto-mlock() the memory area, > rather than trusting userspace apps to know what they're doing? In general, > calls from userspace shouldn't be able to *accidentally* crash the kernel... > at least not without asking the kernel for permission first :) Only applications with permission to open /dev/xen/privcmd can use the hypercall interface; typically this is restricted to root. Also, it's not just the dom0_op_t struct that needs to be mlock()ed -- some operations have secondary buffers that also need mlock()ing, and adding auto support into the kernel would mean that we have yet /another/ layer of code to maintain! -- Keir ------------------------------------------------------- This SF.Net email sponsored by Black Hat Briefings & Training. Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com