]> xenbits.xen.org Git - xenclient/xen.git/commitdiff
Miscellaneous fixes from xen-unstable prior to tboot patch set.
authorRoss Philipson <ross.philipson@citrix.com>
Wed, 4 Feb 2009 15:47:48 +0000 (10:47 -0500)
committerRoss Philipson <ross.philipson@citrix.com>
Wed, 4 Feb 2009 15:47:48 +0000 (10:47 -0500)
A number of small fixes that were done to address a VT-d fault due
to incorrect memory range checking. Taken from change sets 19061,
19081, and parts of 19083 to 19085.

 On branch master
 Changes to be committed:
modified:   xen/arch/ia64/xen/mm.c
modified:   xen/arch/x86/mm.c
modified:   xen/arch/x86/setup.c
modified:   xen/arch/x86/tboot.c
modified:   xen/drivers/passthrough/vtd/iommu.c
modified:   xen/drivers/video/vga.c
modified:   xen/include/xen/mm.h

xen/arch/ia64/xen/mm.c
xen/arch/x86/mm.c
xen/arch/x86/setup.c
xen/arch/x86/tboot.c
xen/drivers/passthrough/vtd/iommu.c
xen/drivers/video/vga.c
xen/include/xen/mm.h

index 4f18bf7349c2360e80632c9bc5bfbd6857c1ae87..418a24b432fc24276e9d16ed4c4f03af70655fe9 100644 (file)
@@ -3180,9 +3180,9 @@ int get_page_type(struct page_info *page, u32 type)
     return 1;
 }
 
-int memory_is_conventional_ram(paddr_t p)
+int page_is_conventional_ram(unsigned long mfn) /* CS 19085 mem to page */
 {
-    return (efi_mem_type(p) == EFI_CONVENTIONAL_MEMORY);
+    return (efi_mem_type(pfn_to_paddr(mfn)) == EFI_CONVENTIONAL_MEMORY);
 }
 
 
index 4c8b40a9011c9c751cd6f517c0f981f94d2d7fd9..b0762825d2d050e7ee6921fd97951c9dec6f957e 100644 (file)
@@ -287,15 +287,16 @@ void __init arch_init_memory(void)
     subarch_init_memory();
 }
 
-int memory_is_conventional_ram(paddr_t p)
+int page_is_conventional_ram(unsigned long mfn) /* CS 19085 mem to page, CS 19083 fixed test */
 {
+    uint64_t maddr = pfn_to_paddr(mfn);
     int i;
 
     for ( i = 0; i < e820.nr_map; i++ )
     {
         if ( (e820.map[i].type == E820_RAM) &&
-             (e820.map[i].addr <= p) &&
-             (e820.map[i].size > p) )
+             (e820.map[i].addr <= maddr) &&
+             ((e820.map[i].addr + e820.map[i].size) >= (maddr + PAGE_SIZE)) )
             return 1;
     }
 
index 967014e30185e9165f1f7de7a7d5970124c6bb75..6c039b0f3353ddc48cca47cb7130ae0ea8e32eae 100644 (file)
@@ -1117,10 +1117,16 @@ void arch_get_xen_caps(xen_capabilities_info_t *info)
 
 int xen_in_range(paddr_t start, paddr_t end)
 {
-    start = max_t(paddr_t, start, xenheap_phys_start);
-    end = min_t(paddr_t, end, xenheap_phys_end);
-    return start < end; 
+    /* CS 19060 removed xenheap_phys_start, CS 19081 fixed 64b range */
+#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
+
+    return (start < xe) && (end > xs);
 }
 
 /*
index ec4aa9436d5f4125e93aaa493a7fd17586d8fcb1..697ca9f4613a116e224aad3935136bdd17f79730 100644 (file)
@@ -96,18 +96,6 @@ int tboot_in_measured_env(void)
     return (g_tboot_shared != NULL);
 }
 
-int tboot_in_range(paddr_t start, paddr_t end)
-{
-    if ( g_tboot_shared == NULL || g_tboot_shared->version < 0x02 )
-        return 0;
-
-    start = max_t(paddr_t, start, g_tboot_shared->tboot_base);
-    end = min_t(paddr_t, end, 
-                g_tboot_shared->tboot_base + g_tboot_shared->tboot_size);
-    return start < end; 
-}
-
 /*
  * Local variables:
  * mode: C
index 2b36b7d06877afef705f8e89d395dec0d1b5fe5b..48ba0381dfc1b92cb4639f7df0f8996097310f93 100644 (file)
@@ -1034,8 +1034,7 @@ static int intel_iommu_domain_init(struct domain *d)
 
     if ( d->domain_id == 0 )
     {
-        extern int xen_in_range(paddr_t start, paddr_t end);
-        extern int tboot_in_range(paddr_t start, paddr_t end);
+        extern int xen_in_range(paddr_t start, paddr_t end);        
 
         /* 
          * Set up 1:1 page table for dom0 except the critical segments
@@ -1043,8 +1042,9 @@ static int intel_iommu_domain_init(struct domain *d)
          */
         for ( i = 0; i < max_page; i++ )
         {
-            if ( xen_in_range(i << PAGE_SHIFT_4K, (i + 1) << PAGE_SHIFT_4K) ||
-                 tboot_in_range(i << PAGE_SHIFT_4K, (i + 1) << PAGE_SHIFT_4K) )
+            /* CS 19084 remove tboot_in_range, CS 19085 use page_is_conventional_ram */              
+            if ( !page_is_conventional_ram(i) ||
+                 xen_in_range(i << PAGE_SHIFT, (i + 1) << PAGE_SHIFT) )
                 continue;
 
             iommu_map_page(d, i, i);
index ef21178a011640220329622af7c3009cbd1e5660..302899ae37f4441cfcc6c69d1069cc0192ed5f35 100644 (file)
@@ -79,7 +79,7 @@ void __init vga_init(void)
     switch ( vga_console_info.video_type )
     {
     case XEN_VGATYPE_TEXT_MODE_3:
-        if ( memory_is_conventional_ram(0xB8000) ||
+        if ( page_is_conventional_ram(paddr_to_pfn(0xB8000)) ||  /* CS 19085 mem to page */
              ((video = ioremap(0xB8000, 0x8000)) == NULL) )
             return;
         outw(0x200a, 0x3d4); /* disable cursor */
index 08bd72d8ce2b511b8bad39d8f0555f0b0228a583..1c0733e32a454a09ba771435191bb70d9c05874b 100644 (file)
@@ -101,8 +101,8 @@ unsigned long avail_scrub_pages(void);
 
 int guest_remove_page(struct domain *d, unsigned long gmfn);
 
-/* Returns TRUE if the memory at address @p is ordinary RAM. */
-int memory_is_conventional_ram(paddr_t p);
+/* Returns TRUE if the whole page at @mfn is ordinary RAM. */
+int page_is_conventional_ram(unsigned long mfn);
 
 extern unsigned long *alloc_bitmap;    /* for vmcoreinfo */