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] Re: Changeset 20209 causes an issue in xen_in_range()

To: "Keir Fraser" <keir.fraser@xxxxxxxxxxxxx>
Subject: [Xen-devel] Re: Changeset 20209 causes an issue in xen_in_range()
From: "Jan Beulich" <JBeulich@xxxxxxxxxx>
Date: Thu, 14 Jan 2010 11:21:24 +0000
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx, Dexuan Cui <dexuan.cui@xxxxxxxxx>
Delivery-date: Thu, 14 Jan 2010 03:21:49 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <C7749CA5.65E5%keir.fraser@xxxxxxxxxxxxx>
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>
References: <ED3036A092A28F4C91B0B4360DD128EA31DD4DFE@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx> <C7749CA5.65E5%keir.fraser@xxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
>>> Keir Fraser <keir.fraser@xxxxxxxxxxxxx> 14.01.10 11:04 >>>
>On 14/01/2010 08:38, "Cui, Dexuan" <dexuan.cui@xxxxxxxxx> wrote:
>
>> Currently PERCPU_SIZE is 2 4K-pages and only 1 page is used actually.
>> 
>> From xen 20209 on, the second unused page is freed and returned to domheap in
>> debug=n build (MEMORY_GUARD is not defined):
>> percpu_free_unused_areas() -> free_xen_data() -> init_xenheap_pages().
>> Later the returned pages could be allocated to dom0 and dom0 could use them 
>> as
>> DMA buffer.
>> 
>> However, in iommu_set_dom0_mapping(), xen_in_range() is still True for the
>> freed pages above, so devices in Dom0 can meet with DMA fault.
>
>Should be fixed by c/s 20803.

Do you really think so? Masking "start" with PERCPU_SIZE-1 doesn't
make sense, as it may be arbitrarily before __percpu_start and
not aligned. Below my take on it.

Jan

--- 2010-01-06.orig/xen/arch/x86/setup.c        2010-01-05 13:29:13.000000000 
+0100
+++ 2010-01-06/xen/arch/x86/setup.c     2010-01-14 11:03:10.000000000 +0100
@@ -230,7 +230,7 @@ static void __init percpu_free_unused_ar
     /* Free all unused per-cpu data areas. */
     free_xen_data(&__per_cpu_start[first_unused << PERCPU_SHIFT], __bss_start);
 
-    data_size = (data_size + PAGE_SIZE + 1) & PAGE_MASK;
+    BUG_ON(data_size & ~PAGE_MASK);
     if ( data_size != PERCPU_SIZE )
         for ( i = 0; i < first_unused; i++ )
             free_xen_data(&__per_cpu_start[(i << PERCPU_SHIFT) + data_size],
@@ -1200,7 +1200,7 @@ int xen_in_range(paddr_t start, paddr_t 
     int i;
     static struct {
         paddr_t s, e;
-    } xen_regions[4];
+    } xen_regions[3];
 
     /* initialize first time */
     if ( !xen_regions[0].s )
@@ -1211,10 +1211,6 @@ int xen_in_range(paddr_t start, paddr_t 
         /* 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 = xen_regions[2].s +
-            (((paddr_t)last_cpu(cpu_possible_map) + 1) << PERCPU_SHIFT);
         /* bss */
         xen_regions[3].s = __pa(&__bss_start);
         xen_regions[3].e = __pa(&_end);
@@ -1226,6 +1222,14 @@ int xen_in_range(paddr_t start, paddr_t 
             return 1;
     }
 
+    /* per-cpu data */
+    for_each_possible_cpu(i)
+    {
+        if ( (start < __pa(&__per_cpu_data_end[i << PERCPU_SHIFT])) &&
+             (end > __pa(&__per_cpu_start[i << PERCPU_SHIFT])) )
+            return 1;
+    }
+
     return 0;
 }
 
--- 2010-01-06.orig/xen/arch/x86/xen.lds.S      2009-10-15 11:42:12.000000000 
+0200
+++ 2010-01-06/xen/arch/x86/xen.lds.S   2010-01-14 11:01:19.000000000 +0100
@@ -104,10 +104,10 @@ SECTIONS
        *(.data.percpu)
        . = ALIGN(SMP_CACHE_BYTES);
        *(.data.percpu.read_mostly)
+       . = ALIGN(PAGE_SIZE);
        __per_cpu_data_end = .;
   } :text
   . = __per_cpu_start + (NR_CPUS << PERCPU_SHIFT);
-  . = ALIGN(PAGE_SIZE);
 
   /*
    * Do not insert anything here - the unused portion of .data.percpu



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