]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
core, configs, tools: Introduce struct jailhouse_iommu
authorJan Kiszka <jan.kiszka@siemens.com>
Thu, 18 Feb 2016 06:13:02 +0000 (07:13 +0100)
committerJan Kiszka <jan.kiszka@siemens.com>
Sat, 5 Mar 2016 09:37:45 +0000 (10:37 +0100)
For both AMD and Intel, we need to store not only base address but also
a size to map the complete MMIO region. Moreover, AMD requires a number
of PCI device parameters for the IOMMU. Introduce struct jailhouse_iommu
that will encapsulate all required data.

Based on patches by Valentine Sinitsyn.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
configs/f2a88xm-hd3.c
configs/h87i.c
configs/qemu-vm.c
hypervisor/arch/x86/iommu.c
hypervisor/arch/x86/vtd.c
hypervisor/include/jailhouse/cell-config.h
tools/root-cell-config.c.tmpl

index 545da808da65bb6a7ba95af223611fa2e649cbeb..825452aacfa0d4ef9afcec2f9ae5d180d43187da 100644 (file)
@@ -44,8 +44,10 @@ struct {
                        .mmconfig_base = 0xe0000000,
                        .mmconfig_end_bus = 0xff,
                        .pm_timer_address = 0x808,
-                       .iommu_base = {
-                               0xfeb80000,
+                       .iommu_units = {
+                               {
+                                       .base = 0xfeb80000,
+                               },
                        },
                },
                .device_limit = 128,
index 521d27425928165a83c8e927555479639bfd89a0..2015729c90f5b3ecf5f8cc933baa5a00a7912957 100644 (file)
@@ -39,9 +39,13 @@ struct {
                        .mmconfig_base = 0xf8000000,
                        .mmconfig_end_bus = 0x3f,
                        .pm_timer_address = 0x1808,
-                       .iommu_base = {
-                               0xfed90000,
-                               0xfed91000,
+                       .iommu_units = {
+                               {
+                                       .base = 0xfed90000,
+                               },
+                               {
+                                       .base = 0xfed91000,
+                               },
                        },
                },
                .interrupt_limit = 256,
index 1f9966ec2fe2f2f6e6e721c09e9cc6db1c034c03..1d7481e8a35f2bd5c35581a09676f66fab85ea2e 100644 (file)
@@ -53,8 +53,10 @@ struct {
                        .mmconfig_base = 0xb0000000,
                        .mmconfig_end_bus = 0xff,
                        .pm_timer_address = 0x608,
-                       .iommu_base = {
-                               0xfed90000,
+                       .iommu_units = {
+                               {
+                                       .base = 0xfed90000,
+                               },
                        },
                },
                .interrupt_limit = 256,
index 3da61d60b9e9be884da704a161a030cb1119cdd7..11f35bcf21ede68dffb39900d3e508700ea02fb3 100644 (file)
@@ -18,7 +18,7 @@ unsigned int iommu_count_units(void)
        unsigned int units = 0;
 
        while (units < JAILHOUSE_MAX_IOMMU_UNITS &&
-              system_config->platform_info.x86.iommu_base[units])
+              system_config->platform_info.x86.iommu_units[units].base)
                units++;
        return units;
 }
index 18d6e4ce00d78f1532c0bb1217a5fe5423d66a15..5826b87f0a1a1f6f425aa2ac8b39caa508072d01 100644 (file)
@@ -421,7 +421,7 @@ static int vtd_init_ir_emulation(unsigned int unit_no, void *reg_base)
 
        root_cell.arch.vtd.ir_emulation = true;
 
-       base = system_config->platform_info.x86.iommu_base[unit_no];
+       base = system_config->platform_info.x86.iommu_units[unit_no].base;
        mmio_region_register(&root_cell, base, PAGE_SIZE,
                             vtd_unit_access_handler, unit);
 
@@ -454,8 +454,8 @@ int iommu_init(void)
 {
        unsigned long version, caps, ecaps, ctrls, sllps_caps = ~0UL;
        unsigned int units, pt_levels, num_did, n;
+       struct jailhouse_iommu *unit;
        void *reg_base;
-       u64 base_addr;
        int err;
 
        /* n = roundup(log2(system_config->interrupt_limit)) */
@@ -484,11 +484,11 @@ int iommu_init(void)
                return -ENOMEM;
 
        for (n = 0; n < units; n++) {
-               base_addr = system_config->platform_info.x86.iommu_base[n];
+               unit = &system_config->platform_info.x86.iommu_units[n];
 
                reg_base = dmar_reg_base + n * PAGE_SIZE;
 
-               err = paging_create(&hv_paging_structs, base_addr, PAGE_SIZE,
+               err = paging_create(&hv_paging_structs, unit->base, PAGE_SIZE,
                                    (unsigned long)reg_base,
                                    PAGE_DEFAULT_FLAGS | PAGE_FLAG_DEVICE,
                                    PAGING_NON_COHERENT);
@@ -503,7 +503,7 @@ int iommu_init(void)
                        return 0;
                }
 
-               printk("Found DMAR @%p\n", base_addr);
+               printk("Found DMAR @%p\n", unit->base);
 
                caps = mmio_read64(reg_base + VTD_CAP_REG);
                if (caps & VTD_CAP_SAGAW39)
index 169e3ca5ef62cee4e90b29655f4bc4928f7edb81..84ffa5c28478a083b6959b41b6e5fed75020df27 100644 (file)
@@ -139,6 +139,10 @@ struct jailhouse_pci_capability {
 
 #define JAILHOUSE_MAX_IOMMU_UNITS      8
 
+struct jailhouse_iommu {
+       __u64 base;
+} __attribute__((packed));
+
 #define JAILHOUSE_SYSTEM_SIGNATURE     "JAILSYST"
 
 struct jailhouse_system {
@@ -151,7 +155,8 @@ struct jailhouse_system {
                        __u8 mmconfig_end_bus;
                        __u8 padding[5];
                        __u16 pm_timer_address;
-                       __u64 iommu_base[JAILHOUSE_MAX_IOMMU_UNITS];
+                       struct jailhouse_iommu
+                               iommu_units[JAILHOUSE_MAX_IOMMU_UNITS];
                } __attribute__((packed)) x86;
        } __attribute__((packed)) platform_info;
        __u32 device_limit;
index a15fbfe72fe0edc2693c9b11bd62062bf8448459..631fcd9d014e557071f7d047939d8045c6bced36 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Jailhouse, a Linux-based partitioning hypervisor
  *
- * Copyright (c) Siemens AG, 2014, 2015
+ * Copyright (c) Siemens AG, 2014-2016
  *
  * This work is licensed under the terms of the GNU GPL, version 2.  See
  * the COPYING file in the top-level directory.
@@ -67,9 +67,11 @@ struct {
                        .mmconfig_end_bus = ${hex(mmconfig.end_bus)},
                        .pm_timer_address = ${hex(pm_timer_base)},
                        % if iommu_units:
-                       .iommu_base = {
+                       .iommu_units = {
                                % for d in iommu_units:
-                               ${hex(d)},
+                               {
+                                       .base = ${hex(d)},
+                               },
                                % endfor
                        },
                        % endif