Skip to contentSkip to conversation

x86-64/MMCFG: finally make Fam10 enabling work

PATCH In review Jan Beulich 1 participant 1 message Jul 19, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 2/3 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.

xen/arch/x86/acpi/boot.c +0 -2
@@ -832,8 +832,6 @@ int __init acpi_boot_init(void)
 
 	acpi_dmar_init();
 
-	acpi_mmcfg_init();
-
 	erst_init();
 
 	return 0;
xen/arch/x86/e820.c +49 -0

55 lines not on this page · raw message

xen/arch/x86/setup.c +2 -0
@@ -1248,6 +1248,8 @@ void __init __start_xen(unsigned long mb
 
 #ifdef CONFIG_X86_64
     vesa_mtrr_init();
+
+    acpi_mmcfg_init();
 #endif
 
     if ( opt_nosmp )
xen/arch/x86/x86_32/pci.c +0 -5
@@ -60,8 +60,3 @@ int pci_find_ext_capability(int seg, int
 {
     return 0;
 }
-
-void acpi_mmcfg_init(void)
-{
-    return;
-}
xen/arch/x86/x86_64/mmconf-fam10h.c +3 -1
@@ -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 @@ static void __init get_fam10h_pci_mmconf
 	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)
xen/include/asm-x86/e820.h +2 -0
@@ -28,6 +28,8 @@ extern int reserve_e820_ram(struct e820m
 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;
 

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.

xen/arch/x86/acpi/boot.c +0 -2
@@ -832,8 +832,6 @@ int __init acpi_boot_init(void)
 
 	acpi_dmar_init();
 
-	acpi_mmcfg_init();
-
 	erst_init();
 
 	return 0;
xen/arch/x86/e820.c +49 -0

55 lines not on this page · raw message

xen/arch/x86/setup.c +2 -0
@@ -1248,6 +1248,8 @@ void __init __start_xen(unsigned long mb
 
 #ifdef CONFIG_X86_64
     vesa_mtrr_init();
+
+    acpi_mmcfg_init();
 #endif
 
     if ( opt_nosmp )
xen/arch/x86/x86_32/pci.c +0 -5
@@ -60,8 +60,3 @@ int pci_find_ext_capability(int seg, int
 {
     return 0;
 }
-
-void acpi_mmcfg_init(void)
-{
-    return;
-}
xen/arch/x86/x86_64/mmconf-fam10h.c +3 -1
@@ -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 @@ static void __init get_fam10h_pci_mmconf
 	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)
xen/include/asm-x86/e820.h +2 -0
@@ -28,6 +28,8 @@ extern int reserve_e820_ram(struct e820m
 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-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel