]> xenbits.xen.org Git - xenclient/xen.git/commitdiff
Added reserved memory from e820 map to pages mapped into IOMMUs for
authorRoss Philipson <ross.philipson@citrix.com>
Fri, 20 Feb 2009 20:03:42 +0000 (15:03 -0500)
committerRoss Philipson <ross.philipson@citrix.com>
Fri, 20 Feb 2009 20:03:42 +0000 (15:03 -0500)
dom0. This is for broken BIOS issues where the RMRRs do not report
the correct reserved ranges for devices.
 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 418a24b432fc24276e9d16ed4c4f03af70655fe9..1a4c24d10753740dbc6488e841023e0807df6695 100644 (file)
@@ -3180,12 +3180,19 @@ int get_page_type(struct page_info *page, u32 type)
     return 1;
 }
 
-int page_is_conventional_ram(unsigned long mfn) /* CS 19085 mem to page */
-{
+int page_is_ram_type(unsigned long mfn, unsigned long type) /* CS 19085 mem to page */
+{
+    /**
+     * N.B. This function should really be enhanced to return what is more in line with the e820
+     * semantics for usable and reservered RAM. For example type RAM_TYPE_CONVENTIONAL can
+     * include the areas freed after OS loader calls ExitBootServices:
+     * EFI_LOADER_CODE, EFI_LOADER_DATA, EFI_BOOT_SERVICES_CODE, EFI_BOOT_SERVICES_DATA, and EFI_CONVENTIONAL_MEMORY
+     * The reserved regions would include:
+     * EFI_RUNTIME_SERVICES_CODE, EFI_RUNTIME_SERVICES_DATA, EFI_MEMORY_MAPPED_IO, EFI_MEMORY_MAPPED_IO_PORT_SPACE and EFI_PAL_CODE
+     */
     return (efi_mem_type(pfn_to_paddr(mfn)) == EFI_CONVENTIONAL_MEMORY);
 }
 
-
 long
 arch_memory_op(int op, XEN_GUEST_HANDLE(void) arg)
 {
index b0762825d2d050e7ee6921fd97951c9dec6f957e..4e8dd2d2390d0aa1db7c9d57c2e73b0fddd675c0 100644 (file)
@@ -287,15 +287,30 @@ void __init arch_init_memory(void)
     subarch_init_memory();
 }
 
-int page_is_conventional_ram(unsigned long mfn) /* CS 19085 mem to page, CS 19083 fixed test */
+int page_is_ram_type(unsigned long mfn, unsigned long mem_type) /* 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 <= maddr) &&
+        switch (e820.map[i].type)
+        {
+        case E820_RAM:
+            if (mem_type & RAM_TYPE_CONVENTIONAL)
+                break;
+            continue;
+        case E820_RESERVED:
+            if (mem_type & RAM_TYPE_RESERVED)
+                break;
+            continue;
+        default:
+            /* unknown */
+            continue;
+        }
+        
+        /* test the range */
+        if ( (e820.map[i].addr <= maddr) &&
              ((e820.map[i].addr + e820.map[i].size) >= (maddr + PAGE_SIZE)) )
             return 1;
     }
index e0a510ba0ac96c148f03a8af3483881c7605b34a..39557b6525776dc8e82410272a9bdfe86dfdf472 100644 (file)
@@ -995,6 +995,9 @@ void __init __start_xen(unsigned long mbi_p)
 
     if ( opt_watchdog ) 
         watchdog_enable();
+    
+    if ( !tboot_protect_mem_regions() )
+        panic("Could not protect TXT memory regions\n");
 
     /* Create initial domain 0. */
     dom0 = domain_create(0, 0, DOM0_SSIDREF);
@@ -1047,9 +1050,6 @@ void __init __start_xen(unsigned long mbi_p)
     if ( xen_cpuidle )
         xen_processor_pmbits |= XEN_PROCESSOR_PM_CX;
 
-    if ( !tboot_protect_mem_regions() )
-        panic("Could not protect TXT memory regions\n");
-
     /*
      * We're going to setup domain0 using the module(s) that we stashed safely
      * above our heap. The second module, if present, is an initrd ramdisk.
index 6b51bc32a97df9a2783c92828faadf4155ccd68f..608d34d39a41abe1547f244c22b2363c1728b9f6 100644 (file)
@@ -251,18 +251,6 @@ int __init tboot_parse_dmar_table(acpi_table_handler dmar_handler)
     return rc;
 }
 
-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 905104d76ff91853059549ae739b2d3bd217faa1..6808bd6cdece33f250beb77b63cec879604f1b45 100644 (file)
@@ -1035,7 +1035,6 @@ 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);
 
         /* 
          * Set up 1:1 page table for dom0 except the critical segments
@@ -1043,12 +1042,10 @@ static int intel_iommu_domain_init(struct domain *d)
          */
         for ( i = 0; i < max_page; i++ )
         {
-            /* CS 19084 remove tboot_in_range, CS 19085 use page_is_conventional_ram */              
-            /*if ( !page_is_conventional_ram(i) ||
+            /* CS 19084 remove tboot_in_range, CS 19085 use page_is_conventional_ram */
+            /* Modified to include reserved memory regions - this fix will be pushed upstream */             
+            if ( !page_is_ram_type(i, RAM_TYPE_CONVENTIONAL|RAM_TYPE_RESERVED) ||
                  xen_in_range(i << PAGE_SHIFT, (i + 1) << PAGE_SHIFT) )
-                continue;*/
-            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) )
                 continue;
 
             iommu_map_page(d, i, i);
index 302899ae37f4441cfcc6c69d1069cc0192ed5f35..05a704bfe05516db45e0be129d43e27a253f555c 100644 (file)
@@ -79,7 +79,7 @@ void __init vga_init(void)
     switch ( vga_console_info.video_type )
     {
     case XEN_VGATYPE_TEXT_MODE_3:
-        if ( page_is_conventional_ram(paddr_to_pfn(0xB8000)) ||  /* CS 19085 mem to page */
+        if ( page_is_ram_type(paddr_to_pfn(0xB8000), RAM_TYPE_CONVENTIONAL) ||  /* CS 19085 mem to page */
              ((video = ioremap(0xB8000, 0x8000)) == NULL) )
             return;
         outw(0x200a, 0x3d4); /* disable cursor */
index 1c0733e32a454a09ba771435191bb70d9c05874b..02eacf501acd1db1c83502aa9a0b4e627b2a20c3 100644 (file)
@@ -101,8 +101,10 @@ unsigned long avail_scrub_pages(void);
 
 int guest_remove_page(struct domain *d, unsigned long gmfn);
 
-/* Returns TRUE if the whole page at @mfn is ordinary RAM. */
-int page_is_conventional_ram(unsigned long mfn);
+#define RAM_TYPE_CONVENTIONAL 0x00000001
+#define RAM_TYPE_RESERVED     0x00000002
+/* Returns TRUE if the whole page at @mfn is of the requested RAM type(s) above. */
+int page_is_ram_type(unsigned long mfn, unsigned long mem_type);
 
 extern unsigned long *alloc_bitmap;    /* for vmcoreinfo */