From: Ian Jackson Subject: Re: [PATCH 10 of 24] libxc: infrastructure for hypercall safe data buffers Date: Tue, 7 Sep 2010 18:23:57 +0100 Message-ID: <19590.29997.199583.59386@mariner.uk.xensource.com> References: <4C85FB75.9070905@goop.org> <1283853410.14311.87.camel@zakaz.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1283853410.14311.87.camel@zakaz.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ian Campbell Cc: Jeremy Fitzhardinge , "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org Ian Campbell writes ("Re: [Xen-devel] [PATCH 10 of 24] libxc: infrastructure for hypercall safe data buffers"): > It's not clear what phase 2 actually is (although phase 3 is clearly > profit), I don't think any existing syscalls do what we need. mlock > (avoiding the stack) gets pretty close and so far the issues with mlock > seem to have been more potential than hurting us in practice, but it > pays to be prepared e.g. for more aggressive page migration/coalescing > in the future, I think. Ian and I discussed this extensively on IRC, during which conversation I became convinced that mlock() must do what we want. Having read the code in the kernel I'm not not so sure. The ordinary userspace access functions are all written to cope with pagefaults and retry the access. So userspace addresses are not in general valid in kernel mode even if you've called functions to try to test them. It's not clear what mlock prevents; does it prevent NUMA page migration ? If not then I think indeed the page could be made not present by one VCPU editing the page tables while another VCPU is entering the hypercall, so that the 2nd VCPU will get a spurious EFAULT. OTOH: there must be other things that work like Xen - what about user mode device drivers of various kinds ? Do X servers not mlock memory and expect to be able to tell the video card to DMA to it ? etc. I think if linux-kernel think that people haven't assumed that mlock() actually pins the page, they're mistaken - and it's likely to be not just us. Ian.