This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
Home Products Support Community News


[Xen-devel] Re: Vanilla Linux and has_foreign_mapping

To: Michael Abd-El-Malek <mabdelmalek@xxxxxxx>
Subject: [Xen-devel] Re: Vanilla Linux and has_foreign_mapping
From: Jeremy Fitzhardinge <jeremy@xxxxxxxx>
Date: Mon, 21 Apr 2008 21:46:45 +1000
Cc: Mark McLoughlin <markmc@xxxxxxxxxx>, xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>, Eduardo Habkost <ehabkost@xxxxxxxxxx>
Delivery-date: Mon, 21 Apr 2008 09:34:22 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <480BB358.3070508@xxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <480BB358.3070508@xxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird (X11/20080407)
Michael Abd-El-Malek wrote:
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.

I was hoping to avoid having to introduce that flag, but I have to admit I haven't given it much analysis. How are you using it?


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)

     /* 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);
+        }
+    }

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;
 } 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: [<c01157f9>] pgd_mop_up_pmds+0x6a/0xd8

Which line is that?


Xen-devel mailing list