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-changelog

[Xen-changelog] [xen-unstable] x86-64/MMCFG: finally make Fam10 enabling

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] x86-64/MMCFG: finally make Fam10 enabling work
From: Xen patchbot-unstable <patchbot@xxxxxxx>
Date: Wed, 03 Aug 2011 21:44:14 +0100
Delivery-date: Wed, 03 Aug 2011 13:47:04 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Jan Beulich <jbeulich@xxxxxxxxxx>
# Date 1311608573 -3600
# Node ID e1717d180897e6e7a04d83a41d86b35ac16912b9
# Parent  b07b6fa766562c990b1d1e59af032feda15c2edb
x86-64/MMCFG: finally make Fam10 enabling work

Forcibly enabling the MMCFG space on AMD Fam10 CPUs cannot be expected
to work since with the firmware not being aware of the address range
used it cannot possibly reserve the space in E820 or ACPI resources.
Hence we need to manually insert the range into the E820 table, and
enable the range only when the insertion actually works without
conflict.

Further, the actual enabling of the space is done from identify_cpu(),
which means that acpi_mmcfg_init() muts be called after that function
(and hance should not be called from acpi_boot_init()). Otherwise,
Dom0 would be able to use MMCFG, but Xen wouldn't.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>
---


diff -r b07b6fa76656 -r e1717d180897 xen/arch/x86/acpi/boot.c
--- a/xen/arch/x86/acpi/boot.c  Mon Jul 25 16:42:19 2011 +0100
+++ b/xen/arch/x86/acpi/boot.c  Mon Jul 25 16:42:53 2011 +0100
@@ -832,8 +832,6 @@
 
        acpi_dmar_init();
 
-       acpi_mmcfg_init();
-
        erst_init();
 
        return 0;
diff -r b07b6fa76656 -r e1717d180897 xen/arch/x86/e820.c
--- a/xen/arch/x86/e820.c       Mon Jul 25 16:42:19 2011 +0100
+++ b/xen/arch/x86/e820.c       Mon Jul 25 16:42:53 2011 +0100
@@ -563,6 +563,55 @@
         clip_to_limit(top_of_ram, "MTRRs do not cover all of memory.");
 }
 
+/* This function relies on the passed in e820->map[] being sorted. */
+int __init e820_add_range(
+    struct e820map *e820, uint64_t s, uint64_t e, uint32_t type)
+{
+    unsigned int i;
+
+    for ( i = 0; i < e820->nr_map; ++i )
+    {
+        uint64_t rs = e820->map[i].addr;
+        uint64_t re = rs + e820->map[i].size;
+
+        if ( rs == e && e820->map[i].type == type )
+        {
+            e820->map[i].addr = s;
+            return 1;
+        }
+
+        if ( re == s && e820->map[i].type == type &&
+             (i + 1 == e820->nr_map || e820->map[i + 1].addr >= e) )
+        {
+            e820->map[i].size += e - s;
+            return 1;
+        }
+
+        if ( rs >= e )
+            break;
+
+        if ( re > s )
+            return 0;
+    }
+
+    if ( e820->nr_map >= ARRAY_SIZE(e820->map) )
+    {
+        printk(XENLOG_WARNING "E820: overflow while adding region"
+               " %"PRIx64"-%"PRIx64"\n", s, e);
+        return 0;
+    }
+
+    memmove(e820->map + i + 1, e820->map + i,
+            (e820->nr_map - i) * sizeof(*e820->map));
+
+    e820->nr_map++;
+    e820->map[i].addr = s;
+    e820->map[i].size = e - s;
+    e820->map[i].type = type;
+
+    return 1;
+}
+
 int __init e820_change_range_type(
     struct e820map *e820, uint64_t s, uint64_t e,
     uint32_t orig_type, uint32_t new_type)
diff -r b07b6fa76656 -r e1717d180897 xen/arch/x86/setup.c
--- a/xen/arch/x86/setup.c      Mon Jul 25 16:42:19 2011 +0100
+++ b/xen/arch/x86/setup.c      Mon Jul 25 16:42:53 2011 +0100
@@ -1248,6 +1248,8 @@
 
 #ifdef CONFIG_X86_64
     vesa_mtrr_init();
+
+    acpi_mmcfg_init();
 #endif
 
     if ( opt_nosmp )
diff -r b07b6fa76656 -r e1717d180897 xen/arch/x86/x86_32/pci.c
--- a/xen/arch/x86/x86_32/pci.c Mon Jul 25 16:42:19 2011 +0100
+++ b/xen/arch/x86/x86_32/pci.c Mon Jul 25 16:42:53 2011 +0100
@@ -60,8 +60,3 @@
 {
     return 0;
 }
-
-void acpi_mmcfg_init(void)
-{
-    return;
-}
diff -r b07b6fa76656 -r e1717d180897 xen/arch/x86/x86_64/mmconf-fam10h.c
--- a/xen/arch/x86/x86_64/mmconf-fam10h.c       Mon Jul 25 16:42:19 2011 +0100
+++ b/xen/arch/x86/x86_64/mmconf-fam10h.c       Mon Jul 25 16:42:53 2011 +0100
@@ -9,6 +9,7 @@
 #include <xen/init.h>
 #include <xen/dmi.h>
 #include <asm/amd.h>
+#include <asm/e820.h>
 #include <asm/msr.h>
 #include <asm/processor.h>
 
@@ -131,7 +132,8 @@
        return;
 
 out:
-       fam10h_pci_mmconf_base = start;
+       if (e820_add_range(&e820, start, start + SIZE, E820_RESERVED))
+               fam10h_pci_mmconf_base = start;
 }
 
 void __cpuinit fam10h_check_enable_mmcfg(void)
diff -r b07b6fa76656 -r e1717d180897 xen/include/asm-x86/e820.h
--- a/xen/include/asm-x86/e820.h        Mon Jul 25 16:42:19 2011 +0100
+++ b/xen/include/asm-x86/e820.h        Mon Jul 25 16:42:53 2011 +0100
@@ -28,6 +28,8 @@
 extern int e820_change_range_type(
     struct e820map *e820, uint64_t s, uint64_t e,
     uint32_t orig_type, uint32_t new_type);
+extern int e820_add_range(
+    struct e820map *, uint64_t s, uint64_t e, uint32_t type);
 extern unsigned long init_e820(const char *, struct e820entry *, int *);
 extern struct e820map e820;
 

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] x86-64/MMCFG: finally make Fam10 enabling work, Xen patchbot-unstable <=