From: Keir Fraser Subject: Re: [PATCH] direct_remap_pfn_range vm_flags fix Date: Wed, 8 Feb 2006 09:13:08 +0000 Message-ID: <620fa26afde95dd8bec7b46e5fbaef71@cl.cam.ac.uk> References: <20060208082847.GE30803@sorel.sous-sol.org> Mime-Version: 1.0 (Apple Message framework v623) Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20060208082847.GE30803@sorel.sous-sol.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Chris Wright Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org On 8 Feb 2006, at 08:28, Chris Wright wrote: > direct_remap_pfn_range() does not properly mark vma with VM_PFNMAP. > This triggers improper reference counting on what rmap thought was > a normal page, and a subsequent BUG() such as: It isn't really proper for direct_remap_pfn_range() to set VM_PFNMAP. Properly that function should actually be called remap_mfn_range(). vm_pgoff is an MFN, and what is mapped is a contiguous sequence of MFNs. So the PFNMAP checks in vm_normal_page() do not work, since pte_pfn() will not return a contiguous sequence of PFNs starting from vm_pgoff -- the MFNs are contiguous, not the PFNs. What saves you currently is the cow_mapping() check in vm_normal_page(). If we created private mappings of any guest-local memory via direct_remap_pfn_range(), we would still crash. Possible proper fixes: 1. Don't map local memory via that interface -- only xenstored does this, when mapping dom0's xenbus page. This could be changed. 2. Add a _PAGE_DIRECTMAP flag, just for Xen, that indicates unrefcounted PTEs. -- Keir