WARNING - OLD ARCHIVES

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/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] vt-d: Better restrict memory ranges considered to be

To: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>, Keir Fraser <keir.fraser@xxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] vt-d: Better restrict memory ranges considered to be in Xen
From: "Cihula, Joseph" <joseph.cihula@xxxxxxxxx>
Date: Fri, 6 Mar 2009 10:21:13 -0800
Accept-language: en-US
Acceptlanguage: en-US
Cc: "Wang, Shane" <shane.wang@xxxxxxxxx>, "Kay, Allen M" <allen.m.kay@xxxxxxxxx>, "Han, Weidong" <weidong.han@xxxxxxxxx>, Ross Philipson <Ross.Philipson@xxxxxxxxxx>, "Cui, Dexuan" <dexuan.cui@xxxxxxxxx>
Delivery-date: Fri, 06 Mar 2009 10:21:49 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: AcmeiFTCuFjejgKMTheNUAshnHLKrA==
Thread-topic: [PATCH] vt-d: Better restrict memory ranges considered to be in Xen
The current implementation of xen_in_range() misses several memory ranges that 
are used by the hypervisor and thus shouldn't get mapped into dom0's VT-d 
tables.  This patch should make the check complete.

This patch is only against x86 because I'm not familiar enough with IA64 to 
know how much, if any, of these checks apply there.

Signed-off-by: Joseph Cihula <joseph.cihula@xxxxxxxxx>

diff -r 7f573cb76db4 xen/arch/x86/setup.c
--- a/xen/arch/x86/setup.c      Tue Mar 03 13:22:28 2009 +0000
+++ b/xen/arch/x86/setup.c      Fri Mar 06 09:09:38 2009 -0800
@@ -1111,15 +1111,43 @@ void arch_get_xen_caps(xen_capabilities_

 int xen_in_range(paddr_t start, paddr_t end)
 {
-#if defined(CONFIG_X86_32)
-    paddr_t xs = 0;
-    paddr_t xe = xenheap_phys_end;
-#else
-    paddr_t xs = __pa(&_stext);
-    paddr_t xe = __pa(&_etext);
-#endif
+    int i;
+    static struct {
+        paddr_t s, e;
+    } xen_regions[5];

-    return (start < xe) && (end > xs);
+    /* initialize first time */
+    if ( !xen_regions[0].s )
+    {
+        extern char __init_begin[], __per_cpu_start[], __per_cpu_end[],
+                    __bss_start[];
+        extern unsigned long allocator_bitmap_end;
+
+        /* S3 resume code (and other real mode trampoline code) */
+        xen_regions[0].s = bootsym_phys(trampoline_start);
+        xen_regions[0].e = bootsym_phys(trampoline_end);
+        /* hypervisor code + data */
+        xen_regions[1].s =__pa(&_stext);
+        xen_regions[1].e = __pa(&__init_begin);
+        /* per-cpu data */
+        xen_regions[2].s = __pa(&__per_cpu_start);
+        xen_regions[2].e = __pa(&__per_cpu_end);
+        /* bss + boot allocator bitmap */
+        xen_regions[3].s = __pa(&__bss_start);
+        xen_regions[3].e = allocator_bitmap_end;
+        /* frametable */
+        xen_regions[4].s = (unsigned long)frame_table;
+        xen_regions[4].e = (unsigned long)frame_table +
+                           PFN_UP(max_page * sizeof(*frame_table));
+    }
+
+    for ( i = 0; i < ARRAY_SIZE(xen_regions); i++ )
+    {
+        if ( (start < xen_regions[i].e) && (end > xen_regions[i].s) )
+            return 1;
+    }
+
+    return 0;
 }

 /*


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] vt-d: Better restrict memory ranges considered to be in Xen, Cihula, Joseph <=