From mboxrd@z Thu Jan 1 00:00:00 1970 From: hanzhu Subject: Re: Re: A race condition in xenlinux exit_mmap Date: Tue, 01 Aug 2006 21:08:47 +0800 Message-ID: <44CF525F.8060901@sjtu.edu.cn> References: <0EBFB99D260C5B40AC33E0F807B1AD66BD2F48@pdsmsx411.ccr.corp.intel.com> <4717086ad65c3dc9247801672d1556b1@cl.cam.ac.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=gb18030; format=flowed Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: ben@virtualiron.com Cc: "Li, Xin B" , xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org This patch just fail the sanity check. It should fix the bug. However,=20 it didn't fix the root cause. I'm afraid Keir will not allow to add another VM_XXX flag. _______________________________________________________ Best Regards, hanzhu Ben Thomas =D0=B4=B5=C0: > Xin, > > I'm attaching a patch that we've been using since late May/early June t= o > address an "Eeek" issues. Since we applied the patch, we haven't seen t= he > issue. As this was some time ago, I cannot recall if this is the same > problem that you're seeing now. The patch wasn't submitted, as it isn't > particularly clean. It's one of the many "some day soon" patches that w= e > need to get resubmitted after a bit more work. I attach it here, not=20 > because > I believe that it is "the answer", but as a data point for you. > > -b > > > On 8/1/06, Keir Fraser wrote: >> >> >> On 1 Aug 2006, at 11:39, Li, Xin B wrote: >> >> >> Do you mind creating a patch to do this? I can send you more >> >> details if you like. >> > >> > Sure, pls send more info on this. >> >> 1. Add an 'int has_foreign_mappings' to mmu_context structure >> 2. Ensure the field is initialised in init_new_context() (e.g., >> memset-zero the whole structure; already done on x86/64) >> 3. Set the field in direct_remap_pfn_range() >> 4. Check the field in _arch_exit_mmap() to avoid calling mm_unpin(). >> >> That's it. Just needs testing. >> >> -- Keir >> >> >> _______________________________________________ >> Xen-devel mailing list >> Xen-devel@lists.xensource.com >> http://lists.xensource.com/xen-devel >> > > -----------------------------------------------------------------------= - > > # HG changeset patch > # User lively@dlively2 > # Node ID 2d63622421e93895f9f5c99d900e80e78943b0c6 > # Parent 0b79b3c194b17dcf4d7916e33628feb321cc1e05 > Robert's workaround for the infamous Eeek! page_mapcount(page) went neg= ative! bug. > > [Bug id:] 3914 > > [Reviewed By:] Ben & Dave L > > diff -r 0b79b3c194b1 -r 2d63622421e9 linux-2.6-xen-sparse/drivers/xen/p= rivcmd/privcmd.c > --- a/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c Sat Jun 10 13:= 23:11 2006 -0400 > +++ b/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c Tue Jun 13 11:= 05:44 2006 -0400 > @@ -244,7 +244,7 @@ static int privcmd_mmap(struct file * fi > static int privcmd_mmap(struct file * file, struct vm_area_struct * vm= a) > { > /* DONTCOPY is essential for Xen as copy_page_range is broken. */ > - vma->vm_flags |=3D VM_RESERVED | VM_IO | VM_DONTCOPY; > + vma->vm_flags |=3D VM_RESERVED | VM_IO | VM_DONTCOPY | VM_PRIVCMD; > =20 > return 0; > } > diff -r 0b79b3c194b1 -r 2d63622421e9 linux-2.6-xen-sparse/include/linux= /mm.h > --- a/linux-2.6-xen-sparse/include/linux/mm.h Sat Jun 10 13:23:11 2006 = -0400 > +++ b/linux-2.6-xen-sparse/include/linux/mm.h Tue Jun 13 11:05:44 2006 = -0400 > @@ -169,6 +169,7 @@ extern unsigned int kobjsize(const void=20 > #ifdef CONFIG_XEN > #define VM_FOREIGN 0x04000000 /* Has pages belonging to another VM */ > #endif > +#define VM_PRIVCMD 0x08000000 /* Pages belong to privcmd mma= p */ > =20 > #ifndef VM_STACK_DEFAULT_FLAGS /* arch can override this */ > #define VM_STACK_DEFAULT_FLAGS VM_DATA_DEFAULT_FLAGS > diff -r 0b79b3c194b1 -r 2d63622421e9 linux-2.6-xen-sparse/mm/memory.c > --- a/linux-2.6-xen-sparse/mm/memory.c Sat Jun 10 13:23:11 2006 -0400 > +++ b/linux-2.6-xen-sparse/mm/memory.c Tue Jun 13 11:05:44 2006 -0400 > @@ -409,6 +409,10 @@ struct page *vm_normal_page(struct vm_ar > print_bad_pte(vma, pte, addr); > return NULL; > } > + > + /* This vma points to foreign pages */ > + if (vma->vm_flags & VM_PRIVCMD) > + return NULL; > =20 > /* > * NOTE! We still have PageReserved() pages in the page=20 > =20