From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Abd-El-Malek Subject: Vanilla Linux and has_foreign_mapping Date: Sun, 20 Apr 2008 17:19:20 -0400 Message-ID: <480BB358.3070508@cmu.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel Cc: Mark McLoughlin , Jeremy Fitzhardinge , Eduardo Habkost List-Id: xen-devel@lists.xenproject.org Hello, I'm trying to add support to Linux 2.6.25 for the "has_foreign_mappings" MMU context flag. Xen's Linux 2.6.18 tree uses this flag, so that page tables are properly disposed of when an application exits when it has foreign mappings. See: http://lists.xensource.com/archives/html/xen-devel/2006-08/msg00038.html Here is my attempt: diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c index 2a054ef..3e51897 100644 --- a/arch/x86/xen/mmu.c +++ b/arch/x86/xen/mmu.c @@ -633,8 +633,13 @@ void xen_exit_mmap(struct mm_struct *mm) spin_lock(&mm->page_table_lock); /* pgd may not be pinned in the error exit path of execve */ - if (PagePinned(virt_to_page(mm->pgd))) - xen_pgd_unpin(mm->pgd); + if (PagePinned(virt_to_page(mm->pgd))) { + if (mm->context.has_foreign_mappings) { + printk("%s: because of has_foreign_mappings, delaying unpinning\n", __FUNCTION__); + } else { + xen_pgd_unpin(mm->pgd); + } + } spin_unlock(&mm->page_table_lock); } diff --git a/include/asm-x86/mmu.h b/include/asm-x86/mmu.h index efa962c..7194698 100644 --- a/include/asm-x86/mmu.h +++ b/include/asm-x86/mmu.h @@ -18,6 +18,9 @@ typedef struct { int size; struct mutex lock; void *vdso; +#ifdef CONFIG_XEN + int has_foreign_mappings; +#endif } mm_context_t; #ifdef CONFIG_SMP Unfortunately, I got the following kernel crash on process exit: BUG: unable to handle kernel paging request at ebdae008 IP: [] pgd_mop_up_pmds+0x6a/0xd8 *pdpt = 000000007f494027 Oops: 0003 [#1] PREEMPT SMP Modules linked in: efsvm(F) nfs lockd sunrpc dm_snapshot dm_mirror dm_mod Pid: 5565, comm: a.out Tainted: GF (2.6.25 #9) EIP: 0061:[] EFLAGS: 00010246 CPU: 0 EIP is at pgd_mop_up_pmds+0x6a/0xd8 ... Call Trace: [] pgd_free+0x8/0x19 [] __mmdrop+0x16/0x2a [] do_exit+0x1b3/0x569 [] do_group_exit+0x63/0x7a [] syscall_call+0x7/0xb Has anyone else implemented this functionality in the mainline Linux tree? Any thoughts? Thanks, Mike