]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
core, configs, tools: Add AMD-specific fields to struct jailhouse_iommu
authorJan Kiszka <jan.kiszka@siemens.com>
Fri, 13 Mar 2015 17:41:02 +0000 (22:41 +0500)
committerJan Kiszka <jan.kiszka@siemens.com>
Mon, 7 Mar 2016 12:49:05 +0000 (13:49 +0100)
For AMD, we also need to store the PCI address, capability offset and
IOMMU feature bits coming from ACPI (overwriting what the hardware
reports) in the cell configuration file.

Based on patches by Valentine Sinitsyn.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
configs/f2a88xm-hd3.c
hypervisor/include/jailhouse/cell-config.h
tools/jailhouse-config-create
tools/root-cell-config.c.tmpl

index d11ebd8a3b5ecc7df98abc727d8693c10d44fb21..3f3390a5aa064c3e758ec5139c1a21a9f3b189c1 100644 (file)
@@ -48,6 +48,10 @@ struct {
                                {
                                        .base = 0xfeb80000,
                                        .size = 0x80000,
+                                       .amd_bdf = 0x02,
+                                       .amd_base_cap = 0x40,
+                                       .amd_msi_cap = 0x54,
+                                       .amd_features = 0x80048824,
                                },
                        },
                },
index b21bf60de761c7e4005a0be18f383f79c0ea354f..e8bfadb2700f9cf29abfe1b3b5bd44bbff2cc3cf 100644 (file)
@@ -142,6 +142,10 @@ struct jailhouse_pci_capability {
 struct jailhouse_iommu {
        __u64 base;
        __u32 size;
+       __u16 amd_bdf;
+       __u8 amd_base_cap;
+       __u8 amd_msi_cap;
+       __u32 amd_features;
 } __attribute__((packed));
 
 #define JAILHOUSE_SYSTEM_SIGNATURE     "JAILSYST"
index b7207fb4145cb0ee181aaab0c6ebdf150fbdc701..4e61abcfc5bb604a08a57100e784e5d9fdc5c3cf 100755 (executable)
@@ -562,6 +562,15 @@ class IOMMUConfig(object):
     def __init__(self, props):
         self.base_addr = props['base_addr']
         self.mmio_size = props['mmio_size']
+        if 'amd_bdf' in props:
+            self.amd_bdf = props['amd_bdf']
+            self.amd_base_cap = props['amd_base_cap']
+            self.amd_msi_cap = props['amd_msi_cap']
+            self.amd_features = props['amd_features']
+
+    @property
+    def is_amd_iommu(self):
+        return hasattr(self, 'amd_bdf')
 
 
 def parse_iomem(pcidevices):
@@ -877,11 +886,21 @@ def parse_ivrs(pcidevices, ioapics):
                 raise RuntimeError('Too many IOMMU units. '
                                    'Raise JAILHOUSE_MAX_IOMMU_UNITS.')
 
+            msi_cap_ofs = None
+
             for i, d in enumerate(pcidevices):
                 if d.bdf() == iommu_bdf:
+                    # Extract MSI capability offset
+                    for c in d.caps:
+                        if c.id == 0x05:
+                            msi_cap_ofs = c.start
                     # We must not map IOMMU to the cells
                     del pcidevices[i]
 
+            if msi_cap_ofs is None:
+                raise RuntimeError('AMD IOMMU lacks MSI support, and '
+                                   'Jailhouse doesn\'t support MSI-X yet.')
+
             if (iommu_feat & (0xF << 13)) and (iommu_feat & (0x3F << 17)):
                 # Performance Counters are supported, allocate 512K
                 mmio_size = 524288
@@ -892,6 +911,13 @@ def parse_ivrs(pcidevices, ioapics):
             units.append(IOMMUConfig({
                 'base_addr': base_addr,
                 'mmio_size': mmio_size,
+                'amd_bdf': iommu_bdf,
+                'amd_base_cap': base_cap_ofs,
+                'amd_msi_cap': msi_cap_ofs,
+                # IVHD block type 0x11 has exact EFR copy but type 0x10 may
+                # overwrite what hardware reports. Set reserved bit 0 in that
+                # case to indicate that the value is in use.
+                'amd_features': (iommu_feat | 0x1) if block_type == 0x10 else 0
             }))
 
             bdf_start_range = None
index 1e5f9f1079b8e5169582f72754873405b8ac5b7c..5ee376784e2665907b5aaa80475a306c55e653f0 100644 (file)
@@ -72,6 +72,12 @@ struct {
                                {
                                        .base = ${hex(unit.base_addr)},
                                        .size = ${hex(unit.mmio_size)},
+                                       % if unit.is_amd_iommu:
+                                       .amd_bdf = ${hex(unit.amd_bdf)},
+                                       .amd_base_cap = ${hex(unit.amd_base_cap)},
+                                       .amd_msi_cap = ${hex(unit.amd_msi_cap)},
+                                       .amd_features = ${hex(unit.amd_features)},
+                                       % endif
                                },
                                % endfor
                        },