Skip to contentSkip to conversation

x86-64/MMCFG: pass down firmware (ACPI) reservation status of used memory space

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

lore
Share & tools
lore
#0 lore raw

PATCH 3/3 x86-64/MMCFG: pass down firmware (ACPI) reservation status of used memory space

Reserving the MMCFG address range(s) in E820 is specified to only be optional for the firmware to do. The requirement is to have them reserved in ACPI resources. Those, however, aren't directly visible to Xen as they require the ACPI interpreter to be active. Thus, if a range isn't reserved in E820, we should not completely disable use of MMCFG on the respective bus range, but rather keep it disabled until Dom0 can pass down information on the ACPI reservation status (though a new physdevop hypercall).

xen/arch/x86/physdev.c +22 -0
@@ -21,6 +21,10 @@ int physdev_map_pirq(domid_t, int type, 
                      struct msi_info *);
 int physdev_unmap_pirq(domid_t, int pirq);
 
+#ifdef CONFIG_X86_64
+#include "x86_64/mmconfig.h"
+#endif
+
 #ifndef COMPAT
 typedef long ret_t;
 
@@ -522,6 +526,24 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_H
         break;
     }
 
+#ifdef __x86_64__
+    case PHYSDEVOP_pci_mmcfg_reserved: {
+        struct physdev_pci_mmcfg_reserved info;
+
+        ret = -EPERM;
+        if ( !IS_PRIV(current->domain) )
+            break;
+
+        ret = -EFAULT;
+        if ( copy_from_guest(&info, arg, 1) )
+            break;
+
+        ret = pci_mmcfg_reserved(info.address, info.segment,
+                                 info.start_bus, info.end_bus, info.flags);
+        break;
+    }
+#endif
+
     case PHYSDEVOP_restore_msi: {
         struct physdev_restore_msi restore_msi;
         struct pci_dev *pdev;
xen/arch/x86/x86_64/mmconfig.h +5 -1
@@ -85,5 +85,9 @@ extern struct acpi_mcfg_allocation *pci_
 
 /* function prototypes */
 int acpi_parse_mcfg(struct acpi_table_header *header);
+int pci_mmcfg_reserved(uint64_t address, unsigned int segment,
+                       unsigned int start_bus, unsigned int end_bus,
+                       unsigned int flags);
 int pci_mmcfg_arch_init(void);
-void pci_mmcfg_arch_free(void);
+int pci_mmcfg_arch_enable(unsigned int);
+void pci_mmcfg_arch_disable(unsigned int);
xen/arch/x86/x86_64/mmconfig-shared.c +58 -31

161 lines not on this page · raw message

xen/arch/x86/x86_64/mmconfig_64.c +39 -36

104 lines not on this page · raw message

xen/arch/x86/x86_64/physdev.c +4 -0
@@ -63,6 +63,10 @@ CHECK_physdev_setup_gsi;
 CHECK_physdev_get_free_pirq;
 #undef xen_physdev_get_free_pirq
 
+#define xen_physdev_pci_mmcfg_reserved physdev_pci_mmcfg_reserved
+CHECK_physdev_pci_mmcfg_reserved;
+#undef xen_physdev_pci_mmcfg_reserved
+
 #define COMPAT
 #undef guest_handle_okay
 #define guest_handle_okay          compat_handle_okay
xen/include/public/physdev.h +13 -0
@@ -255,6 +255,19 @@ struct physdev_get_free_pirq {
 typedef struct physdev_get_free_pirq physdev_get_free_pirq_t;
 DEFINE_XEN_GUEST_HANDLE(physdev_get_free_pirq_t);
 
+#define XEN_PCI_MMCFG_RESERVED         0x1
+
+#define PHYSDEVOP_pci_mmcfg_reserved    24
+struct physdev_pci_mmcfg_reserved {
+    uint64_t address;
+    uint16_t segment;
+    uint8_t start_bus;
+    uint8_t end_bus;
+    uint32_t flags;
+};
+typedef struct physdev_pci_mmcfg_reserved physdev_pci_mmcfg_reserved_t;
+DEFINE_XEN_GUEST_HANDLE(physdev_pci_mmcfg_reserved_t);
+
 /*
  * Notify that some PIRQ-bound event channels have been unmasked.
  * ** This command is obsolete since interface version 0x00030202 and is **
xen/include/xlat.lst +1 -0
@@ -65,6 +65,7 @@
 ?	physdev_irq_status_query	physdev.h
 ?	physdev_manage_pci		physdev.h
 ?	physdev_manage_pci_ext		physdev.h
+?	physdev_pci_mmcfg_reserved	physdev.h
 ?	physdev_unmap_pirq		physdev.h
 ?	physdev_restore_msi		physdev.h
 ?	physdev_set_iopl		physdev.h

Reserving the MMCFG address range(s) in E820 is specified to only be optional for the firmware to do. The requirement is to have them reserved in ACPI resources. Those, however, aren't directly visible to Xen as they require the ACPI interpreter to be active. Thus, if a range isn't reserved in E820, we should not completely disable use of MMCFG on the respective bus range, but rather keep it disabled until Dom0 can pass down information on the ACPI reservation status (though a new physdevop hypercall).

xen/arch/x86/physdev.c +22 -0
@@ -21,6 +21,10 @@ int physdev_map_pirq(domid_t, int type, 
                      struct msi_info *);
 int physdev_unmap_pirq(domid_t, int pirq);
 
+#ifdef CONFIG_X86_64
+#include "x86_64/mmconfig.h"
+#endif
+
 #ifndef COMPAT
 typedef long ret_t;
 
@@ -522,6 +526,24 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_H
         break;
     }
 
+#ifdef __x86_64__
+    case PHYSDEVOP_pci_mmcfg_reserved: {
+        struct physdev_pci_mmcfg_reserved info;
+
+        ret = -EPERM;
+        if ( !IS_PRIV(current->domain) )
+            break;
+
+        ret = -EFAULT;
+        if ( copy_from_guest(&info, arg, 1) )
+            break;
+
+        ret = pci_mmcfg_reserved(info.address, info.segment,
+                                 info.start_bus, info.end_bus, info.flags);
+        break;
+    }
+#endif
+
     case PHYSDEVOP_restore_msi: {
         struct physdev_restore_msi restore_msi;
         struct pci_dev *pdev;
xen/arch/x86/x86_64/mmconfig.h +5 -1
@@ -85,5 +85,9 @@ extern struct acpi_mcfg_allocation *pci_
 
 /* function prototypes */
 int acpi_parse_mcfg(struct acpi_table_header *header);
+int pci_mmcfg_reserved(uint64_t address, unsigned int segment,
+                       unsigned int start_bus, unsigned int end_bus,
+                       unsigned int flags);
 int pci_mmcfg_arch_init(void);
-void pci_mmcfg_arch_free(void);
+int pci_mmcfg_arch_enable(unsigned int);
+void pci_mmcfg_arch_disable(unsigned int);
xen/arch/x86/x86_64/mmconfig-shared.c +58 -31

161 lines not on this page · raw message

xen/arch/x86/x86_64/mmconfig_64.c +39 -36

104 lines not on this page · raw message

xen/arch/x86/x86_64/physdev.c +4 -0
@@ -63,6 +63,10 @@ CHECK_physdev_setup_gsi;
 CHECK_physdev_get_free_pirq;
 #undef xen_physdev_get_free_pirq
 
+#define xen_physdev_pci_mmcfg_reserved physdev_pci_mmcfg_reserved
+CHECK_physdev_pci_mmcfg_reserved;
+#undef xen_physdev_pci_mmcfg_reserved
+
 #define COMPAT
 #undef guest_handle_okay
 #define guest_handle_okay          compat_handle_okay
xen/include/public/physdev.h +13 -0
@@ -255,6 +255,19 @@ struct physdev_get_free_pirq {
 typedef struct physdev_get_free_pirq physdev_get_free_pirq_t;
 DEFINE_XEN_GUEST_HANDLE(physdev_get_free_pirq_t);
 
+#define XEN_PCI_MMCFG_RESERVED         0x1
+
+#define PHYSDEVOP_pci_mmcfg_reserved    24
+struct physdev_pci_mmcfg_reserved {
+    uint64_t address;
+    uint16_t segment;
+    uint8_t start_bus;
+    uint8_t end_bus;
+    uint32_t flags;
+};
+typedef struct physdev_pci_mmcfg_reserved physdev_pci_mmcfg_reserved_t;
+DEFINE_XEN_GUEST_HANDLE(physdev_pci_mmcfg_reserved_t);
+
 /*
  * Notify that some PIRQ-bound event channels have been unmasked.
  * ** This command is obsolete since interface version 0x00030202 and is **
xen/include/xlat.lst +1 -0
@@ -65,6 +65,7 @@
 ?	physdev_irq_status_query	physdev.h
 ?	physdev_manage_pci		physdev.h
 ?	physdev_manage_pci_ext		physdev.h
+?	physdev_pci_mmcfg_reserved	physdev.h
 ?	physdev_unmap_pirq		physdev.h
 ?	physdev_restore_msi		physdev.h
 ?	physdev_set_iopl		physdev.h

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel